2015-03-13 16 views
0

我正在创建一个响应模板,并为此发生我需要使用,如果其他和功能。这是我迄今为止所拥有的。joomla模块的位置,如果其他和

<?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)中的index.php上线197

线197 =

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

我曾尝试添加一个额外的()但没有工作:

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

我忘了一些事情,但是什么。

+0

您正在'&&'之前关闭'elseif'。 – inigomedina 2015-03-13 13:50:19

回答

0

的顺序是错的,而不是添加(),你应该删除一组和。请参阅下面的改编代码。

<?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 } ?> 

希望这会让你在正确的车道。

+1

谢谢你的回答。它像魅力一样工作。 – purple11111 2015-03-13 13:56:05

0

你有你的括号在错误的地方。尝试更换如下:

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

与此:

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

订单也是错误的,因为即使当正确的模块位置也在使用中时,原始订单Joomla仍会继续说Left + Content。 – HennySmafter 2015-03-13 13:52:41

+1

@ Lodder感谢您的回答。我已经尝试过了,但正如HennySmafter说的那样,它总是告诉左+内容。 – purple11111 2015-03-13 13:56:51

+0

@HennySmafter - 你是对的...我的不好 – Lodder 2015-03-13 14:05:00