Not signed in (Sign In)
Welcome, Guest

Did you know that there is a whole world of functionality you're not seeing? If you have an account, sign in now.

If you don't have an account, apply for one now.

Bottom of Page
Savant2: problem with conditional includes
  1.  
1 to 5 of 5
Jul 9th 2008 edited
I'm having trouble including sub-templates inside if statements. I'm passing booleans to the main template to determine if certain widgets get shown in the side bar:

<!-- $showLoginBox and $showSearchBox are booleans -->

<div id="sidebar">
<ul>
<!-- Login Box -->
<?php
if ($this->_($this->showLoginBox))
include $this->loadTemplate('login.tpl.php') ;

if ($this->_($this->showSearchBox))
include $this->loadTemplate('search.tpl.php');
?>
</ul>
</div>

All that shows in my sidebar is a '1' if the boolean is set to true, and nothing if it's set to false.

What should I be doing differently? Is it possible to conditionally include sub-templates?

Thanks!
Jul 9th 2008
The _ method is for escaping output, which is not what you want for your booleans. Try:

if ($this->showLoginBox)
include $this->loadTemplate('login.tpl.php') ;

if ($this->showSearchBox)
include $this->loadTemplate('search.tpl.php');
Jul 10th 2008
Thanks you! I was hoping it was something simple like that. It works perfectly now.
Jun 29th 2010
Something about the Golf Driving

A correct startup will be critical to be able to giving an individual a chance to be able to travel the ball together with maximum power [url=http://www.golfseasonss.com/]wholesale golf clubs[/url]. Always be certain to be able to carefully adopt these tips, and you’ll always be nicely about ones entire way to be able to the [url=http://www.golfseasonss.com/Callaway-X-22-Irons-3-9PS-1066.html]Callaway X-22 Irons[/url] much longer tee pictures. Many amateur players, equally low- and high-handicappers alike, as well as many Excursion players, swing straight by the [url=http://www.golfseasonss.com/TaylorMade-2009-R7-CGB-Max-Irons-3-9PS-1043.html]R7 CGB Max Irons[/url] down too much together with their owners. The membership set has the least attic regarding any golf club in the bag excluding the putter or the [url=http://www.golfseasonss.com/Titleist-2010-AP2-Irons-3-9P-1181.html]Titleist 2010 AP2[/url], but we know that together with today’s playing golf balls they can hit the ball vast distances as long as the [url=http://www.golfseasonss.com/Ping-G15-Irons-$1-for-Golf-Gloves-1633.html]PING G15[/url] initial launch angle will be adequate. ishiner
Jul 29th 2010
Your problem is very common i think it is useful for many guys


http://www.golfselling.com
  1.  
1 to 5 of 5
Top of PageBack to discussions