Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cave2006/fa9e3897dc980b9f2c444880ac84b07b to your computer and use it in GitHub Desktop.
Save cave2006/fa9e3897dc980b9f2c444880ac84b07b to your computer and use it in GitHub Desktop.
Вывод модулей в шаблоне Joomla
<?php //вывод позиции модулей
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$options = array('style' => 'xhtml');
$position = 'user1';
echo $renderer->render($position, $options, null);
?>
<!-- или -->
<?php
$modules =JModuleHelper::getModules('position-0');
foreach ($modules as $module){
echo JModuleHelper::renderModule($module);
}
?>
<!-- Вывод одного модуля -->
<?php //Вывод одного модуля
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$options = array('style' => 'raw');
$module = JModuleHelper::getModule('mod_custom_banners');
$module->params = "heading=2\nlimit=10"; //как видим даже параметры задавать
echo $renderer->render($module, $options);
?>
<!-- или -->
<?php
$module = JModuleHelper::getModule('mod_banners');
echo JModuleHelper::renderModule($module);
?>
<!-- Вывод модуля по id -->
<?php //выводим модуль по id
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>'xhtml');
$dbo = JFactory::getDBO();
//получить модуль как объект
$dbo->setQuery("SELECT * FROM #__modules WHERE id='111' ");
$module = $dbo->loadObject();
//убрать предупреждение
$module->user = '';
echo $renderer->render($module, $params);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment