0

I've encountered a problem and I can't seem to solve it.

My articles are tied to subcategories.

In one menu item, I display a list of all articles. Let's call it [all-articles]. This is Blog layout.

In another menu item, I first display a list of subcategories. Let's call this [all-categories]. This is Categories layout.

Then, when I open any subcategory, a list of articles appears. When I open any article, its path in the breadcrumbs and in the URL looks like this: sitename.com/all-articles/subcategory-name/article-name.

But I want it to be displayed like this: sitename.com/all-categories/subcategory-name/article-name.

It turns out that the main menu item for the article has become the menu with all the articles. But I want it to be with all the categories. How can I implement this?

PS

If I enter both of these URLs for the article, it will open with both. That is, both URLs work for the article, but I want the main URL to be the one with all-categories.

1 Answer 1

0

No easy way that I'm aware of! You could try raising an issue on the Joomla issue tracker if you felt strongly about this.

I tried solving it by creating a template override for the categories layout area, by injecting the Itemid you want into the Route::_() calls, but it refused to go with it.

The only way I can think of is to override the com_content custom router as described at https://groups.google.com/g/joomla-dev-cms/c/Tpw5kMASF2A then rather than using the standard Joomla\CMS\Component\Router\Rules\MenuRules class write your own which would have your own preprocess() function. That would allow you to select whatever menuitem you wanted to use as base, and then Joomla would use its alias as that segment of the SEF URL.

If you want to go down this route then you might find useful a couple of videos I made at https://youtu.be/zqyjRuVaT8M and https://youtu.be/d1WoRbXcvkw.

Also I'd be happy to provide some further guidance about this approach if you want.

3
  • Thank you for the advice. I realized that solving this problem is not simple. So, I'll leave it for the future, and right now I'll focus on more important matters concerning my project. If I manage to achieve something later on, I'll write here about the results. Sep 26 at 8:17
  • As I said above, you ought to be able to do a template override and inject the Itemid of the menuitem you want, but that didn't work. So I raised a Joomla issue at issues.joomla.org/tracker/joomla-cms/41946 - you can follow its progress if you're interested. Sep 27 at 11:49
  • @VladSocurenco I noticed that there were other similar issues on stack exchange, so I decided to write up in detail how to override the MenuRules for com_content. You can find it at joomla.stackexchange.com/questions/33370/… if you're interested. Oct 10 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.