2015-03-13 17 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