Php 在组件joomla 2.5中调用模块时如何设置布局
在组件中,如何调用模块:Php 在组件joomla 2.5中调用模块时如何设置布局,php,joomla,joomla2.5,Php,Joomla,Joomla2.5,在组件中,如何调用模块: tmpl ---default.php ---hello.php mod_hello.php mod_hello.xml helper.php $module = JModuleHelper::getModule('mod_hello'); echo JModuleHelper::renderModule ($module ); 当我echo使用布局default的结果时,如何显示模块mod_hello的布局是hellolayout阅读下面的论坛线程,这可能
tmpl
---default.php
---hello.php
mod_hello.php
mod_hello.xml
helper.php
$module = JModuleHelper::getModule('mod_hello');
echo JModuleHelper::renderModule ($module );
当我
echo
使用布局default
的结果时,如何显示模块mod_hello的布局是hello
layout阅读下面的论坛线程,这可能会帮到你
有两种方法可以调用模块:
A. Call Module by position :
$position = 'left';
$contents = '';
foreach (JModuleHelper::getModules($position) as $mod) {
$contents .= $renderer->render($mod, $params);
}
B. Call Module by name :
$modName = 'mostread '; // not mod_mostread
$modTitle = 'Popular';
$mod = JModuleHelper::getModule($modName, $modTitle);
$content = JModuleHelper::renderModule($mod);
内容/文章中的调用模块:您可以使用{loadposition}(感谢plgContentLoadModule-/plugins/Content/loadmodule.php)
以编程方式调用模块(模块调用另一个模块或组件调用模块):
我是如何做到的:
模块上下文中有一个$attribs数组,因此您可以使用它来传递布局
$module = JModuleHelper::getModule('mod_hello');
$attribs = array('layout'=>'hello');
echo JModuleHelper::renderModule ($module,$attribs);
然后在mod_hello.php中:
$layout = isset($attribs['layout'])?$attribs['layout']:'default';
require(JModuleHelper::getLayoutPath('mod_hello',$layout));
$layout = isset($attribs['layout'])?$attribs['layout']:'default';
require(JModuleHelper::getLayoutPath('mod_hello',$layout));