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 ...
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 ...
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 ...
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');
/...
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.
{
$...
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 ...
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:...
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-&...
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 ...
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 ...
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 ...
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 ...
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" ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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'])) ...
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 ...
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 ...
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&...
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 = ...
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:
...
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);
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
jroute × 49joomla-3.x × 15
sef × 13
custom-component × 10
router × 9
component × 7
url × 6
joomla-4.x × 5
development × 3
module × 2
joomla-2.5 × 2
joomla-3.3.x × 2
menu × 2
ajax × 2
multilingual × 2
joomla-3.9 × 2
view × 2
alias × 2
php × 1
plugin × 1
joomla-3.4 × 1
administrator × 1
menu-item × 1
k2 × 1
template-override × 1