Hot answers tagged

5

The /component/name/ part of the url is automatically written by Joomla router when there is no matching menu item found. This is required for the application to route the command to the proper component. So in your case, the pattern can be removed by creating the menu item. Since the menu item is already mapped to a component view, the routing will happen ...


3

One thing is, that you're trying to create a router in the old way, it changed over time. Now router is a class. Second thing is, one of your component views have to be set as a front-page for a system. Without that, in most websites the default router will be com_content's router, so every wrong URL(url that don't have a proper menu item/parent item) will ...


2

There is a very simple and handy way to do it, you can create a menu at the time of install in script file in method public function postflight($type, $parent). Use a process here as follows to create a menu type and then a menu item => https://webkul.com/blog/menu-item-joomla-rebuild-automatically/ This will create a menu item of your view. Get data ...


1

getCategoryRoute basically justs returns a URL in the following format index.php?option=com_content&view=category&id=[ID PARAMETER]&lang=[LANGUAGE PAREMETER] It's not a particularly complicated function - the entirity is as follows: if ($catid instanceof JCategoryNode) { $id = $catid->id; } else { ...


1

My original goal was creating a alias on frontend without any link using Jroute or menu id... But after a lot of search it seems that Joomla cannot do that or if it can it may need some serious change on Router. So instead of messing with Joomla Router (I actually tried) I created a script on my plugin to create a menutype and to save on database a new menu ...


1

Create your URLs like this: echo JRoute::_('index.php?option=com_mycomponent&Itemid='.Itemid.'&aliasid=alias-'.$id); You will want to include the Itemid of your current menu item, makes things cleaner and helps you keep track of where you are. That can be found with: $Itemid = JFactory::getApplication()->getMenu()->getActive()->id; Try ...


1

Assuming you can only have one list view, then your BuildRoute function should have a maximum of 1 segment (which is the article alias). You should unset all other segments (try doing a print_r to see what you should unset. In your ParseRoute function, you check for the count of segments, and you return either the list view or the article view. Here's how: ...


1

As I suggested in my comment, building a plugin for this may be an alternative solution worth pursuing. In a system plugin, simply add code similar to the example below to intercept any calls. Rest assured the code below was not tested on animals. intercept onAfterRoute() ensure your code should really run there, as an example: exclude administrator ...


1

Your question is not fully clear about using Fragments in Joomla Routers and it is because I do not really see what you really want to do with the fragments in your component's router. Few things I’d like to clear about that though. #Fragments are not handled by the Joomla Router class basically since #fragments do not require routing. It is handled by the ...


1

If I'm understanding you correctly, you have 2 menuitems on your site which have links /formAlias and /listAlias, and when you form an SEF URL using Route:_() then it gives you the wrong link; is that correct? The way I believe Joomla routing works is that when you supply the parameters to Route::_() it goes through the site menuitems to compare the link ...


1

The Joomla router will set up the "option", "view" etc input parameters once it's parsed the SEF URL. So you just have to overwrite those values using the input set method (https://api.joomla.org/cms-3/classes/Joomla.CMS.Input.Input.html#method_set). Then your component/view will be executed instead. So define a group="system" plugin which listens for the ...


1

From the answers comments and further scouring of the codebase, I think the answer is that, no, its not possible for a component to claim a route in Joomla without a menu item id associated with a view from that component. The Joomla docs explicitly confirm this in this article, which says: neither Joomla! nor any component router can create URLs with a ...


1

(Not a proper answer, I'm afraid, just some thoughts – easier to write as an answer rather than lots of comments). First I believe you're right about the need to have a menuitem which is associated with your component. Otherwise you're going to end up with the https://mysite.com/component/mycomponent/xxx format. Secondly a good administrator will be ...


1

It's a bit unclear what's your exact goal and how you are going to use whatever possible answer you are going to get. Will you have all previous SEF URLs changed? Will you do a search and replace inside the database for all old links of the content? And how you could combine a possible API usage with the database operations. I think the whole task needs a ...


1

If you have a multilingual site and your articles are associated, enable Show Associations option in com_content configuration.


1

I played a bit around with that the last hour and the way you do seems to be right. Maybe you can share all the relevant code here? This could also be related to that current Joomla! issue which results in similar URLs containing /administrator/ even if a frontend URL is generated: https://github.com/joomla/joomla-cms/issues/20070 The release lead of ...


1

While I do not have an answer to item 1-3, I can answer my question 4 at least a little bit. The Joomla documentation was recently updated with information about the new router implementation: https://docs.joomla.org/J3.x:Supporting_SEF_URLs_in_your_component https://docs.joomla.org/J3.x:Supporting_SEF_URLs_in_your_component#The_Component_Router


Only top voted, non community-wiki answers of a minimum length are eligible