? ? ? Pending

User tests: Successful: Unsuccessful:

avatar csthomas
csthomas
6 Oct 2017

Pull Request for Issue #17719 and #16774

Summary of Changes

If link Itemid is equal to active menu and link query is equal to active query then use it, do not try to find a better match.
Add unit tests to prove that.

Testing Instructions

Use tests from #17719 or #16774 or this below.

  1. Turn off Search Engine Friendly URLs in Global Configuration
  2. Create menu item (Style 1) to an article, save, then save as copy (Style 2), publish and save and close.
  3. Go to front-page and click on the first one (Style 1), check both URLs, it is OK.
  4. Go to second (Style 2), and check link at (Style 2), the Itemid in URL point to (Style 1) instead to itself (Style 2).

Expected result

Active second menu item (Style 2) should have URL to (Style 2)

Actual result

Active second menu item (Style 2) use first menu item URL (Style 1)

Documentation Changes Required

No

avatar joomla-cms-bot joomla-cms-bot - change - 6 Oct 2017
Category Libraries Unit Tests
avatar csthomas csthomas - open - 6 Oct 2017
avatar csthomas csthomas - change - 6 Oct 2017
Status New Pending
avatar csthomas
csthomas - comment - 6 Oct 2017

@arrowthemes @weeblr

This small patch should fix your issues and it has chance to be merged in J3.8.x than my previous one #17746 that won't be merged in J3.8

To test you have to replace only one file libraries/src/Component/Router/Rules/MenuRules.php.

avatar esedic esedic - test_item - 7 Oct 2017 - Tested successfully
avatar esedic
esedic - comment - 7 Oct 2017

I have tested this item successfully on 94fae0c


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

avatar infograf768
infograf768 - comment - 8 Oct 2017

Not sure this works.
Test with 3 menu items displaying same article:
screen shot 2017-10-08 at 09 07 00

When clicking a second time on the same menu item, the itemid changes, except for the last one.
This screencapture displays the url(s) obtained at the bottom of the window.
itemid

avatar infograf768
infograf768 - comment - 8 Oct 2017

@csthomas
Note: I also tested #17746 with the same menu items and when clicking a second time on the same menu item, it changes from the menu item itemid to the Home page menu item itemid.

avatar ggppdk
ggppdk - comment - 8 Oct 2017

@infograf768
it must be because of:
#18260 (comment)

avatar csthomas csthomas - change - 8 Oct 2017
Labels Added: ? ?
avatar csthomas
csthomas - comment - 8 Oct 2017

Thanks @ggppdk @infograf768

PR #17746 after the last commit is broken for this test.

I added a new commit. I tested an article with menu styles with success.
Please test again.

avatar infograf768
infograf768 - comment - 8 Oct 2017

At first sight, it was working OK, i.e. I got unique itemids for each of the menu items, even when clicking again on the same menu... but when clicking on the category link in the Article Info Category link, I get
[08-Oct-2017 16:12:19 Europe/Berlin] PHP Warning: explode() expects parameter 2 to be string, array given in /Applications/MAMP/htdocs/testnew/trunkgitnew/libraries/src/Component/Router/Rules/MenuRules.php on line 83

avatar csthomas
csthomas - comment - 8 Oct 2017

The problem was filter_key that is an array in category view.
As filter_key is not a part of routing then I use now only option, view, key (usual it is id) and layout.

avatar infograf768
infograf768 - comment - 9 Oct 2017

@csthomas
Your last changes solve the category display warning, but we still have an error.

Test:
Create a menu item of type Create an article
Create a menu item of type Login form with option set to redirect to the Create an article menu item.
Login via this login form. url is here http://localhost:8888/testnew/trunkgitnew/index.php?option=com_users&view=login&Itemid=135&lang=en

Login is done OK, but I get a notice:
[09-Oct-2017 10:46:22 Europe/Berlin] PHP Notice: Undefined index: a_id in /Applications/MAMP/htdocs/testnew/trunkgitnew/libraries/src/Component/Router/Rules/MenuRules.php on line 103

The Notice is the same in multilang whether the redirect is set to a Create an article tagged to the same language as the login form or to another language.

avatar infograf768
infograf768 - comment - 9 Oct 2017

In fact clicking directly on the Create article menu item also sends the Notice.
URL is:
http://localhost:8888/testnew/trunkgitnew/index.php?option=com_content&view=form&layout=edit&a_id=0&Itemid=134&lang=en

avatar infograf768
infograf768 - comment - 9 Oct 2017

TBH, I am a bit concerned about B/C here.
I have only tested stuff concerning com_content, but are'nt we going to find other issues in other extensions, including 3rd party?

avatar csthomas
csthomas - comment - 9 Oct 2017

There is still an issue with B/C now.

avatar infograf768
infograf768 - comment - 9 Oct 2017

Last commit solved the Notice for Create Article menu item.

avatar csthomas
csthomas - comment - 9 Oct 2017

As I can not use $view->key because it is only in newer routing I back to simpler way and only compare strings, if in query has array then this PR change nothing.

avatar csthomas
csthomas - comment - 9 Oct 2017

Current version does not work for category view because category view has query parameter filter_tag that is not used in build lookup. I can add a workaround for that by adding code in loop

if (strpos($k, 'filter_') === 0) continue; that will ignore every filter parameters.

avatar infograf768
infograf768 - comment - 10 Oct 2017

@csthomas

If someone care about category view then such improvement could be add later.

What is the exact issue you have with category view?

avatar infograf768
infograf768 - comment - 10 Oct 2017

What I remarked (and I do not see how to solve that aspect except by a new parameter), is that

  1. a link to article 1 in an article will always display the article1 menu item with highest id
  2. same for a link to a category in the article info when one has 2 single category menu items.
    Example a category blog has itemid 117 and category list or blog is itemid 136, then 136 will display.
avatar csthomas
csthomas - comment - 10 Oct 2017

Joomla routing is not a simple path.

Version for monolingual (If you do not use language parameter):

  • if you want to route to article then you look up for the lowest menu item id that match criteria.
    Version for multilingual (If appended parameter lang=...):
  • if you want to route to article then you look up for the highest menu item id that match criteria.

This is very weird but probably there ware some B/C issue.

The code is at https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Component/Router/Rules/MenuRules.php#L206 - the trick one

[Deleted]
...

avatar csthomas
csthomas - comment - 10 Oct 2017
  1. same for a link to a category in the article info when one has 2 single category menu items.
    Example a category blog has itemid 117 and category list or blog is itemid 136, then 136 will display.

[Updated]

It would be good to add new column/field "Routing Priority" to each menu item. This way we can manage which menu item (category menu) should be used for routing

After that you can set higher priority for menu item 117.
Then only first category menu will be used for articles routing.

avatar csthomas
csthomas - comment - 10 Oct 2017

Going back to this PR,

If someone care about category view then such improvement could be add later.

What is the exact issue you have with category view?

I'm surprised that it works for category menus.
Ok, then It is completed. Please test.

avatar infograf768 infograf768 - test_item - 12 Oct 2017 - Tested successfully
avatar infograf768
infograf768 - comment - 12 Oct 2017

I have tested this item successfully on 8740d71

No more Notices or warnings.
Modules assignment work fine.


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 12 Oct 2017

@esedic can you please retest?

avatar esedic esedic - test_item - 12 Oct 2017 - Tested successfully
avatar esedic
esedic - comment - 12 Oct 2017

I have tested this item successfully on 8740d71

@franz-wohlkoenig, done



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

avatar franz-wohlkoenig franz-wohlkoenig - change - 12 Oct 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 12 Oct 2017

RTC after two successful tests.

avatar mbabker mbabker - close - 15 Oct 2017
avatar mbabker mbabker - merge - 15 Oct 2017
avatar mbabker mbabker - change - 15 Oct 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-10-15 15:53:25
Closed_By mbabker
Labels Added: ?

Add a Comment

Login with GitHub to post a comment