? Success

User tests: Successful: Unsuccessful:

avatar hans2103
hans2103
22 Apr 2014
  • changing trigger from onAfterRoute to onContentBeforeDisplay (because I need content information for creation of Canonical URL)
  • add if-then-else statement for creation of proper Canonical URL for com_content view=article

Reason for this pull request is to solve the wrong Canonical URL for an article. Problem is that Google will index all provided canonical weblinks. You will end up with duplicate content.

examples with com_content and view = article
open an article in a category blog view and look at the created Canonical URL

add parameters to the URL and take a look at the created Canonical URL

add an extra subcategory in the URL and take a look at the created Canonical URL

remove a part of the URL and take a look at the created Canonical URL

avatar hans2103 hans2103 - open - 22 Apr 2014
avatar Bakual
Bakual - comment - 23 Apr 2014

This PR adds specific code for the com_content article view into the SEF plugin.
I don't think that's a good idea. The plugin should work the same for all extensions, not only for a single view.

avatar hans2103 hans2103 - change - 23 Apr 2014
Labels Added: ? ?
avatar hans2103
hans2103 - comment - 23 Apr 2014

for the moment there is no solution that works for all extensions.
but... people might be inspired with my specific solution and create a new pull request to remove the single view.
for the moment... this solution will prevent huge amount of duplicate content.

I would advice to merge this pull request solving a lot of potential SEO problems.

avatar Bakual
Bakual - comment - 23 Apr 2014

for the moment there is no solution that works for all extensions.

Your PR actually even removes the function from all other extensions since it changes the event to onContentBeforeDisplay which is only triggered by com_content.
If you want to go that route, you better do it in com_content directly instead of doing it in the generic SEF plugin.

avatar hans2103
hans2103 - comment - 23 Apr 2014

you're suggesting to create a new content plugin? Removing the existing canonical url and placing a new canonical url for content item.

Instead of a content plugin I placed it into a system plugin.
https://github.com/hans2103/plg_system_canonicalurl

avatar Bakual
Bakual - comment - 23 Apr 2014

you're suggesting to create a new content plugin?

No. I'm saying that with your PR, you only create canonical URLs for com_content since most other extensions don't trigger the onContentBeforeDisplay event.
But if it only works for com_content, then there is no point in doing it with a plugin. Just do it within com_content (for example in the view) directly.

Another point is that this event may be triggered multiple times during a pageload. The category and featured view will trigger it for each article, and mod_articles_news does trigger it as well. It will actually produce worse canonical URLs for those pages.
This event is just not suiteable for what you try to do. It's used in core to add the voting feature and page navigations to an article.

avatar hans2103
hans2103 - comment - 23 Apr 2014

All I want to do is create a proper Canonical URL for content.
If, as you mention as an example in your comment, it's better to move it into the view then it's even better to remove the entire trigger onAfterRoute from the sef system plugin.
Removal of the trigger is needed to prevent duplicate content. Might seem as a strange advice since the Canonical URL is meant to reduce the amount of duplicate content.

avatar betweenbrain
betweenbrain - comment - 23 Apr 2014

t's better to move it into the view then it's even better to remove the entire trigger onAfterRoute from the sef system plugin

Won't that potentially break SEF for all other extensions though?

avatar hans2103
hans2103 - comment - 23 Apr 2014

nope... creation of SEF Url will not break.
only thing what will happen is that no canonical url will be added to the < head >

I wrote this pull request since the current implementation of canonical url is not correct.
(see the examples in my pull request)
But... as Thomas states correctly... my implementation is neither perfect.
Perhaps the creation of a canonical URL shouldn't be in a plugin. Perhaps it should be in the view.
I'm not a programmer... I'm just trying to solve an issue with duplicate content.

avatar Bakual
Bakual - comment - 23 Apr 2014

It's indeed a bit strange place for the link creation as it's not directly related to the SEF URLs.
I guess it was added there because it is only needed if SEF is enabled and it was the easiest place to add so it works for all extensions.

Moving it to the components will break backward compatibility as it removes the canonical links for non-core extensions. That is not really an option and would also result in a lot of duplicate code in the views.

Best approach would probably be to make calls to the component helper or router and run a new method which creates the canonical URLs or so. And if the method doesn't exist fall abck to current code. I'm sure there are better ways to solve the issue :smiley:

avatar brianteeman brianteeman - change - 21 Aug 2014
The description was changed
Status New Pending
avatar nicksavov nicksavov - change - 21 Aug 2014
Labels Removed: ?
avatar Hackwar
Hackwar - comment - 8 Dec 2014

Sorry, but this PR wont work in any scenario. Closing it.

avatar Hackwar Hackwar - change - 8 Dec 2014
Status Pending Closed
avatar jissues-bot jissues-bot - close - 8 Dec 2014
avatar jissues-bot
jissues-bot - comment - 8 Dec 2014

Set to "closed" on behalf of @Hackwar by The JTracker Application at issues.joomla.org/joomla-cms/3491

avatar jissues-bot jissues-bot - change - 8 Dec 2014
Closed_Date 0000-00-00 00:00:00 2014-12-08 10:49:14

Add a Comment

Login with GitHub to post a comment