Hello All,
Thought I'd share this little snippet / approach, now someone might have a more elegant solutions but for me this works fines and will be the standard approach I take.
Firstly, let me say the docs gave a great insight into globals.php usage, and KK's help let me clarify an approach.
Secondly, I do completely appreciated the clean admin panel that Couch offers, it lets you paint your own picture on it's blank canvas, and make things super easy for clients. Now, when I started tinkering with this I thought: Hey this would be a plugin in WP or other CMS', however reliance on plugins is a pain sometimes and I have utilised this approach, albeit more convoluted with EE before.
Down to the nitty gritty: I want to be able to give clients the ability to edit META information* for a page they publish (or that is already setup by me). Using the same "global" META (including titles) value in a site is not a great approach for the SEO conscious, however, and some may argue otherwise, I do believe there should be a default value. So, we achieve the default value in the globals by defining default Site title, Keywords and Description.
However, to simply allow more focussed SEO on a page we only need to use a little conditional magic in the header of the site.
The full code with some ropey annotations is below, basically we define the fallback / default META stuff in globals.php then use a simple conditional in there to check if the page.php has values in a defined editable regions, if so they get output instead of the defaults.
The premise is very simple, I don't claim to be a genius, and based on WordPress plugins like All In One SEO - except this is not a plugin and doesn't need to be, its far simpler and takes to seconds to setup if you copy my code snippets.
I hope it's of use to fellow users, any questions PM me and I will get back as soon as possible.
I'd like to add another layer to the conditional for things like News and Events so it does the following conditional logic:
1. Has META been defined in the page editable? - YES then Output, NO? Then move to 2
2. Well, we got some title of the page and probably a page content / body so lets just excerpt that, keywords will be a little harder unless we used a possible future feature like
Anyway the whole code:
*Some clients, without any SEO education, may hinder themselves by altering these values so when we see user access lock down on fields / editable regions these MEAT fields I would keep away from the client and give to a higher site admin access group.
Thought I'd share this little snippet / approach, now someone might have a more elegant solutions but for me this works fines and will be the standard approach I take.
Firstly, let me say the docs gave a great insight into globals.php usage, and KK's help let me clarify an approach.
Secondly, I do completely appreciated the clean admin panel that Couch offers, it lets you paint your own picture on it's blank canvas, and make things super easy for clients. Now, when I started tinkering with this I thought: Hey this would be a plugin in WP or other CMS', however reliance on plugins is a pain sometimes and I have utilised this approach, albeit more convoluted with EE before.
Down to the nitty gritty: I want to be able to give clients the ability to edit META information* for a page they publish (or that is already setup by me). Using the same "global" META (including titles) value in a site is not a great approach for the SEO conscious, however, and some may argue otherwise, I do believe there should be a default value. So, we achieve the default value in the globals by defining default Site title, Keywords and Description.
However, to simply allow more focussed SEO on a page we only need to use a little conditional magic in the header of the site.
The full code with some ropey annotations is below, basically we define the fallback / default META stuff in globals.php then use a simple conditional in there to check if the page.php has values in a defined editable regions, if so they get output instead of the defaults.
The premise is very simple, I don't claim to be a genius, and based on WordPress plugins like All In One SEO - except this is not a plugin and doesn't need to be, its far simpler and takes to seconds to setup if you copy my code snippets.
I hope it's of use to fellow users, any questions PM me and I will get back as soon as possible.
I'd like to add another layer to the conditional for things like News and Events so it does the following conditional logic:
1. Has META been defined in the page editable? - YES then Output, NO? Then move to 2
2. Well, we got some title of the page and probably a page content / body so lets just excerpt that, keywords will be a little harder unless we used a possible future feature like
- Code: Select all
<cms:show page_tags />
Anyway the whole code:
- Code: Select all
//GLOBALS for the fall back SEO META values
// globals.php where we define core SEO stuff
<cms:editable name='base_seo' label='Base SEO' desc='Set the default SEO Meta Data' type='group' order='99' />
<cms:editable name='meta_title' label='Meta Title' type='text' group='base_seo' />
<cms:editable name='company_name' label='Company Name' type='text' group='base_seo' />
<cms:editable name='meta_keywords' label='Meta Keywords - 7-8 max comma separated' type='text' group='base_seo' />
<cms:editable name='meta_description' label='Meta Description - 180 words max' type='textarea' group='base_seo' />
//PAGE TEMPLATE DECLARATION for the primary SEO override
// Assumes your template is pages.php for menu maker
// Also use in any clonable or nested pages
<cms:template clonable='1' nested_pages='1' title='Pages'>
<cms:editable name='page' label='Page SEO' desc='Override the default SEO Meta Data' type='group' order='99' />
<cms:editable name='meta_title' label='Meta Title' type='text' group='base_seo' />
<cms:editable name='meta_keywords' label='Meta Keywords - 7-8 max comma separated' type='text' group='base_seo' />
<cms:editable name='meta_description' label='Meta Description - 180 words max' type='textarea' group='base_seo' />
</cms:template>
//HEADER META used in the header.ext
// Assumes you are embedding your header in templates and it is called header.inc - i.e. domainroot/couch/snippets/header.inc
// change the filename.extension to suit your needs
// If your globals.php is named differently please change reference to it below
//WHITE SPACE VERSION
<title>
<cms:get_custom_field 'company_name' masterpage='globals.php' />
<cms:if meta_title !=''> | <cms:show meta_title /><cms:else />
| <cms:get_custom_field 'meta_title' masterpage='globals.php' /></cms:if>
</title>
<meta name="keywords" content="
<cms:if meta_keywords !=''><cms:show meta_keywords />
<cms:else />
<cms:get_custom_field 'meta_keywords' masterpage='globals.php' />
</cms:if>
">
<meta name="description" content="
<cms:if meta_description !=''><cms:show meta_description />
<cms:else />
<cms:get_custom_field 'meta_description' masterpage='globals.php' />
</cms:if>">
//MINIFIED VERSION
<title><cms:get_custom_field 'company_name' masterpage='globals.php' /><cms:if meta_title !=''> | <cms:show meta_title /><cms:else /> | <cms:get_custom_field 'meta_title' masterpage='globals.php' /></cms:if></title>
<meta name="keywords" content="<cms:if meta_keywords !=''><cms:show meta_keywords /><cms:else /><cms:get_custom_field 'meta_keywords' masterpage='globals.php' /> </cms:if>">
<meta name="description" content="<cms:if meta_description !=''><cms:show meta_description /><cms:else /><cms:get_custom_field 'meta_description' masterpage='globals.php' /></cms:if>">
*Some clients, without any SEO education, may hinder themselves by altering these values so when we see user access lock down on fields / editable regions these MEAT fields I would keep away from the client and give to a higher site admin access group.