JRoute problem

109 views
Skip to first unread message

Thomas

unread,
May 2, 2013, 8:35:11 AM5/2/13
to joomla-de...@googlegroups.com
I have a module on my frontpage with a form with an action that uses the JRoute function to show to which page the module should point, this is in a multilangual site with a menu item pointing to the view for each language.

This is the code for the form action attribute: <?php echo JRoute::_('index.php?option=com_jhotelreservation&view=jhotelreservation') ?>

With sef urls turned of the action is index.php?option=com_jhotelreservation&view=jhotelreservation

Turning on sef urls joomla generates this url "/fr/component/jhotelreservation/?view=jhotelreservation" in the french language and "/nl/component/jhotelreservation/?view=jhotelreservation" for the dutch language

I've added for both the french and dutch languages a menu item pointing to "index.php?option=com_jhotelreservation&view=jhotelreservation" 

with sef urls turned on they are: nl/reservatie/reserveren.html (for dutch) and fr/reserver/reservation.html (french). the are also linked to eachother by menu item Association.

The is no router.php file in the component so why does joomla not generate the sef urls from the menu items for the action in the module's form?

Regards

Thomas 

Donald Gilbert

unread,
May 2, 2013, 9:21:51 AM5/2/13
to joomla-de...@googlegroups.com
Joomla doesn't know which Itemid to assign to the link without you telling it or giving it some type of instruction (which is what the router.php is for).

So, what I've done in the past is go into the menu manager to see what the Itemid the desired menu item is and then manually append it to the links within the JRoute::_() call. The problem with that is that it is not very flexible. You can't restructure your menu without also going in and changing the code.

I would take a look at the router.php in com_content. Starting around line 87 there is a call to the database to fetch the proper Itemid for the loaded view.


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

WP4J

unread,
May 2, 2013, 9:12:07 PM5/2/13
to joomla-de...@googlegroups.com
In Joomla 3.0 there is also a menuitem field type, so you could then add this field to the module's config parameters and get the Itemid like that - saves manually editing files. As Donald Suggested you can use the DB, but the trouble is which Itemid? You can basically have multiple instances of menu items from the same view so there is no real way that the system can "guess" via a db call - maybe you could just take the first one it finds, even then I think adding a menuitem field to the module config and using the stored itemid to put in the JRoute call is the way to go, makes the module much more flexible.

Billy
Reply all
Reply to author
Forward
0 new messages