LISE and canonical URL in detail template Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

LISE and canonical URL in detail template

Post by webform »

I can't seem to figure out how i set the canonical url for the LISE detail template.

I'm using this in my LISE detail template:

Code: Select all

{assign var='canonical' value="{root_url}/{$item->url}" scope=global}
and the variable is outputting the correct url but the canonical url from {metadata} is unchanged.

Am i forgetting something?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1619
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE and canonical URL in detail template

Post by DIGI3 »

It's usually an order of operations thing. Do you have anything in your config.php such as startup_mact_processing set?
Not getting the answer you need? CMSMS support options
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE and canonical URL in detail template

Post by webform »

Good thought. But i only have default config except "permissive_smarty" enabled.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1619
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE and canonical URL in detail template

Post by DIGI3 »

You'll need to do a bit of troubleshooting then, output the variable in various parts of your template and see where it's getting set, and where it's changing. Do an admin search for 'canonical', and check all templates to make sure it's not being reset somewhere else later.
Perhaps also share your metadata entries, and a url if possible. I'm also going under the assumption you're on the latest version, but advise if that's not the case.
Not getting the answer you need? CMSMS support options
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE and canonical URL in detail template

Post by webform »

Yes, i'm using latest version (CMS MS 2.2.16).

I don't have the variable nowhere but in my LISE detail template and the default News default template.

I've created a page with the default News template and the page also doesn't display the canonical url for the news item, but only the url for the page url.

I've inserted the variable {$canonical} in all 3 zones in the base template and the canonical url outputs correctly. It's only the rel="canonical" from {metadata} that is ignoring the set variable in the module detail template.

If i'm using the old {CGHeadMaster} module i can override default canonical url from {metadata}

Code: Select all

{cghm_config_set key='canonical' val=$canonical|default:''}
but who knows how long that solution will work.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1619
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE and canonical URL in detail template

Post by DIGI3 »

I would just add the meta to your page template instead of in the {metadata} section in admin then. It's possible that gets processed first, I haven't tested. Just add the line right before/after you call {metadata}.
Not getting the answer you need? CMSMS support options
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE and canonical URL in detail template

Post by webform »

It's not the metadata section in admin but the {metadata} tag in the page template that outputs the rel="canonical" tag, there is ignoring the set canonical variable in the LISE and NEWS detail template.

Only with {CGHeadMaster} and {cghm_config_set key='canonical' val=$canonical|default:''} it seems the {metadata} tag is accepting the canonical url of the LISE and NEWS module.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1619
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE and canonical URL in detail template

Post by DIGI3 »

The {metadata} tag just outputs what's in the admin metadata section. Because this is (likely) processed before the module tag, it can't know it's been set elsewhere. Cut the line from that section and put it in your template. I usually put something like this in the head of my template:

Code: Select all

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
as the <head> section is processed after modules, it will have access to variables set in modules with scope=global.

I'm not familiar with the CG module but as it's been abandoned by its author I wouldn't suggest using it.
Not getting the answer you need? CMSMS support options
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE and canonical URL in detail template

Post by webform »

I don't have that content in my metadata section in admin only

Code: Select all

<meta name="Generator" content="CMS Made Simple - Copyright (C) 2004-2018. All rights reserved." />
So i assumed the rel="canonical" came default from the {metadata} tag in the template.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1619
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE and canonical URL in detail template

Post by DIGI3 »

Nope, it only sets what's in the admin section for it, plus it adds a <base> tag unless told not to. Your canonical tag must be in a template or module somewhere (perhaps CGHM sets one by default?)
Not getting the answer you need? CMSMS support options
webform
Power Poster
Power Poster
Posts: 458
Joined: Sat Nov 25, 2006 3:39 pm
Location: Copenhagen, Denmark

Re: LISE and canonical URL in detail template

Post by webform »

I think your right!

It must be CGHeadMaster that set canonical tag by default and i must just have forgotten i've removed the tag from the metadata section back then i've created the site a couple of years ago. :-[

Thanks for your time and patience.
Post Reply

Return to “Modules/Add-Ons”