PHP Else If Statement and XML



I'm new to PHP, hence my difficulty on this simple issue. Anyways I'm trying to create a template option in my main menu that hides/shows arrows but cannot seem to get it to work using elseif statements (the class is not being inserted).


Here's the PHP Code:



<?php if ($this->params->get('hideArrows'))
{
$displayArrows = ' class=\"hide-arrows\"';
}
elseif ($this->params->get('showArrows'))
{
$displayArrows = '';
}
?>


The XML Code is:



<field name="displayArrows" type="list" default="hideArrows" label="Display Arrows" description="Display arrows for drop down menu">
<option value="hideArrows">Hide</option>
<option value="showArrows">Show</option>
</field>


And finally the HTML/PHP output is:



<div id="mainmenu"<?php echo $displayArrows;?>>
<jdoc:include type="modules" name="mainmenu" /></div>


Unfortunately it appears that I'm slightly off somewhere which I am struggling to figure out what's wrong with this code.


No comments:

Post a Comment