Re: JRoute:: not giving the correct URL (Joomla 2.5.8)

1,741 views
Skip to first unread message

Bakual

unread,
Jan 15, 2013, 4:14:28 PM1/15/13
to joomla-de...@googlegroups.com
Are you passing the Itemid to JRoute? Because in a view it will take the current Itemid automatically, even if not explicitely passed, but in your Ajax request in the controller there may be no Itemid involved.

Am Dienstag, 15. Januar 2013 21:37:51 UTC+1 schrieb Liam:
I can't work it out.

The JRoute::_() works fine when the page is loading or the form submit button is submitted.

However when using the ajax request (Moo Tools) it returns /component/NAME/VIEW instead of /MENU-ITEM-NAME.

Why would JRoute::_() work on a page reload, but an AJAX request returns /component/NAME/VIEW

The AJAX is calling a controller and return a result. I am trying to make a add to shopping cart style request, everything is working perfectly apart from JRoute::_() returning the wrong url.

Any ideas, menu items are building ok.

Thanks
Liam

brian teeman

unread,
Jan 15, 2013, 9:46:27 PM1/15/13
to joomla-de...@googlegroups.com
itemid is a confusing name - it is really the id number of the menu item

On Wednesday, 16 January 2013 09:54:06 UTC+11, Liam wrote:
No item id is passed, the AJAX is called from a function that has the product ID number.

The product ID is passed back to the controller which then stores it in the session for later use. It then returns a list of items in the session and a link to 'checkout'.

The link to checkout is the one that JRoute::_() fails to complete using the menu alias.

Can you explain what you meant by the item id, I have no item page to load if that makes sense.

Thanks
Liam


Many thanks
Liam Glanfield
07875 328 368


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/EnCvwJXE0AwJ.

To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Bakual

unread,
Jan 16, 2013, 1:47:17 AM1/16/13
to joomla-de...@googlegroups.com
As Brian already mentioned is the Itemid the id of the assigned menu item. Without this, Joomla will not know which menu item is active.
Turn off SEF URLs and you will notice this parameter on each link. You may also notice that it's named &Itemid=1234 and not &itemid=1234. I'm not sure if it's important but I'd keep the first char uppercase just to be sure.

As said, JRoute will add the component name and the Itemid to the link by default. So if you have a link pointing to the same extension, you could use JRoute::_('index.php?view=foo') and it would internally translate to JRoute::_('index.php?option=com_foobar&view=foo&Itemid=1234'). This works in a regular view, but not during an Ajax call if you didn't pass the Itemid. Because then during the call there is no menu item active.

Am Dienstag, 15. Januar 2013 23:54:06 UTC+1 schrieb Liam:
No item id is passed, the AJAX is called from a function that has the product ID number.

The product ID is passed back to the controller which then stores it in the session for later use. It then returns a list of items in the session and a link to 'checkout'.

The link to checkout is the one that JRoute::_() fails to complete using the menu alias.

Can you explain what you meant by the item id, I have no item page to load if that makes sense.

Thanks
Liam


Many thanks
Liam Glanfield
07875 328 368


On 15 January 2013 21:14, Bakual <werbe...@bakual.ch> wrote:
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages