? Pending

User tests: Successful: Unsuccessful:

avatar csthomas
csthomas
7 Dec 2017

Summary of Changes

Replace the old complex loop with a simpler one.
Remove PHP notice.
Everything should work as before.

This PR adds a way to build correct URL for below structure:

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

Testing Instructions

Install Joomla with sample data testing.
After you replace php code in com_content/router.php as describer above:

  • disable all menu items for categories and category view.
  • add a featured view to menu item if missing
  • Go to index.php/component/content/categories/ and compare link to category view before and after patch.

Expected result

No PHP notices.
Link to the top category view should be like
/featured-articles/14-sample-data-articles

Actual result

There is a PHP Notice: Undefined index id on line 265.

Documentation Changes Required

No

avatar csthomas csthomas - open - 7 Dec 2017
avatar csthomas csthomas - change - 7 Dec 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 7 Dec 2017
Category Libraries
avatar csthomas csthomas - change - 7 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 7 Dec 2017
avatar csthomas csthomas - change - 7 Dec 2017
Title
[Modern Routing] make loop simpler in StandardRules::build
[Modern Routing] make a simpler loop in StandardRules::build
avatar csthomas csthomas - edited - 7 Dec 2017
avatar csthomas csthomas - change - 8 Dec 2017
Labels Added: ?
avatar csthomas csthomas - change - 8 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 8 Dec 2017
avatar csthomas csthomas - change - 8 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 8 Dec 2017
avatar csthomas csthomas - change - 8 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 8 Dec 2017
avatar csthomas csthomas - change - 8 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 8 Dec 2017
avatar csthomas csthomas - change - 8 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 8 Dec 2017
avatar csthomas csthomas - change - 8 Dec 2017
The description was changed
avatar csthomas csthomas - edited - 8 Dec 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Dec 2017

After you replace php code in com_content/router.php as describer above:

this is be done by applying PR or manually?

avatar csthomas
csthomas - comment - 9 Dec 2017

Manually,
to test this PR you need a custom routing configuration as above.
StandardRules from modern routing should support a various configurations, above too.

To create a test example (in order to not install a separate component) I created a custom configuration for com_content in order to show a bug in StandardRules build method.

For such custom configuration, the link to the top category should look like /featured-articles/14-sample-data-articles.

You do not need to click on that link because it has not work yet (parse method has not support such custom configuration yet) and returns error 404. I would like to leave it for another PR.

For this PR I would like to change the loop to simpler and remove PHP notice.

@joomdonation As you are familiar with StandardRules class, would you like to to add your opinion?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 9 Dec 2017

@csthomas this is above my skills.

avatar csthomas
csthomas - comment - 9 Dec 2017

But thanks for interest:)

avatar FPerisa FPerisa - test_item - 11 Dec 2017 - Tested successfully
avatar FPerisa
FPerisa - comment - 11 Dec 2017

I have tested this item successfully on bf28ce6

After following the instructions the top link has the url "/featured-articles/sample-data-articles" instead of the php notice about an undefined id index.
Like expected the link leads to error 404. With IDs in url its workting too.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19012.

avatar joomdonation
joomdonation - comment - 18 Dec 2017

@csthomas I think for this PR you should focus in make a simpler loop in StandardRules::build task only. That part is good and easier to understand compare to the original code. It will help testers easier to review the change and also easier for maintainer to review and merge.

For adding support for new router configuration, I would leave it for the next PR as I am unsure if it needed for now (and as you mentioned, the generated link causes 404 error anyway). The routing code is quite complex, so I prefer small step at a time.

avatar csthomas
csthomas - comment - 29 Dec 2017

Ok. When I have more time to think about it I will fix it.

avatar csthomas
csthomas - comment - 3 Jan 2018

I close it in favour of #19271

avatar csthomas csthomas - change - 3 Jan 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-01-03 11:55:52
Closed_By csthomas
avatar csthomas csthomas - close - 3 Jan 2018

Add a Comment

Login with GitHub to post a comment