Canonical Link for CG Calendar Event detail pages

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JohnnyB
Dev Team Member
Dev Team Member
Posts: 729
Joined: Tue Nov 21, 2006 5:05 pm
Location: OH, USA

Canonical Link for CG Calendar Event detail pages

Post by JohnnyB »

To generate an event's canonical link add this to the top of your Event Display (Detail) template:

Code: Select all

{capture name='cann' assign='canonical'}{$gCms->config.root_url}/{$smarty.get.page}{/capture}
{assign var='canonical' value=$canonical}
Be sure to include the canonical link in your template:

Code: Select all

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Canonical Link for CG Calendar Event detail pages

Post by carasmo »

Thanks for this! I can get the last part of the url, but the root url (to the site) does not show up. What's the update for this for v. 1.10 and up?

Thanks again!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Canonical Link for CG Calendar Event detail pages

Post by calguy1000 »

{root_url}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Canonical Link for CG Calendar Event detail pages

Post by carasmo »

Yeah, I'm having a flash of stupid right now ;-)

Code: Select all

{* set a canonical variable that can be used in the head section if process_whole_template is false in the config.php *}
{capture name='cann' assign='canonical'}
{root_url}/{$smarty.get.page}{/capture}
{assign var='canonical' value=$canonical}
Post Reply

Return to “Tips and Tricks”