Php 在joomla的特定位置加载两个模块
我希望能够在一个特定的位置分配多个模块,但在joomla中的任何给定时间只显示其中的两个模块。我该怎么做 经过一些研究,我发现可以使用下面的代码来完成Php 在joomla的特定位置加载两个模块,php,joomla,joomla3.2,Php,Joomla,Joomla3.2,我希望能够在一个特定的位置分配多个模块,但在joomla中的任何给定时间只显示其中的两个模块。我该怎么做 经过一些研究,我发现可以使用下面的代码来完成 $arrayofmoduleObj = JModuleHelper::getModules('position') // to get an array of module Object. $options = array('style' => 'chrome'); foreach($arrayofmoduleObj as $modu
$arrayofmoduleObj = JModuleHelper::getModules('position') // to get an array of module Object.
$options = array('style' => 'chrome');
foreach($arrayofmoduleObj as $moduleObject){
/* code to decide whether to print this module or not if yes */
echo JModuleHelper::renderModule($moduleObject,$options) //to render a module Object..
else continue;
}
如果我希望能够随机选择分配到特定位置的模块,该怎么办。。通过代码?这不是Joomla附带的功能。您可能需要寻找第三方扩展或编写自己的插件。您可能希望编写自己的模块,以加载分配给Joomla允许的模板中不存在的位置的所有模块。您创建的模块将具有随机选择2个模块并显示它们的代码。@DavidFritsch对此表示感谢,但我刚刚从文档中找到了解决方案。。现在就把它作为一个答案发布…我很想看到答案!