joomla/joomla-cms — Issue #141: ContentBuildRoute does not remove layout if link attached to menu item
Author: ryandemmer
Created: 2012-02-28 14:12:30+00:00
State: open

In components/com_content/router.php, the following condition does not remove the layout from the query :

// are we dealing with an article or category that is attached to a menu item?
if (($menuItem instanceof stdClass) && $menuItem->query['view'] == $query['view'] && isset($query['id']) && $menuItem->query['id'] == intval($query['id'])) {
unset($query['view']);

if (isset($query['catid'])) {
unset($query['catid']);
}

unset($query['id']);

return $segments;
}

this may result in links like index.php/extensions?layout=blog, where the original link was something like index.php?option=com_content&view=category&layout=blog&id=20&Itemid=527

Easily fixed by unsetting the layout from the $query, eg:

// are we dealing with an article or category that is attached to a menu item?
if (($menuItem instanceof stdClass) && $menuItem->query['view'] == $query['view'] && isset($query['id']) && $menuItem->query['id'] == intval($query['id'])) {
unset($query['view']);

if (isset($query['catid'])) {
unset($query['catid']);
}
if (isset($query['layout'])) {
unset($query['layout']);
}
unset($query['id']);

return $segments;
}