No Code Attached Yet
avatar robbiejackson
robbiejackson
27 Sep 2023

Steps to reproduce the issue

On a clean install of Joomla set up the following:

An article - eg with title "one"

A menuitem with title "blog", Menu Item Type set to Articles / Category Blog,
Choose a Category set to Uncategorised

A menuitem with title "list", Menu Item Type set to Articles / Category List,
Choose a Category set to Uncategorised

(The order that these menuitems are configured is important).

Go to the front-end. On the site this should then display the 3 menuitems.

When you click on "blog" menuitem it shows article "one" with a link /blog/one

When you click on "list" menuitem it shows article "one" with a link /blog/one

Now use a template override to change the "list" display to try and get it to show article "one" with a link of /list/one instead.

(Or rather than using a template override just edit the file instead).

The key file is: com_content/tmpl/category/default_articles.php.

Around line 176 it has:

<a href="<?php echo Route::_(RouteHelper::getArticleRoute($article->slug, $article->catid, $article->language)); ?>">
    <?php echo $this->escape($article->title); ?>

Change this to include the Itemid of the "list" menuitem (which is 103 on my instance):

<a href="<?php echo Route::_(RouteHelper::getArticleRoute($article->slug, $article->catid, $article->language) . "&Itemid=103"); ?>">
    <?php echo $this->escape($article->title) . " ok"; ?>

(Adding the "ok" to the article title just confirms you're editing the right file).

Redisplay the menuitem "list" on the site.

Expected result

You would expect that specifying the Itemid would force the URL to be /list/one

Actual result

The URL continues to be /blog/one

(You can also change the code to have "&Itemid=101" - the home page - to demonstrate that it uses the entered Itemid for other values).

System information (as much as possible)

Joomla 4.3.4 on Windows 10

Additional comments

Going through with a debugger, I reckon that the Itemid was refused in libraries/src/Component/Router/Rules/MenuRules.php, in the code following line 90

// Check if the active menu item matches the requested query

Obviously the case appears a bit contrived, but I've just made it up to be the easiest way to demonstrate a genuine problem.

avatar robbiejackson robbiejackson - open - 27 Sep 2023
avatar robbiejackson robbiejackson - change - 27 Sep 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 27 Sep 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Sep 2023
avatar brianteeman
brianteeman - comment - 27 Sep 2023

Sorry but I am confused. You want to create two menu items that point to the exact same content with two different urls. Thats exactly the opposite of what everyone else asked for to avoid duplicate content

avatar robbiejackson
robbiejackson - comment - 27 Sep 2023

No, it's just to create a minimal example. As I said in the text, it's a bit contrived, but it's purpose is to highlight a genuine problem.

You can instead create more categories and articles, and have the blog pointing to different categories and articles. As long as you create the blog menuitem before the list menuitem, the router always uses the blog menuitem, even if you try and force it to use the "list" menuitem when it's displaying the category list by injecting the Itemid.


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

avatar Hackwar Hackwar - change - 1 Oct 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-10-03 10:07:36
Closed_By Hackwar
avatar Hackwar Hackwar - close - 1 Oct 2023

Add a Comment

Login with GitHub to post a comment