Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在joomla的特定位置加载两个模块_Php_Joomla_Joomla3.2 - Fatal编程技术网

Php 在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

我希望能够在一个特定的位置分配多个模块,但在joomla中的任何给定时间只显示其中的两个模块。我该怎么做

经过一些研究,我发现可以使用下面的代码来完成

$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对此表示感谢,但我刚刚从文档中找到了解决方案。。现在就把它作为一个答案发布…我很想看到答案!