?
avatar joomlabeat
joomlabeat
22 May 2018

Steps to reproduce the issue

I noticed a minor issue in mod_articles_categories module, for the Categories URLs, because of the way ContentHelperRoute::getCategoryRoute handles the $layout from $jinput.
Not sure if this bug appears anywhere else where ContentHelperRoute::getCategoryRoute is called, but for the mod_articles_categories we get URLs like below in cycles, depending from where we view the categories and when there is no menu-item for those categories to define a layout.

index.php?option=com_content&view=category&id=12&layout=&Itemid=119
index.php?option=com_content&view=category&id=12=&Itemid=119

Notice that the layout param in the first occasion is just empty, which with SEF on it ends up to URLs like below:
/blog/nature/16-animals?layout=
/blog/nature/16-animals

To reproduce this, create an articles categories module for a category tree e.g. you have a blog category and subcategories. Create menu items for the parent categories and just let the children without menu items. Place the module in all pages (articles, featured items and even other component), so to make sure there isn't a $layout for the categories view defined.
Start clicking on your module's categories links from your various pages and you will notice the non-constant URLs.

Expected result

Categories URLs should be the same for the same categories.

Actual result

Categories URLs toggles as described above, depending on the $layout param.

System information (as much as possible)

Joomla 3.8.7

Additional comments

The issue appears to be in the way ContentHelperRoute::getCategoryRoute deals with the layout param from $jinput

/components/com_content/helpers line 82 - 88:

$jinput = JFactory::getApplication()->input;
			$layout = $jinput->get('layout');

			if ($layout !== '')
			{
				$link .= '&layout=' . $layout;
			}

At line 85, it does a strict comparison for $layout !== '' and if it's not, then it appends it to the URL. But this is not always the case, as I don't know about other cases, in those that I tested it out, $layout came back as null. So the $layout !== '' results to true.

I think that unless we are expecting a layout to equals to "0", we could go with:

if (!empty($layout))

avatar joomlabeat joomlabeat - open - 22 May 2018
avatar joomla-cms-bot joomla-cms-bot - change - 22 May 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 22 May 2018
avatar joomlabeat joomlabeat - change - 22 May 2018
The description was changed
avatar joomlabeat joomlabeat - edited - 22 May 2018
avatar joomlabeat joomlabeat - change - 22 May 2018
Title
ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs due
ContentHelperRoute::getCategoryRoute -> minor bug in categories URLs
avatar joomlabeat joomlabeat - edited - 22 May 2018
avatar joomlabeat
joomlabeat - comment - 22 May 2018

Also - not sure about this - but what about in the case of a missing $layout for a category to default to the categories/global params?

avatar infograf768
infograf768 - comment - 22 May 2018

I think we already have a PR for this, can't remember which one

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 May 2018
Status New Discussion
avatar joomla-cms-bot joomla-cms-bot - edited - 22 May 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 22 May 2018
Category com_content Router / SEF
avatar franz-wohlkoenig franz-wohlkoenig - change - 22 May 2018
Category com_content Router / SEF com_content com_modules Router / SEF
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 May 2018

closed as fixed by #20229

avatar franz-wohlkoenig franz-wohlkoenig - change - 22 May 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-05-22 09:33:46
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 22 May 2018
Closed_Date 2018-05-22 09:33:46 2018-05-22 09:33:47
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 22 May 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 22 May 2018
avatar infograf768
infograf768 - comment - 22 May 2018

Thanks folks... my memory is not what it was... ;)

avatar joomlabeat
joomlabeat - comment - 22 May 2018

I searched for this, but didn't find anything at first place. Now reading #20229
Have a good day!

Add a Comment

Login with GitHub to post a comment