Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created December 11, 2011 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/1458242 to your computer and use it in GitHub Desktop.
Save iaindooley/1458242 to your computer and use it in GitHub Desktop.
Conditional Includes in Template Animation
When the user is not logged in:
<div id="content" class="noSidebar">
<div id="main">
<!-- STUFF GOES IN HERE //-->
</div>
</div>
Now imagine that for some really good technical reason, we need to remove that noSidebar class when we add a sidebar:
<div id="content" class="withSidebar">
<div id="main">
<!-- STUFF GOES IN HERE //-->
</div>
<div id="sideBar">
<!-- SOME OTHER STUFF GOES IN HERE //-->
</div>
</div>
The designer/template implementor simply creates two files:
my_interface.html
my_interface_logged_in.html
The developer then chooses which one to load according to whatever login system they're using:
if($security->loggedIn())
$template = $this->loadTemplate('my_interface_logged_in.html');
else
$template = $this->loadTemplate('my_interface.html');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment