Joomla模块位置,如果其他和


joomla module position if else and

我正在创建一个响应式模板,为此我需要使用 if else 和功能。这就是我目前所拥有的。

<?php if ($this->countModules('left')) { ?>
<p>Left + Content</p>
<?php } elseif ($this->countModules('right')) { ?>
<p>Right + Content</p>
<?php } elseif ($this->countModules('left')) && ($this->countModules('right')) { ?>
<p>Left + Right + Content</p>
<?php } else { ?>
<p>Content</p>
<?php } ?>

我现在收到错误:解析错误:语法错误,索引中意外的"&&"(T_BOOLEAN_AND.php第 197 行

第 197 行 =

<?php } elseif ($this->countModules('left')) && ($this->countModules('right')) { ?>

我尝试添加一个额外的(),但这不起作用:

<?php } elseif (($this->countModules('left')) && ($this->countModules('right'))) { ?>

我忘记了一些东西,但什么。

顺序错误,而不是添加 (),您应该删除一个集合。请参阅下面的改编代码。

<?php if ($this->countModules('left') && $this->countModules('right')) { ?>
<p>Left + Right + Content</p>
<?php } elseif ($this->countModules('right')) { ?>
<p>Right + Content</p>
<?php } elseif ($this->countModules('left')) { ?>
<p>Left + Content</p>
<?php } else { ?>
<p>Content</p>
<?php } ?>

希望这能让你走上正确的道路。

你的括号放错了地方。尝试替换以下内容:

<?php } elseif ($this->countModules('left')) && ($this->countModules('right')) { ?>

有了这个:

<?php } elseif ($this->countModules('left') && $this->countModules('right')) { ?>