JRoute::_ return wrong Menu URL

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

Moderators: ooffick, General Support Moderators

Forum rules
Locked
tkalweit
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat May 13, 2017 5:21 pm

JRoute::_ return wrong Menu URL

Post by tkalweit » Mon Apr 23, 2018 7:03 pm

Hi,

I use 3.8.7 and I get the worong URL by JRoute::_.
My menu use the url: http://joomla.local/joomla/admin/tablets
but with:

Code: Select all

$menu = JFactory::getApplication()->getMenu();
$item = $menu->getActive();
error_log('URL:' . JRoute::_($item->link));
I get back the url: http://joomla.local/joomla/admin/tablets/tablets

it add one /tablets to much.

is this my mistake?

Thx T.

bomkallo
Joomla! Explorer
Joomla! Explorer
Posts: 251
Joined: Fri Jun 14, 2013 7:27 am
Location: Poland

Re: JRoute::_ return wrong Menu URL

Post by bomkallo » Mon Apr 23, 2018 7:11 pm

Try to var_dump $item with xdebug for clear response. I can't check it for now, but the problem might come from component router (route.php), not JRoute itself.

PS: I don't remember, but should you use jroute in case of menu retrieval?

tkalweit
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat May 13, 2017 5:21 pm

Re: JRoute::_ return wrong Menu URL

Post by tkalweit » Tue Apr 24, 2018 5:30 am

The component is generated by component-creator.

I found this page: https://docs.joomla.org/J3.x:Supporting ... _component

but my code use the JComponentRouterBase instead of RouterBase.

My code add allways a /tablets to each call, for example first call /admin/tablets, second /admin/tablets/tablets
third /admin/tablets/tablets/tablets and so on.


I need to read more about JComponentRouterBase now.

Thx!

tkalweit
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat May 13, 2017 5:21 pm

Re: JRoute::_ return wrong Menu URL

Post by tkalweit » Tue Apr 24, 2018 6:08 pm

Okay I found a little solution, but I think there is something wrong.

My router.php use the build function, like shown here: https://docs.joomla.org/J3.x:Supporting ... ex_Example

This part seems to create the wrong url.

Code: Select all

		if (isset($query['view']))
		{
			$segments[] = $query['view'];
			$view = $query['view'];
			
			unset($query['view']);
		}
If I commented out

Code: Select all

$segments[] = $query['view'];
the url is right.

Are there any suggestions?

tkalweit
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat May 13, 2017 5:21 pm

Re: JRoute::_ return wrong Menu URL

Post by tkalweit » Sat Apr 28, 2018 11:48 am

Push...

Can I post more informations for getting an answer?

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

Re: JRoute::_ return wrong Menu URL

Post by Per Yngve Berg » Sat Apr 28, 2018 12:22 pm

Mod. Note: Relocated the topic to the coding forum.


Locked

Return to “Joomla! 3.x Coding”