Load Module Outside Template


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. require_once(JPATH_ROOT.DS.'libraries'.DS.'joomla'.DS.'application'.DS.'module'.DS.'helper.php');
  3. $document =& JFactory::getDocument();
  4. $renderer = $document->loadRenderer('module');
  5. $db =& JFactory::getDBO();
  6. $db->setQuery("SELECT * FROM #__modules WHERE position='positionname' AND published=1 ORDER BY ordering");
  7. $modules = $db->loadObjectList();
  8. if( count( $modules ) > 0 )
  9. {
  10. foreach( $modules as $module )
  11. {
  12. //just to get rid of that stupid php warning
  13. $module->user = '';
  14. $params = array('style'=>'xhtml');
  15. echo $renderer->render($module, $params);
  16. }
  17. }

URL: http://jeffchannell.com/Joomla/load-a-joomla-module-position-without-using-jdoc-tags.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.