News : Use SLUG prevent use of specified detail template

Forum rules
Only administrators can post or move items here.
pierrepercee
Forum Members
Forum Members
Posts: 143
Joined: Thu Jan 10, 2013 8:02 am

News : Use SLUG prevent use of specified detail template

Post by pierrepercee »

When you add SLUG (often for SEO purpose) to a News, the news template details called in your template is ignored for the by default template.

Anymore, Canonical URL doesn't take care about the specified template details called in your template. It use the by default template details-

But if you don't use SLUG :
Real Url generated (click on "More" on front-end to read the entire news):

Code: Select all

http://localhost/rc1/news/1/24/News-Module-Installed/d,simpletest.html
Canonical URL generated (just the news page...) :

Code: Select all

 <link rel='canonical' href='http://localhost/rc1/default-extensions/modules/news.html' />
I remember this topic
pierrepercee
Forum Members
Forum Members
Posts: 143
Joined: Thu Jan 10, 2013 8:02 am

Re: News : Use SLUG prevent use of specified detail templat

Post by pierrepercee »

For end customers, those who buy sites, this problem is hardly visible. Yet this inevitably leads to significant shortfalls for the affected sites.
The url rewriting and management of canonical url are, in my view, very important for SEO ... I know that developers do a lot of work, all for free, but I think this problem should be solved for 1.12 and 2.0 version. Simple to say...I know this. I do my best to point out the important points.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: News : Use SLUG prevent use of specified detail templat

Post by velden »

I'm not sure what exactly the problem is. You can/should set the canonical url yourself from the News detail template. You posted this yourself in http://forum.cmsmadesimple.org/viewtopi ... 43#p317843

Further, perhaps this information is useful to know:

CGExtension module has some extra functionality (from help):
{cge_module_hint module=string ...}

This function plugin can be used to provide hints for module behavior if various parameters cannot be specified on the URL. I.e: In a situation when a site is configured to use pretty urls for SEO purposes it is often impossible to provide additional module parameters like a detailtemplate or sort order on a URL. This plugin can be used in page templates, GCBs or in a page specific way to give hints as to how modules should behave.

Note: Any parameters that are specified on the URL will override matching module hints. i.e: When using News and a detailtemplate parameter is specified on a News detail url, any detailtemplate hints will have no effect.

Note: In order to ensure proper behavior, module hints must be created before the {content} tag is executed in the CMSMS page template. Therefore they should (normally) be created very early in the page template process. An ideal location for page specifc hints is in the "Smarty data or logic that is specific to this page:" textarea on the editcontent form.
Example:

When using the CGBlog module, and pretty urls. You wish to display blog articles for a specific category on one page, and would like to use a non standard detail template to display the individual articles on a differernt page. I.e: perhaps on your "Sports" page you are calling CGBlog like: {CGBlog category=sports detailpage=sports_detail}. However, using pretty urls it is impossible to specify a detailtemplate on the links that will generate the detail views. The solution is to use the {cge_module_hint} tag on the sports_detail page to provide some hints as to how CGBlog should behave on that page.

When editing the sports_detail page on the options tab, in the textarea entitled "Smarty data or logic that is specific to this page:" you could enter a tag such as: {cge_module_hint module=CGBlog detailtemplate=sports}. Now when a user clicks on a link from the CGBlog display on your "sports" page he will be directed to the sports_detail page, and the CGBlog detail template entitled "sports" will be used to display the article.

It is possible to specify multiple parameter hints to a single module in one call to this plugin.
It is possible to call this module multiple times in a request to provide hints to different modules.

Usage:

{cge_module_hint module=CGBlog summarytemplate=something detailpage=home}
{cge_module_hint module=CGSmartImage noembed=1}
pierrepercee
Forum Members
Forum Members
Posts: 143
Joined: Thu Jan 10, 2013 8:02 am

Re: News : Use SLUG prevent use of specified detail templat

Post by pierrepercee »

for the next version (2.0), the problem seems to me clearly stated. You can do the test locally. The use of a specific module (CG Extension) is a stopgap.
Many integrators have not identified this problem and do not know this solution. I can provide you with mp sites url's where the problem arises (in 1.12)
This must be managed natively for each module concerned.
Clearly the generation of the canonical url must integrate all the parameters specific to the page. Choosing a template detailed in part, obviously.
If it is possible to examine this, it is in the class.news_article.php file

[removed by moderator]
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: News : Use SLUG prevent use of specified detail templat

Post by calguy1000 »

The problem is: You cannot have a pretty URL AND pass all of the parameters that are possible from a summary view to a detail view on the URL. The two requirements conflict with each other.

CMSMS 2.0 has added the {cms_module_hint} tag to work around the problem in most (but not all) cases.

i.e: even with cms_module_hint you still cannot do some things like have a slug URL and specify a different detail page or detail template per news category if the summary view is displaying all categories.
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.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: News : Use SLUG prevent use of specified detail templat

Post by Jeff »

pierrepercee wrote:Many integrators have not identified this problem and do not know this solution.
That isn't a problem with CMSms, that is a problem with people thinking they can do something they are not qualified to do and/or are unwilling to learn the software they are using.
pierrepercee
Forum Members
Forum Members
Posts: 143
Joined: Thu Jan 10, 2013 8:02 am

Re: News : Use SLUG prevent use of specified detail templat

Post by pierrepercee »

@Jeff

To go from London to Paris you can of course go through Moscow, but everyone does not want to. Argue incompetence of integrators as it is clearly a weakness of CMSMS is a point of view. Perhaps you allow me not to share it.

@Calguy
On the front-end pretty urls work perfectly and pass the detail template as a parametter without a problem. Only the canonical url collected problem.
I naively thought that what had been implemented in pretty urls could be in the canonical url management mechanism. I had to make mistake ...
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: News : Use SLUG prevent use of specified detail templat

Post by calguy1000 »

We will not be changing this.

in fact... we should be removing the /d,detailltemplatename stuff too. That never should've been done, but there was no better solution at the time. However, we'll save that for a later version.
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.
archeo
Forum Members
Forum Members
Posts: 107
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: News : Use SLUG prevent use of specified detail templat

Post by archeo »

On the French forum there are few people who know about this problem since few of us use different detail templates (http://www.cmsmadesimple.fr/forum/viewt ... d=5737&p=1.

A solution could be to modify the canonical url in class.news_article.php, private function _get_canonical()
replacing

Code: Select all

[removed by moderator]
by

Code: Select all

$canonical = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
An other solution : using a default templace that select the good detail template in function of news category.

Code: Select all

<!-- Start News Display Template -sélectionne detailpage et detail template en fonction de la catégorie, le dernier article est affiché avec titre image et résumé les autres seulement avec le résumé ->
{$num_article=0}
{$num_article}
{$pagecount}
{if $pagecount > 1}
  <p  style="text-align : center;  margin-bottom : 2px; padding-bottom: 5px; border-bottom : 2px solid #ccc;">
{if $pagenumber > 1}
{$firstpage}&nbsp;&nbsp;{$prevpage}&nbsp;
{/if}
{$pagetext}&nbsp;{$pagenumber}&nbsp;{$oftext}&nbsp;{$pagecount}
{if $pagenumber < $pagecount}
&nbsp;{$nextpage}&nbsp;&nbsp;{$lastpage}
{/if}
</p>
{/if}


{foreach from=$items item=entry}

{* on modifie detailpage en fonction de la catégorie de l'article en paramétrant news*}
{$detail_page="nouvelle"}
{$gabarit_det="actualites"}

{if $entry->category == 'Travaux en cours'}
{$detail_page="travaux-en-cours-detail"}
{$gabarit_det="travaux"}

{elseif $entry->category == 'Techniques 3D'}
{$detail_page="travaux-en-cours-detail"}
{$gabarit_det="travaux"}

{elseif $entry->category == 'actualités'}
{$detail_page="actualite"}
{$gabarit_det="actualites"}

{elseif $entry->category == 'Mise à jour du site'}
{$detail_page="actualite"}
{$gabarit_det="actualites"}

{elseif $entry->category == 'Pédagogie'}
{$detail_page="pedagogie-2"}
{$gabarit_det="travaux"}

{elseif $entry->category == 'musées'}
{$detail_page="musees-details"}
{$gabarit_det="musees"}

{/if}

{if $num_article==0}

{news idlist="{$entry->id}"  summarytemplate="actualites_mini_pop"    detailtemplate="$gabarit_det" detailpage="$detail_page"}
{else}
{news idlist="{$entry->id}"  summarytemplate="actualites_mini_pop_ss_image"    detailtemplate="$gabarit_det" detailpage="$detail_page"}
{/if}

{$num_article=$num_article+1}

{/foreach}

{* fin de la modification *}
<!-- End News Display Template -->
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1921
Joined: Mon Jan 29, 2007 4:47 pm

Re: News : Use SLUG prevent use of specified detail templat

Post by Jo Morg »

archeo wrote:A solution could be to modify the canonical url (...) by

Code: Select all

$canonical = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
This IS NOT a solution* for the canonical urls as in doesn't specify one single url for the current content and will be dismissed by search engines:
googlewebmastercentral - 5 common mistakes with rel=canonical wrote:Specify no more than one rel=canonical for a page. When more than one is specified, all rel=canonicals will be ignored.
See 5 common mistakes with rel=canonical.

Although there may be issues with the generation of the canonical urls in News (because of an feature that shouldn't exist in the module to begin with, see Calguy 2nd reply) the current discussion and that old topic revolve around a misconception of what canonical URLs really are, and their use (at least imo).

Suggested reading:
pierrepercee wrote:The url rewriting and management of canonical url are, in my view, very important for SEO
It's misuse is... being even recommended that better than using it wrongly is not using it at all if you are not sure it is correctly implemented... Just read the links above.
pierrepercee wrote:This must be managed natively for each module concerned.
That is partially true... the generation of the correct canonical URL should be a feature in some modules, but:
calguy1000 wrote:The problem is: You cannot have a pretty URL AND pass all of the parameters that are possible from a summary view to a detail view on the URL. The two requirements conflict with each other.

CMSMS 2.0 has added the {cms_module_hint} tag to work around the problem in most (but not all) cases.
The solution is not a simple one and even other CMS's and applications scripts either have poor solutions for this or none at all from what I could read on some articles. IMO News has a decent, if not perfect, solution.
*P.S.: actually this may have an extremely negative impact on SEO according to the articles from the links I posted.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1921
Joined: Mon Jan 29, 2007 4:47 pm

Re: News : Use SLUG prevent use of specified detail templat

Post by Jo Morg »

On another note:
archeo wrote:An other solution : using a default templace that select the good detail template in function of news category.
This seems a far better solution for this issue IMnsHO. :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: News : Use SLUG prevent use of specified detail templat

Post by calguy1000 »

I read through (most of) the thread on the French forum and this is because you want to use different news detail templates (and potentially different News detail pages) for different categories of News.

Well, I need to tell you that:
a: This question has been asked and answered many times on our forum, it does not only apply to News but to almost every other module that supports summary/detail views.
b: There is no bug. News is not built out of the box to handle this.

Here is why it is not a bug:
- The News module is capable of displaying a summary of news articles in many ways (different categories, page limits, sort orders, by author, etc.).
- When creating a summary view you can specify a detailpage parameter to use for all links to individual articles coming from that summary view. (does not apply when using SLUG's).
- When using News SLUG's you must specify a single detail page. There is a preference in the news module for this. This is because there is no detail page value on the URL itself to parse out.
- The module allows you to specify (per summary call) that detail links from this summary view should be dispayed on this page. This applies when NOT using slugs. The url is like "news/<pageid>/<articleid>/title-text"
- The module allows you to specify (per summary call) the detail template to use for all detail views coming from this summary view. This applies when NOT using slugs.
- You can create multiple different summary views on different pages (or even the same page). There is a great deal of flexibility in the module. But you can't have everything...... You can't have flexibility AND a single canonical URL for an article.
- If slugs are NOT used {news detailpage=home}{news detailpage=about} would generate two different canonical URL's for the same article (because you specified the detailpage parameter differently)... it is your responsibility to manage this.
i.e: if you dont' care about SEO, you could use {news category=foo detailpage=childcat}{news category=parentcat detailpage=bar}. Which would give you two different detail pages (and therefore potentially two different page templates) depending upon the category.

When not using slugs: This URL: News/22/55/some-news-article.html/d,footemplate
and This URL: News/22/55/some-news-article.html and this URL:
News/25/55/foo-bar.html all point to the same article (55) and therefore will result in duplicate content issues with google. because they are displaying the same data.
The first URL is just a different type of ugly URL than the normal ?cntnt01detailtemplate=footemplate stuff.

You can test this out... even when using slugs. You need to know the ID of any visible content page, AND the id of a valid news article then enter a URL Like <site>/News/<pageid>/<articleid>/some-junk.html it'll work. And you can change the page id or the "some-junk" stuff all you want. When a slug is entered for that article (and you haven't made any other changes). The canonical URL will use the slug.

The 'detailtemplate' parameter (in the summary view) is perhaps our biggest mistake. Although it certainly may have correct uses (can't think of any right now); for what you want, it is not the proper thing to use. If you want a custom display of some data based on the data itself (author, category, dates, depending on whether it has images or not, or the value of some custom field, etc) then the best place to make those decisions is in the detail template itself. Just put logic into your detail template.

Most of us would never think of putting logic in a summary template that says 'if the article author is 'fred' use a different detail template. We would put that display logic into the detail view itself. Then why would we do it for categories. It is best left to the detail view.

i.e:

{if $news_category == 'foo'} .... {else} ... {/if} {* pseudocode *}

is exactly the same type of decision as:

{if $news_image != ''} <!-- display image on left, summary on right --> {else} <!-- display summary across whole row --> {/if} {* pseudocode *}

or

{if $news_author == 'fred'}<!-- this guy is special, display a start with his profile -->{/if}

You can also use smarty logic and the {include} tag to include other templates so that your primary logic occurs in one template, and a nice... clean template does the display. i.e: something like:

{* My default News detail template *}
{if $news_category == 'foo'}
{include file='module_db_tpl:News;foo_category_detail'}
{else}
{include file='module_db_tpl:News;standard_detail'}
{/if}

Woot! I think I've just convinced myself to drop the whole detailtemplate parameter stuff from the summary view in News for CMSMS 2.1 :)
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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: News : Use SLUG prevent use of specified detail templat

Post by calguy1000 »

Just as a followup... we have been looking through the code and discussing this, and came up with one good explanation for the way the URL's work specifically related to the News module (but my other modules copy this methodology)

a: There are multiple ways to display a news article, and the same news article can be displayed on different pages with different detail templates.... and therefore you CAN access the same news article via multiple different URL's.

b: For SEO purposes there can only be ONE canonical URL for an article.
For News this is determined by:
i: The slug (if it is set). You must specify the 'default page for detail views' in the News module settings.
ii: If the slug is not set then the 'default page for detail views' is used or the default page id. The detailtemplate parameter or any other parameter is NOT included on the URL.

c: If not using pretty URL's... then we assume that SEO is not a priority (maybe it's an intranet or members only site) and we just 'fake' a canonical URL using whatever parameters were passed to the module action.

So, therefore... if you want to display articles differently, based on some criteria, AND SEO is important to you, then put the logic into your detail template.

Putting the logic into the detail template is the better way from a logical point of view anyways.
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.
archeo
Forum Members
Forum Members
Posts: 107
Joined: Tue Oct 21, 2014 12:47 pm
Location: Lorient (France)

Re: News : Use SLUG prevent use of specified detail templat

Post by archeo »

Thank you very much to Jo and Calguy for their very detailed answers.
Probably a stupid suggestion , using an url like :
news/<pageid>/<articleid>/<detailtemplateid>/title-text if the parameter detailtemplate is use.
pierrepercee
Forum Members
Forum Members
Posts: 143
Joined: Thu Jan 10, 2013 8:02 am

Re: News : Use SLUG prevent use of specified detail templat

Post by pierrepercee »

Hello Calguy and thank you for these welcome clarification.
We can of course offer the same news with different retail templates on different pages.
This obviously raises if one gets the template detail in a canonical url SEO problem. It is right but I think it is very far from being the most frequent case (to be quite honest I think it more to do with a particular purpose)
In most cases different news belonging to different categories are offered on different pages. The problem of a single URL to a single content not then arise.
For against, when not used slugs, Google obviously shows the canonical URL using the default template detail. The result is obvious: users who are looking for information via Google will fall on poorly formatted pages.
I have no ideal solution to offer and I know this is not simple.
At least I think it is important to accurately document this aspect to that in the absence of a native management, integrators are not trapped.
Locked

Return to “Closed Issues”