Forum for discussing general topics related to Couch.
11 posts Page 1 of 2
I've implemented Couch on a website in the past couple of days and it was a smooth ride. If I couldn't find answers to my questions in the Documentation, which itself is really concise, I found them in the Forums.

One answer I haven't been able to find though. It concerns page-specific META description values. I have a template and it's not at all a problem to get specific description for each of the pages of the template. However, I'd like to enable my client to enter specific description for the list-of-pages page itself. Or in Couch language, for the k_is_home page :)

Basically, I'd like this page to have a specific description: http://www.dentalpavelic.hr/usluge/
It's subpages (children) were easy to add specific description to: http://www.dentalpavelic.hr/usluge/implantati.html
I simply added a "description" editable field in the template and call it for each page with this line, placed in header.inc:

Code: Select all
<meta name="page_description" content="<cms:show page_description />">

Currently I'm showing specific description for pages and global description for page lists and the homepage:

Code: Select all
<cms:if k_is_page>
    <meta name="description" content="<cms:show page_description />">
<cms:else />
    <meta name="description" content="Here goes a global description of the website.">
</cms:if>

But like I said before, I'd like for all of the pages of the website to have specific META description tags if at all possible.

Can this be done somehow with custom fields, via globals.php...? I tried several things, experimented a bit, but with no success. Any help would be greatly appreciated!
Hi Davor :)

The following section of our Aurelius tutorial deals *exactly* with the problem you mentioned -
http://www.couchcms.com/docs/tutorials/ ... -ends.html
Please see the 'Global values' part of it.

So, for example if you define a region for template 'usluge.php' as 'usluge_description', following is how your code will now become
Code: Select all
<cms:if k_is_page>
    <meta name="description" content="<cms:show page_description />">
<cms:else />
    <meta name="description" content="<cms:get_custom_field 'usluge_description' masterpage='globals.php' />">
</cms:if>

Does this help?
Hey KK, thank you for a prompt answer! I probably should've mentioned that I also have two other clonable templates in place, so this approach would only cover one of three :)

Should I've gone with a single clonable template and three folders instead? Probably yes, but I thought this would've been easier for my client - to have separate links in admin for each of the three content sections respectively.

What do you think about this?

P.S.
I know you've heard it a million times by now, but Couch is so wonderfully easy to work with and at the same time so powerful. First time tried the Gallery feature and it is magnificent! Also in-page editing worked so easily, just not sure if it's needed for this particular project. Great work my friend!
Thank you very much for the kind words, my friend :)

As for the three different templates, the idea is to create three editable regions in globals.php - one for each template.
Then on each individual template you specify the name of the right editable region.

Or is it that your code is in a snippet shared by all the templates and so you'd want something that'll work with all the templates?

One way would be to use if/else statements e.g.
Code: Select all
<cms:if k_is_page>
    <meta name="description" content="<cms:show page_description />">
<cms:else />
    <cms:if k_template_name='one.php'>
        <meta name="description" content="<cms:get_custom_field 'one_description' masterpage='globals.php' />">
    </cms:if>   
    <cms:if k_template_name='two.php'>
        <meta name="description" content="<cms:get_custom_field 'two_description' masterpage='globals.php' />">
    </cms:if> 
    <cms:if k_template_name='three.php'>
        <meta name="description" content="<cms:get_custom_field 'three_description' masterpage='globals.php' />">
    </cms:if> 
</cms:if>


There is one more approach if you can use single words as template titles e.g.
Code: Select all
<cms:template title='One' clonable='1' > 
<cms:template title='Two' clonable='1' >

etc.

If so, you can do the following -
In 'globals.php', create editable regions for each template and name them the same as the corresponding template's title.
e.g.
Code: Select all
<cms:editable name='One' desc='desc for template one' type='text' />
<cms:editable name='Two' desc='desc for template one' type='text' />

Now your code in the snippet can simply become -
Code: Select all
<cms:if k_is_page>
    <meta name="description" content="<cms:show page_description />">
<cms:else />
    <meta name="description" content="<cms:get_custom_field k_template_title masterpage='globals.php' />">
</cms:if>

Notice we are using the 'k_template_title' variable to get the right editable region.

Hope I was able to understand the problem correctly.
Please let me know.

Thanks.
KK, thanks for a detailed answer.

Or is it that your code is in a snippet shared by all the templates and so you'd want something that'll work with all the templates?

This is exactly the situation.

One way would be to use if/else statements e.g.

This was obvious and was my "last resort" so to speak :) In my case this works as the website already has a strictly defined structure and works with a small enough, and therefore manageable, number of templates.

Thanks for confirming my thoughts about this being a solid solution ;)

I guess the thing is I got very confident by now, after getting familiar with Couch more and more, so I kept asking myself if there was a better, universal solution, which I wasn't aware of.

There is one more approach if you can use single words as template titles e.g.

Actually I am using single words as template titles in this case! Thanks, I'll definitely try out the solution proposed here!

Btw, in the documentation, I stumbled upon the "k_template_desc" variable, but couldn't quite figure out what purpose does it serve. Thought it might be there for "template description". How wrong was I? :D
I stumbled upon the "k_template_desc" variable, but couldn't quite figure out what purpose does it serve. Thought it might be there for "template description". How wrong was I?
You are right - it does stand for "template description". However, it is not (as of the current version) utilized by Couch for that purpose, I am afraid.
Hi Guys,

I know this topic has been a while, but would like to share how I'm implementing meta tags site wide with different templates. KK you input would be great if my method is the right way or not

Basically I created the meta fields in a file called meta.html and placed it in embeds folder:

Code: Select all
<cms:editable name='meta_information' label='Meta Information' type='group' order='1' />

<cms:editable
   name='meta_title'
   label='Meta Title'
   maxlength='80'
   group='meta_information'
   type='text' />

<cms:editable
   name='meta_desc'
   label='Meta Description'
   maxlength='150'
   group='meta_information'
   type='text' />


And then I simply embedded meta.html in each template that I created

Code: Select all
<cms:embed 'meta.html' />


Its working fine so far, although no sure at this stage if there's any performance penalties or other issues down the line.

Hope this helps

Regards
Said
Hi Said,

Your approach is perfectly fine.
By using the embedded snippet, you are defining the two editable regions for all templates the embed is used in.

This way you get to see the 'Meta Title' and 'Meta Description' text boxes while editing any cloned page. The inputted values then can be used in the page-view using a simple cms:show.
This is the standard approach.

Davor's problem was that he needed these fields for the list-view or home-view.
See it? The variables are not available in these views as they are associated with specific single pages.

A workaround in Couch for this problem (of values associated with list-views) is the use of a global template i.e. a separate template where we define regions for each template. This is shown in our tutorial also.

Hope that clarifies things :)

Thanks.
Thanks KK

Perfectly clarified, thank you very much for the insight

Regards
Said
Hi, stumbled across this post while trying to implement Content Tags through Couch CMS. Is this whats it relating to?
11 posts Page 1 of 2