Posted By

joomlabamboo on 11/28/11


Tagged

joomla


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jbyerson


Retrieve module id in Joomla xml element


 / Published in: PHP
 

It's not possible to use the standard syntax to retrieve the current id of the Joomla module in a Joomla xml element. This code parses the url and grabs the last part of the url which i atypically the module id when editing a module in the Joomla admin.

We used this to create a unique cookie for each instance of the module.

  1. // Workaround to get the module id via the url.
  2. $moduleID = JUri::getInstance()->toString();
  3.  
  4. // Split the url instance so we can get the moduel id
  5. $moduleID = split("=",$moduleID);
  6.  
  7. // The fourth = last variable in the module admin so we set the cookie name to that
  8. $cookieName = "listOrder".$moduleID[4];

Report this snippet  

You need to login to post a comment.