Hot answers tagged

6 votes
Accepted

Create a link from Backend to SEF Path in Frontend

Since 3.9 there's Joomla\CMS\Router\Route::link() method which takes client (site or administrator) as first argument. $link = 'index.php?option=com_content&view=article&id=1'; echo '<a ...
Sharky's user avatar
  • 10.5k
3 votes
Accepted

How to properly add a query parameter to my Router?

What you're doing is the proper way. The included rules are suitable for basic components, they're not meant to work for every known component. In fact, some of the core components are running into ...
Sharky's user avatar
  • 10.5k
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

Problem with JRoute::_ and ajax data

The final source code is: // Get menu item $app = JFactory::getApplication(); $menu = $app->getMenu(); // Get component's name $comName = JFactory::getApplication()->input->get('option'); /...
Anibal's user avatar
  • 7,435
2 votes
Accepted

How to remove IDs from SEF URL in Joomla?

I found the solution with the help of @Farahmand, here it is: <?php defined('_JEXEC') or die; function empresaBuildRoute(&$query) //Esta función divide la url y se trae las variables. { $...
Ignacio Salcedo's user avatar
2 votes
Accepted

Possible to associate item with itself?

I'm presuming it's the Joomla Language Switcher module which you're using to switch languages. In this case, this module has to generate the links which are behind the little flag symbols. It does ...
Robbie Jackson's user avatar
2 votes

JRoute not working - always shows the current view

You need to add your own router.php and build your own views in the build + parse methods in it. I would create a router.php file with this information: https://docs.joomla.org/J3.x:...
pe7er's user avatar
  • 1,918
2 votes
Accepted

Absolute SEF url with JRoute

You could try this way: $itemid = 164; $application = JFactory::getApplication(); $menu = $application->getMenu(); $item = $menu->getItem( $itemid ); $link = new JURI( $item->link ); $link-&...
FFrewin's user avatar
  • 19.6k
2 votes
Accepted

How to disable Joomla routing by Article ID with any alias but use exact alias only

May not be practical for blog articles, but a fixed url can be achieved via menu items: https://docs.joomla.org/Search_Engine_Friendly_URLs#Limitations Otherwise, if I see it correctly, you have to ...
astridx's user avatar
  • 404
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

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
  • 10.5k
1 vote

What is the best way to have pages displaying articles from our custom content table in Joomla 4.1?

if you just want to use different content than the one stored in the com_content tables, why not creating a simple content plugin which replaces the content in the row before showing it? That way you ...
Carlos Cámara's user avatar
1 vote

JRoute don't make a SEF Url from the article link

Apparently, this is now the expected behavior in J4. You need to create a menu item, but it doesn't have to be a menu item for a specific article. Creating a single "List All Categories" ...
Sharky's user avatar
  • 10.5k
1 vote

JRoute don't make a SEF Url from the article link

Route::_() expects a non-SEF URL as an input. index.php/eng/?view=article&id=29:article-name-1&catid=17 is already an SEF URL, which is why Route::_() is not modifying it. A non-SEF URL would ...
Weeblr's user avatar
  • 51
1 vote
Accepted

Friendly URL for a custom component

You have to create a router for your component for JRoute::_() to do anything. See Supporting SEF URLs in your component documentation. I suggest looking specifically at Simple View-based Example ...
Sharky's user avatar
  • 10.5k
1 vote

Why do we Route url using JRoute or Route namespace? What is the purpose of routing urls?

Hard to give a precise answer without more detail, so this will be oversimplified, perhaps too much so, but I'll try. Joomla URLs natively look like someone dumped part of a can of alphabet soup on ...
Arlen's user avatar
  • 802
1 vote

What is the purpose of cloning JUri in the CMSApplication route method?

Object cloning is done so that subsequent actions on the object are applied purely to the "detached replica" (cloned object) and not the original object. By not cloning, in other words just declaring ...
mickmackusa's user avatar
  • 4,781
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
1 vote
Accepted

JRoute::_('index.php') no longer adds Itemid since Joomla 3.8.4

There seems to be a bug with the routing in Joomla 3.8.4 which is a known issue and is currently being discussed on Github, here: https://github.com/joomla/joomla-cms/issues/19496 I've seem ...
Lodder's user avatar
  • 26.8k
1 vote
Accepted

Joomla! 3.6.4 router.php for a custom component

You are not checking the existence of parameter name before using it. Hence PHP shows the notice message. Change your code to if(isset($query['id']) && isset($query['name'])) ...
Nagarjun's user avatar
  • 2,991
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,787
1 vote

[com]BuildRoute(&$query) function is called with no $query['view'] member passed

BuildRoute function gets whatever the information you will pass to it. How you are creating your urls in your component? Like this? $url = JRoute::_('index.php?option=com_mycomponent&view=myview&...
Nagarjun's user avatar
  • 2,991
1 vote

Absolute SEF url with JRoute

UPDATE 2021 It seems that somewhere around version 3.9.7, they included a fourth parameter in this function, so now the function definition is: public static function _($url, $xhtml = true, $tls = ...
mavrosxristoforos's user avatar
1 vote

Absolute SEF url with JRoute

You can not achieve it the way you trying to because if you look at the router code: link that starts with index.php should be passed, not with http(s) The correct way to achieve routing is: ...
Alexandr's user avatar
  • 1,130
1 vote

Absolute SEF url with JRoute

You can also use proper way to get full url as: $config = JFactory::getConfig(); $mode = $config->get('force_ssl', 0) == 2 ? 1 : (-1); echo JRoute::_('index.php?Itemid=164',false,$mode);
bharat's user avatar
  • 131
1 vote
Accepted

SEF URL using router without id in the URL

You can use .htaccess URL Rewrite replacing the numeric segment to something else but you have to make sure your item's alias column is unique in your component's table unless the same URL segments ...
U K A's user avatar
  • 166
1 vote
Accepted

Component doesn't use route Joomla 2.5.28

It is Ok to create hidden menu items for better content managament. But, you have to be sure that Itemid is associated with generated Urls. It is not so obvious how to associate Itemid. Each ...
Anibal's user avatar
  • 7,435
1 vote

404 HTTP codes in Joomla

I have recently seen this on a few sites and just discovered that it happens when the site is in offline mode and you are logged in to the frontend. When the site is online and you make up a url you ...
Robert Went's user avatar

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