November 20th, 2009 › Joomla, Notes, PHP › admin ›
This is a handy piece of code I use for whenever I need to load the output of a Joomla module as a PHP variable. One common use for this is to allow for HTML tags in menu titles. It’s also handy if you need to do string searches.
<? // extra code to make this work $style = -2; // set the style $position = "column4"; // set the position of the modules to be loaded // end of extra code <br/> $document = &JFactory::getDocument(); $renderer = $document->loadRenderer('module'); $params = array('style'=>$style); <br/> $contents = ''; foreach (JModuleHelper::getModules($position) as $mod) { $contents .= $renderer->render($mod, $params); } <br/> // html_entity_decode allows html from the menu title to parse normally // otherwise, just do whatever you need to $contents echo html_entity_decode($contents); ?>
No Comments
Comments RSS TrackBack Identifier URI
No comments. Be the first.
Leave a comment
Name (required)
Mail (will not be published) (required)
Website
Your comment