Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
6 posts Page 1 of 1
Here is the code to easily have a CMS module to control the webpages TITLE, DESCRIPTION, and Keywords:

Add the following code to your CMS FILE (or in between the <template></template> tag on the page/template:

Code: Select all
    <cms:editable name='page_section_header' label='Homepage Meta/Head Details' type='group' />
        <cms:editable name='page_title' type='text' label='Page Title' group='page_section_header' maxlength="55" desc='For SEO Please keep it under 55 Characters'>Please enter the page title here</cms:editable>
        <cms:editable name='page_desc' type='text' label='Page Description' group='page_section_header' maxlength="160" desc='For SEO Please keep it under 160 Characters'>Please enter a short page description here</cms:editable>
        <cms:editable name='page_keywords' type='text' label='Page Keywords' desc='Seperate key words with a comma' group='page_section_header' desc='For SEO Please keep it 10 keyword Phrases Seperated by Commas'>Please, enter, keywords, here, with, commas, separating, them</cms:editable>


Take note: Google is currently ignoring the keywords tag(or so they say) but I bet it will make a comeback and is good for other search engines as well.

Add the following code in between the <head></head> tag of your webpage/template:

If NOT using clonable template page (clonable='0'):
Code: Select all
<title><cms:get_custom_field 'page_title' masterpage=k_template_name /></title>
<meta name="description" content="<cms:get_custom_field 'page_desc' masterpage=k_template_name />
<meta name="keywords" content="<cms:get_custom_field 'page_keywords' masterpage=k_template_name />


If using clonable template page (clonable='1'):
Code: Select all
      
   <title><cms:if k_is_list ><cms:get_custom_field 'page_title' masterpage=k_template_name /><cms:else /><cms:if k_is_page ><cms:show page_title /></cms:if><cms:if k_is_folder ><cms:show page_title /></cms:if><cms:if k_is_archive ><cms:show page_title /></cms:if><cms:if k_is_home ><cms:show page_title /></cms:if></cms:if></title>   
    <meta name="description" content="<cms:if k_is_list ><cms:get_custom_field 'page_desc' masterpage=k_template_name /><cms:else /><cms:if k_is_page ><cms:show page_desc /></cms:if><cms:if k_is_folder ><cms:show page_desc /></cms:if><cms:if k_is_archive ><cms:show page_desc /></cms:if><cms:if k_is_home ><cms:show page_title /></cms:if></cms:if>" />
    <meta name="keywords" content="<cms:if k_is_list ><cms:get_custom_field 'page_keywords' masterpage=k_template_name /><cms:else /><cms:if k_is_page ><cms:show page_keywords /></cms:if><cms:if k_is_folder ><cms:show page_keywords /></cms:if><cms:if k_is_archive ><cms:show page_desc /></cms:if><cms:if k_is_home ><cms:show page_title /></cms:if></cms:if>" />


I Hope that this useful :)

- Developernator
Hi developernator,

You are quite productive with some very useful code snippets, Thank you for your input !

I try to optimize my couch site and looking at your solution make me wonder what this precisely means/does.....

Code: Select all
$currentpage = basename($_SERVER["PHP_SELF"]);


Could you explain this in more detail ?

Thanks again
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hello,

The snippet gets the page file name you are on including the extension after the template name when using clone-able pages ....such as index.php?p=1 .... That would grab the "index.php?p=1" and so that it can be matched with the CMS template file. This is really in place to support clonal pages with this snippet.

If you are not using clonal templates you do not need to add it and you can

use the front end snippet with the masterpage=thePageYouAreOnOrThePagewithTheTemplate Tag:

such as


Code: Select all
<cms:get_custom_field 'page_title' masterpage='<?php echo $currentpage; ?>


can be replaced with:

Code: Select all
<cms:get_custom_field 'page_title' masterpage='index.php'>


UPDATED: The echo function and addition to the language file is not needed is already built into the CMS, so it can easily just be:

Code: Select all
<cms:get_custom_field 'page_title' masterpage=k_template_name>


Hope that helps :)
Hope that helps


Yes it does.

Thanks for taking the time to explain this.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hello, module work ,but page corrupted, anyone please explain more specifically ?
Hello @Viktor341 :)

Couch does not make any changes to your static markup so if your page appears corrupt (I assume you mean the HTML markup is not correct), please do a view-source and see what the generated HTML looks like. It should give you a clue as to where the problem lies.
6 posts Page 1 of 1