0

I am creating an responsive template and for that to happen I need to use and if else and function. This is what I have so far.

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

I am now receiving the error: Parse error: syntax error, unexpected '&&' (T_BOOLEAN_AND) in index.php on line 197

Line 197 =

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

I have tried adding an extra () but that did not work:

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

I am forgetting something but what.

purple11111
  • 709
  • 7
  • 20

2 Answers2

0

You have your brackets in the wrong place. Try replacing the following:

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

with this:

<?php } elseif ($this->countModules('left') && $this->countModules('right')) { ?>
Lodder
  • 19,758
  • 10
  • 59
  • 100
  • 1
    The order is also wrong because with the original order Joomla will keep saying Left + Content even when the right module position is also in use. – HennySmafter Mar 13 '15 at 13:52
  • 1
    @ Lodder thank you for your answer. I have tried it but as HennySmafter is saying it keeps telling Left + content. – purple11111 Mar 13 '15 at 13:56
0

The order is wrong and instead of adding the () you should remove a set. See the adapted code below.

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

Hopefully this puts you in the right lane.

HennySmafter
  • 131
  • 1
  • 3
  • 14