我正在尝试将一个变量从索引页传递到文章视图。基本上,div的宽度需要根据是否有侧边栏进行更改。
index.php:
if ($this->countModules('position-1')&$this->countModules('position-3')){
$content_margin = 'contentCenter';
}elseif ($this->countModules('position-1')&!$this->countModules('position-3')){
$content_margin = 'contentRight';
}elseif (!$this->countModules('position-1')&$this->countModules('position-3')){
$content_margin = 'contentLeft';
}else{
$content_margin = '';
}那么如何访问组件中的$content_margin变量呢?
<jdoc:include type="component" class="<?php echo $content_margin; ?>" />发布于 2013-04-26 02:59:26
我更愿意尝试这样的方式:
<div class="<?php echo $content_margin; ?>">
<jdoc:include type="component" />
</div>你不需要把这个变量传递给你的组件,只要给你的CSS类不同的宽度即可。
如果想要计算组件中的模块数量,可以查看this链接
https://stackoverflow.com/questions/16180752
复制相似问题