User tests: Successful: Unsuccessful:
Use this pull request / core hack as a temporary fix until Hannes Papenberg (@Hackwar) publishes his new URL router.
With the current Joomla implementation it's possible to generate very stupid URLs from a category blog view.
When you create a menu item for a category blog view you can call another catogory with it's alias.
example
menu item for category blog view
https://www.byte.nl/nieuws/
an article in this view will be
https://www.byte.nl/nieuws/2799-lek-bash-shell-gedicht
another category might be Products
it's category ID is 78
thus the alias will be 78-products
therefor you can call the url
https://www.byte.nl/nieuws/78-products
and it will display all items from category Products as a category blog view in menu item Nieuws
I don't want Joomla to render such a stupid link.
Instead of waiting for @Hackwar I implemented this temporary solution.
It will raise an error 302 to /nieuws instead of a /404
For me that's okay since people and search engines cannot render the other page anymore.
Labels |
Added:
?
|
another category might be Products
it's category ID is 78
thus the alias will be 78-products
therefor you can call the url
https://www.byte.nl/nieuws/78-products
and it will display all items from category Products as a category blog view in menu item Nieuws
This URL is actually perfectly valid, correct and far from stupid.
Your PR breaks almost every link to a com_content category. You would have detected that if you tested it yourself with a standard Joomla installation using testing sample data.
Closing as this PR solves nothing and instead breaks almost everything.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-09-25 13:10:24 |
what do you mean with "almost everything"?
bear with me and try the following:
create CategoryA as root category. Category alias might be 12-categorya
create CategoryB as root category. Category alias might be 13-categoryb
create CategoryC as subcategory of CategoryB. Category alias might be 14-categoryc
add articles to both category A and C
create a menu item for a category blog view of CategoryA.
The weblink will be http://example.com/categorya
Open an article on this page... the url might be: http://example.com/categorya/42-article
Now type in the following URL: http://example.com/categorya/13-category/categoryc
You might notice that it will display a category blog view of all articles whithin CategoryC
When you apply the path it will check if you are trying to open a category inside a category blog view.
If so... it will break... and fall back to http://example.com/categorya
I know it's not perfect.. but... it's better that it will break then being indexed by the search engines. (which happens now)
Since we have nested categories, it's perfectly valid to have links pointing to a subcategory from the category view. So http://example.com/categorya/13-categoryc
is a valid and correct URL. categorya
is in this case the menu item which just happens to be a category view, but that doesn't matter much for the routing.
Take a look at the "testing" sample data and try to have a look at the "Archived Articles" or "Article Category List". You will see what I mean.
Every link which points to a category will be broken, except if said category has a menu item pointing directly to it.
If you look a moment at your code you will see why. On line 89 we have if ($view == 'category' || $view == 'article')
and on line 96 you're going to raise an error if the view is a category view. Raising an error makes no sense anyway. The user didn't do anything wrong, he just visits a page
FILE: /home/travis/build/joomla/joomla-cms/components/com_content/router.php
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
102 | ERROR | Whitespace found at end of line