Skip to content

Instantly share code, notes, and snippets.

@zaurmag
Created August 14, 2016 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save zaurmag/3db24d856fad69ffc99af2395a8cbe12 to your computer and use it in GitHub Desktop.
Save zaurmag/3db24d856fad69ffc99af2395a8cbe12 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