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

I am trying to add meta tags into a website that is using couchcms but when I added them, it messed up the layout, it was like it could not get the css styling from the stylesheet, can anyone post the correct way to add meta tags to a web page using couchcms please so they can added, edited from the couchcms admin side

the pages are using clonable template pages

below is what I had in my header.php file

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 />


below is what I had in my index.php file

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="180" desc='For SEO Please keep it 180 or less Characters'>Please enter the page title here</cms:editable>
<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'>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>

<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>" />


Thank you in advance

Ian
<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 />" />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Thank you for the reply, appreciate it

was going to say just sorted it about a minute before your reply but thank you for replying
You are welcome!

<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>

This part is effectively the same as this shortened code:
Code: Select all
<title><cms:if k_is_list ><cms:get_custom_field 'page_title' masterpage=k_template_name />
<cms:else />
<cms:show page_title /></cms:if></title>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
got a little issue, most of the pages are clonable but I have two that are not clonable and I can't get the meta tags added to the non clonable page, the meta description and keywords fields are showing in the admin couchcms side but they don't get added to the front end when viewing the source, is there a way it can work?

I have a header.php file and the non clonable page is photobooths.php

I got the following in the photobooths.php file

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>
Please post the 'showing' part of your editables. You got them defined well, now post the code how you show'em. In my view, it should match something similar:
Code: Select all
<title><cms:if page_title ><cms:show page_title /><cms:else /><cms:show k_template_title /> | This is a default title</cms:if></title>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I did it this way but is not ideal as am thinking the search engines cannot pick up the meta tags, in my header.php file, I have the following

Code: Select all
<title><?php echo $title; ?></title>

<meta name="description" content="<?php echo $pgDesc ?>">

<meta name="keywords" content="<?php echo $pgKeywords ?>">

<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>" />


is not ideal as the clonable pages show the hard coded meta tags as being empty but then further down the coding on view source, the meta tags are filled with what is entered in the couchcms admin side

in the non clonable page, I have the following

Code: Select all
<?php require_once( 'cms/cms.php' ); ?>

<cms:template title='Photobooths'>

</cms:template>

<?php

$title = "Photobooth Hire Essex - Sweetz and Treatz";

$pgDesc="make your event a memorable day with our photobooths available for hire in Essex";

$pgKeywords="photobooth hire essex, photobooth event hire essex";

include ( 'includes/header.php' );
?>
sorted it, I created a second header.php file called header-2.php and called that from the photobooths.php file
ianhaney50 wrote: I did it this way but is not ideal as am thinking the search engines cannot pick up the meta tags, in my header.php file, I have the following

Code: Select all
<title><?php echo $title; ?></title>

<meta name="description" content="<?php echo $pgDesc ?>">

<meta name="keywords" content="<?php echo $pgKeywords ?>">

<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>" />


is not ideal as the clonable pages show the hard coded meta tags as being empty but then further down the coding on view source, the meta tags are filled with what is entered in the couchcms admin side

in the non clonable page, I have the following

Code: Select all
<?php require_once( 'cms/cms.php' ); ?>

<cms:template title='Photobooths'>

</cms:template>

<?php

$title = "Photobooth Hire Essex - Sweetz and Treatz";

$pgDesc="make your event a memorable day with our photobooths available for hire in Essex";

$pgKeywords="photobooth hire essex, photobooth event hire essex";

include ( 'includes/header.php' );
?>


Ok, the first problem is the raw PHP is wrong. It's procedural so the variables have to be defined BEFORE they are outputted. The way your code currently runs is the page outputs the tags and THEN assigns values to the variables, so the output tags are always empty.

Secondly, Couch version looks incredibly messy, hurting my head to look at for too long haha. But it looks like that part works (as you said). As for "non-clonable" tag - after looking more at your output, Your if-statements have <cms:if k_is_list> which WOULD output the correct value for the list-view, but later on in the statement you have <cms:if k_is_home> (Which is the SAME as k_is_list, so it gets replaced with the value output in there.

I'll do the title tag as an example:
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>


The above is your original code tidied up and neatened.
The below is the fixed version, notice removal of k_is_list (I could have kept it similar to your original code just changing k_is_list to k_is_home and removing the k_is_home at the bottom, but this *should* work better, in my opinion. This is similar to the code for views displayed on the tutorial page, found here.

Code: Select all
<title>
    <cms:if k_is_page >
        <cms:show page_title />
    <cms:else />
        <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:get_custom_field 'page_title' masterpage=k_template_name />
        </cms:if>
    </cms:if>
</title>


The above code pretty much looks for a page, if it's not a cloned page it then looks if the view is a folder, then an archive and finally (if it's none of the above it will be a list-view, but we only want to show that if its not archive or folder, so we wrap it with <cms:if k_is_home> to remove the output from other views), a list.

Hope this helps.
Image
Thank you will try that
12 posts Page 1 of 2