Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing: No-Itemid-behavior for components #5599

wants to merge 55 commits into from


Copy link

@Hackwar Hackwar commented Jan 3, 2015

This PR implements a rule for URLs with missing Itemid as a generic rule for all component routers that extend from JComponentRouterView.

How to test

  • Apply this change
  • Change the router of com_content by replacing
class ContentRouter extends JComponentRouterBase


class ContentRouter extends JComponentRouterView
    function __construct($app = null, $menu = null) {

        $categories = new JComponentRouterViewconfiguration('categories');
        $category = new JComponentRouterViewconfiguration('category');
        $category->setKey('id')->setParent($categories, 'id')->setNestable()->addLayout('blog');
        $article = new JComponentRouterViewconfiguration('article');
        $article->setKey('id')->setParent($category, 'catid');
        $this->registerView(new JComponentRouterViewconfiguration('archive'));
        $this->registerView(new JComponentRouterViewconfiguration('featured'));
    $this->registerView(new JComponentRouterViewconfiguration('form'));

        parent::__construct($app, $menu);
        $this->attachRule(new JComponentRouterRulesMenu($this));
        $this->attachRule(new JComponentRouterRulesNomenu($this));

    public function getCategorySegment($id, $query)
        $category = JCategories::getInstance($this->getName())->get($id);
        if ($category)
            return array_reverse($category->getPath());

        return array();

    public function getCategoriesSegment($id, $query)
        return $this->getCategorySegment($id, $query);

    public function getArticleSegment($id, $query)
        return array($id);
  • Comment line 62 and 111 from /components/com_content/helpers/route.php to disable the lookup of the Itemid there.
  • See that the right menu items are still found for the items
  • See that URLs without an Itemid are created properly and return a page that does not throw an error code. Please notice that this currently will display all other URLs of com_content still as mostly non-SEF. That behavior will come in another rule.

This was updated on May 22nd 2015. All discussions prior to that point have either been integrated or are obsolete.

This was made possible through the generous donation of the people mentioned in the following link via an Indiegogo campaign:

…s pretty complex and throws errors in our testing environment
Hackwar and others added 19 commits March 22, 2015 12:58
Call-time pass-by-reference has been removed

Removing JError, using Exception instead

protecting $name and renaming register() to registerView()

Adding removeRule, getRules and renamed $id to $key in register method

Making method names consistent

Implementing JComponentRouterViewconfiguration for configuration of views in JComponentRouterAdvanced

Codestyle, smaller improvements, unittests for all component router classes except for JComponentRouterAdvanced

Removing ability to have one view with different names and implementing unittests for JComponentRouterAdvanced

Adding get<View>Slug() and get<View>Key() methods to JComponentRouterAdvanced

Updating unittest

Small fixes

Adding back in platform check

Adding back in platform check

Adding back in platform check

Adding back in platform check

Implementing feedback so far

Adding "covers" notation for unittests

Fix unit test failure in JComponentRouterViewTest
@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label May 23, 2015
Copy link
Member Author

Hackwar commented May 23, 2015

I've updated this PR to work with the changed JComponentRouterView class. Please test.

Copy link

Duke3D commented Jul 24, 2015

Is this still active? If so, I suggest a companion PR with patch for the listed code changes needed to implement the test conditions.

This comment was created with the J!Tracker Application at

Copy link
Member Author

Hackwar commented Jul 24, 2015

@Duke3D What do you mean with companion PR and what not? And this is still active, yes.

Copy link
Member Author

Hackwar commented Jul 24, 2015

Please be aware that all comments above mine from May 23rd have either been incorporated into this or do not apply here. Those come from several cross merges.

Copy link
Member Author

Hackwar commented Aug 2, 2015

I've combined the changes from this and all other routing related PRs into a new PR: #7615 Please review and comment in the new PR. I'm closing this one, so that we can focuse on the new PR.

@Hackwar Hackwar closed this Aug 2, 2015
@Hackwar Hackwar deleted the componentrulesnomenu branch January 6, 2016 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Language Change This is for Translators
None yet

Successfully merging this pull request may close these issues.

None yet

7 participants