SEOTools2 with detail pages
Posted: Fri Jun 15, 2012 10:57 am
SEOTools2 is designed to output keywords and meta descriptions for entire pages. That doesn't quite work when you have a detail page, eg News, CGBlog, Products etc.
You can replace the standard page meta by following a few simple steps.
For each of the modules that have detail pages, create two custom fields. Call them what you will so long as they are the same across all the modules, eg 'detail_keywords' and 'metadescription'.
At the end of your detail template, put:
Or whatever the semantics are for retrieving the custom field value for the module.
This makes those vars available to the entire page, not just the individual modules.
Next, at the bottom of your page template, enter:
This will retain the detail page's metadescription rather than replacing it with the page's metadescription. The var name must match the name of the content_block you've nominated as the content block for the meta description in SEOTools2.
Next, in SEOTools2, wherever you have the {keywords} tag, say:
In other words, replace the page keywords with the detail page keywords.
Although they only appear as single line fields, the SEOTools2 page title and meta title fields have full Smarty template processing capabilities.
Of course this will only work when the config process_whole_template is set to false. The body html must be processed before the head stuff.
Have fun with this,
psy
You can replace the standard page meta by following a few simple steps.
For each of the modules that have detail pages, create two custom fields. Call them what you will so long as they are the same across all the modules, eg 'detail_keywords' and 'metadescription'.
At the end of your detail template, put:
Code: Select all
{assign var=metadescription value=$entry->fields.metadescription->value}
{assign var=detail_keywords value=$entry->fields.detail_keywords->value
This makes those vars available to the entire page, not just the individual modules.
Next, at the bottom of your page template, enter:
Code: Select all
{if !isset($metadescription)}{content block='metadescription' label='Page description for SEO' oneline='true'}{/if}
Next, in SEOTools2, wherever you have the {keywords} tag, say:
Code: Select all
{if isset($detail_keywords)}{$detail_keywords}{else}{keywords}{/if}
Although they only appear as single line fields, the SEOTools2 page title and meta title fields have full Smarty template processing capabilities.
Of course this will only work when the config process_whole_template is set to false. The body html must be processed before the head stuff.
Have fun with this,
psy