Page 1 of 1

[solved] Canonical URL on Products detail page

Posted: Fri Oct 04, 2013 3:09 pm
by paulbaker
Hi :D

I have an installation of Products on CMSMS 1.11.7 using pretty URLs. I call it with:

Code: Select all

{Products sortby="f:sortby"}
so it lists all Products on a page like "http://www.example.com/portfolio

I have the usual canonical call in the HEAD of the page template:

Code: Select all

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
So this produces the canonical link "http://www.example.com/portfolio on the main Products list page. So far so good.

When I click a Product to see more details it uses the same page template and goes to a URL like "http://www.example.com/portfolio/3/24/Nice-Product-Name

But the canonical URL in the HEAD remains as "http://www.example.com/portfolio

How can I change the canonical URL in the HEAD to match the real pretty URL of "http://www.example.com/portfolio/3/24/Nice-Product-Name ???

Thanks!

Re: Canonical URL on Products detail page

Posted: Fri Oct 04, 2013 3:54 pm
by calguy1000
Try this in your detail template:

{$canonical=$entry->detail_url}

Re: Canonical URL on Products detail page

Posted: Fri Oct 04, 2013 4:06 pm
by paulbaker
Perfect :P

Thanks Calguy O0