From JRoute to Route?

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

From JRoute to Route?

Post by SocketPup » Sat May 04, 2024 6:04 am

I was told JRoute was going to be phased out and no longer work on future versions of Joomla. The following code work(ed) well and gave me the output url I wanted:

Code: Select all

JRoute::_('index.php?option=com_content&view=category&id=9')
So after some trial and error I tried getting the same result with the new way of doing it, see below:

Code: Select all

Route::_(RouteHelper::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language) . "&view=category&id=9");
I just wanted to know if this is the proper way of doing it. The result is what I want, but it might be it's still not done in a best-practice way. Any feedback would be most appreciated.

(to frame it in the right context, I want to add an url in my override template for Article, and have it take the user to the category of said id)

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31057
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: From JRoute to Route?

Post by Per Yngve Berg » Sat May 04, 2024 9:32 am

Mod. Note: Relocating the topic to the J5 Coding Forum.

User avatar
carlitorweb
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Tue May 08, 2018 9:03 pm

Re: From JRoute to Route?

Post by carlitorweb » Sat May 04, 2024 2:52 pm

For get the category link should be:

Code: Select all

Route::_(RouteHelper::getCategoryRoute($this->item->catid, $this->item->language));
The future will be automated, decentralized, and digital.

SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Re: From JRoute to Route?

Post by SocketPup » Sat May 04, 2024 3:05 pm

carlitorweb wrote:
Sat May 04, 2024 2:52 pm
For get the category link should be:

Code: Select all

Route::_(RouteHelper::getCategoryRoute($this->item->catid, $this->item->language));
That code gives the following output:
/blomstradgard/index.php?view=category&amp;id=2
And does not take me to the correct location.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31057
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: From JRoute to Route?

Post by Per Yngve Berg » Sat May 04, 2024 3:39 pm

Add a Menu Item (Itemid).


Post Reply

Return to “Joomla! 5.x Coding”