Skip to main content
Share Your Experience: Take the 2024 Developer Survey
5 votes

Remove /component/ from URL generated from module for a custom component

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 ...
Nagarjun's user avatar
  • 3,001
3 votes

Create SEF URLs from a Custom Component that does not search on database

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 ...
Artur Stępień's user avatar
3 votes

Joomla 4 no longer inserting the Itemid, the current or active menu , in the URL. Is this correct behavior?

In Joomla 4 the /library/src/Router/SiteRouter.php has a new method, buildInit, that replaces the createInit method of Joomla 3. In appearance they do the same thing, suffix the URL with the Itemid=(...
Irata's user avatar
  • 3,947
2 votes

Router for Joomla 4

com_banners and other core components in J4 use service-based structure. For this the component needs to include a services/provider.php file which returns a service provider. The provider must ...
Sharky's user avatar
  • 11.4k
2 votes

Joomla 4: Error when I use getArticleRoute

You need to register extension namespaces to use extension classes. This can be done with JNamespacePsr4Map::load(): JLoader::register('JNamespacePsr4Map', JPATH_LIBRARIES . '/namespacemap.php'); (new ...
Sharky's user avatar
  • 11.4k
2 votes
Accepted

Creating site routes from Administrator client

Corrected Response ---------------- I tried this on a Joomla 4 component which I have and it worked ok, so I reckon you should be able to get it working. That exception gets created in the ...
Robbie Jackson's user avatar
2 votes

Remove /component/ from URL generated from module for a custom component

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 ...
Pratyush's user avatar
  • 496
2 votes

J4 component URL not SEF

Solution found, all details on https://forum.joomla.org/viewtopic.php?f=831&t=996848 To create a routing in J4 with same behavior that J3, you need to create 4x files : /com_componentname/src/...
Yann's user avatar
  • 41
1 vote

How to catch Joomla\CMS\Router\Exception\RouteNotFoundException in Joomla 4.1?

In J4 exceptions can be handled by system plugins with onError event: use Joomla\CMS\Event\ErrorEvent; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Router\Exception\RouteNotFoundException; class ...
Sharky's user avatar
  • 11.4k
1 vote

Route not working properly on J4?

As there are a number of issues arising like this, this answer explains how to override the com_content router to select a better menuitem to base an SEF URL on. WARNING This is a system plugin, and ...
Robbie Jackson's user avatar
1 vote
Accepted

Joomla 4 Router forward to Controller function

I wrote up in https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Upgrading_to_Joomla4#Router what I found were the differences in the router between v3 and v4. In particular you have to find the ...
Robbie Jackson's user avatar
1 vote

Joomla 4 Component SEF URL not working for detail page of the item when catid is added in the url

There was no issue in my router file but it was in the /components/com_componantname/src/Service/Category.php previously in my file, I only added the * @copyright 2023 Super User * @license GNU ...
user4571727's user avatar
1 vote
Accepted

Using Legacy router while offering API access for own component

Have the component implement Joomla\CMS\Component\Router\RouterServiceInterface. Create and return the router instance in the createRouter() method: public function createRouter(\Joomla\CMS\...
Sharky's user avatar
  • 11.4k
1 vote

Joomla 4: no need for Route::_($url)?

Both of your assumptions are correct. Non-SEF URLs are converted to SEF by System - SEF plugin. But you should use SEF URLs in PHP code whenever possible. This will ensure proper URLs when the plugin ...
Sharky's user avatar
  • 11.4k
1 vote

Joomla 4 URL processing/routing

The answer is that somewhere in the processing, an href with a relative pathname is handled differently between Joomla 3 and Joomla 4. In Joomla 3, the base site URL is prepended. In Joomla 4, a menu ...
John B's user avatar
  • 51
1 vote

Joomla 4 URL processing/routing

There are some backward compatibility issues in Joomla 4 when using Joomla 3 code: https://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_4 Furthermore are you sure that the 404 ...
pe7er's user avatar
  • 2,058
1 vote

Joomla 4 no longer inserting the Itemid, the current or active menu , in the URL. Is this correct behavior?

This is really only a temporary solution if you have control over the site where your extension(s) operate as it is a hack to the core code and not suitable if your extension is used by others. If you ...
Irata's user avatar
  • 3,947
1 vote

Extend the JRoute API?

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 ...
RichardB's user avatar
  • 3,082
1 vote

Create SEF URLs from a Custom Component that does not search on database

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 ...
user1967509's user avatar
1 vote

Create SEF URLs from a Custom Component that does not search on database

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 ...
Terry Carter's user avatar
  • 1,812
1 vote

Unset not removing parameter from URL

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 ...
itoctopus's user avatar
  • 3,226
1 vote

Router, keep only item alias in SEF URL

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 ...
Riccardo Zorn's user avatar
1 vote

Joomla router file with fragment(# parameter in URL) in a custom component

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 ...
Zollie's user avatar
  • 2,936
1 vote

Joomla custom component - router not find alias

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 ...
Robbie Jackson's user avatar
1 vote
Accepted

Get the option and view values of a SEF url (i.e. the internal url)

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-...
Robbie Jackson's user avatar
1 vote
Accepted

Using JRoute to generate component SEF URL without a menu item id

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 ...
Dom's user avatar
  • 512
1 vote

Using JRoute to generate component SEF URL without a menu item id

(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 ...
Robbie Jackson's user avatar
1 vote
Accepted

Find Article SEF URL by ID

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 ...
FFrewin's user avatar
  • 19.7k
1 vote

Generate link to a page with specific language

If you have a multilingual site and your articles are associated, enable Show Associations option in com_content configuration.
Sharky's user avatar
  • 11.4k
1 vote

Generating URL in CLI

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 ...
NickSdot's user avatar
  • 111

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