Skip to content

ContentBuildRoute does not remove layout if link attached to menu item #141

@ryandemmer

Description

@ryandemmer

In components/com_content/router.php, the following condition (line 47) 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 removing 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;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions