Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi

I got another issue with the meta tags for blog posts.

The blog.php is a clonable template and thought I could do the meta tags the same way as the non clonable pages so in blog.php I added the following code
Code: Select all
<cms:editable name='page_section_header' label='Blog Articles Meta Tags' type='group' collapsed='1' order='3' />
    <cms:editable name='page_desc' type='text' label='Page Description' group='page_section_header' maxlength="180" desc='For SEO Please keep it 180 or less Characters' />
    <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' />


It's got the fields showing when I create a new blog post and can fill the fields in and I save it but on the blog post article, the meta tag fields are blank

In header.php I have the following code
Code: Select all
<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 />">


I thought if it works for the non clonable pages, it would work the same way for the clonable page
Hi,

Assuming you are using the <meta> tags in the context of a page_view, you can simply use the editable values as follows
Code: Select all
<meta name="description" content="<cms:show page_desc />">
<meta name="keywords" content="<cms:show page_keywords />">

Continuing for the sake of documentation, using <cms:get_custom_field> or <cms:get_field> in clonable pages would also need either the page_name or the page_id to be specified e.g.
Code: Select all
<meta name="description" content="<cms:get_custom_field 'page_desc' masterpage=k_template_name page=k_page_name />">
<meta name="keywords" content="<cms:get_custom_field 'page_keywords' masterpage=k_template_name id=k_page_id />">

This, however, in your case is an overkill as the code is running from the very page it needs the editable values from and hence we can directly use <cms:show>.

Hope this helps.
Hi KK

Thank you so much for the reply, appreciate it

Using the following code worked in my includes/header.php file
Code: Select all
<meta name="description" content="<cms:show page_desc />">
<meta name="keywords" content="<cms:show page_keywords />">
You are welcome :)
4 posts Page 1 of 1