Wrong SEF URL using JRoute

For Joomla! 4.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.
Locked
KriZan
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Fri Oct 15, 2021 12:31 pm

Wrong SEF URL using JRoute

Post by KriZan » Fri Oct 15, 2021 12:41 pm

Hi,
SEF and URL-rewrite is on and working. I develope a component 'com_mycomponent'. I created a menu item to my components view with an alias 'myview'. My components view is now available under example.org/myview.

Then I try to create a link inside of my component with JRoute::_('index.php?option=com_mycomponent'). This should create '/myview' as it does in Joomla! 3. But now I get '/component/mycomponent'.
What is wrong? Where is the mistake?

Thanks for reply!

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

Re: Wrong SEF URL using JRoute

Post by Per Yngve Berg » Fri Oct 15, 2021 3:33 pm

Include a menu item (Itemid=xx).

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12787
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Wrong SEF URL using JRoute

Post by brian » Fri Oct 15, 2021 6:47 pm

As explained on github its a bug in joomla when you dont have a layout in the url as the roter is failing to select the default layout for the component
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

KriZan
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Fri Oct 15, 2021 12:31 pm

Re: Wrong SEF URL using JRoute

Post by KriZan » Mon Oct 18, 2021 8:56 am

can you post the link to github pls?

emedina
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Oct 31, 2021 10:28 pm

Re: Wrong SEF URL using JRoute

Post by emedina » Sun Oct 31, 2021 10:30 pm

omg
I have wasted all the afternoon trying to fix this.

GreenDot
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Thu Dec 02, 2021 9:27 pm

Re: Wrong SEF URL using JRoute

Post by GreenDot » Thu Dec 16, 2021 3:19 am

KriZan wrote:
Mon Oct 18, 2021 8:56 am
can you post the link to github pls?
Has anyone that link? Have a similar issue...

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17437
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Wrong SEF URL using JRoute

Post by toivo » Thu Dec 23, 2021 7:23 am

The closest open bug I could find was reported from Joomla 3.9.20 last year:
[3.9] Component routers gives incorrect menu item for default view layouts when view has non default layouts #30169

The report refers to lines 256 - 259 of \Joomla\CMS\Component\Router\Rules\MenuRules::buildLookup in 3.9.20, which lines remain the same in Joomla 3.10.4. Lines 264 - 267 in Joomla 4.0.5 are similar:

3.9.20

Code: Select all

						if (!isset($this->lookup[$language][$view . $layout]) || $item->language !== '*')
						{
							$this->lookup[$language][$view . $layout] = $item->id;
							$this->lookup[$language][$view] = $item->id;
						}
4.0.5

Code: Select all

						if (!isset($this->lookup[$language][$view . $layout]) || $item->language !== '*')
						{
							$this->lookup[$language][$view . $layout] = $item->id;
						}
Toivo Talikka, Global Moderator


Locked

Return to “Joomla! 4.x Coding”