We all know that the <link rel="canonical" href="some url"/> tag is the way to tell the search engines the one true URL for a page. So, making sure its filled in is important.
CMSMS's built in templates have a tag like this in their head section:
Code: Select all
{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
News has an {$entry->canonical} variable in its detail view. And the default detail template has a line like: {assign var='canonical' value=$entry->canonical} to ensure that our 'canonical' value is set properly for use when the page template's head section is processed.
If a variable like this isn't available, you can easily create one, just by re-creating the URL. Sometimes you can use the {get_current_url} plugin provided by the CGExtensions module. However, if there is alot of ajax going on this may work the way you want it to. That's where the {module_action_link} plugin comes in. It is provided in the CGSimpleSmarty module.
Adding a line like:
{module_action_link module=CompanyDirectory action=details compid=$entry->id urlonly=1 assign=canonical} into your detail template will generate the pretty url necessary for the canonical view.
I encourage you to look at the help of the CGSimpleSmarty module to see all of the parameters for this, and the other smarty plugins.
Hint: some js for ajax:
var url = '{module_action_link module=CompanyDirectory action=details compid=5 urlonly=1 jsfriendly=1}&showtemplate=false';
$('#somediv').load(url);