joomla/joomla-cms — pull request #5446 by Hackwar (2014-12-16 21:08:10+00:00)
Title: Routing: JComponentRouterRulesMenu to find right Itemid

This rule implements finding the right Itemid as a generic rule for all component routers that extend from JComponentRouterAdvanced. It makes most of the parts of the *HelperRoute classes obsolete.

### How to test
- Apply this change
- Change the router of com_content by replacing
```php
class ContentRouter extends JComponentRouterBase
{
```
with
```php
class ContentRouter extends JComponentRouterAdvanced
{
function __construct($app = null, $menu = null) {

$this->register('categories', 'categories');
$this->register('category', 'category', 'id', 'categories', '', true, array('default', 'blog'));
$this->register('article', 'article', 'id', 'category', 'catid');
$this->register('archive', 'archive');
$this->register('featured', 'featured');
$this->register('form', 'form');
parent::__construct($app, $menu);

$this->attachRule(new JComponentRouterRulesMenu($this));
}
```
- Comment line 69 and 123 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

### Issues
This does not yet work properly for multi-language sites, since that requires #5140 and all related PRs to be merged. This code however does not need modifications in that case.
This also assumes that #5444 is accepted. That PR is already part of this one, but in order to keep it manageable, #5444 should be reviewed and merged before this one is tackled.

This was made possible through the generous donation of the people mentioned in the following link via an Indiegogo campaign: http://joomlager.de/crowdfunding/5-contributors