If-Statement in a View #2184

hice3000 opened this Issue Jan 22, 2013 · 3 comments


None yet

3 participants


I am programming a big project now, and I got some problems with the template parser.
I want that there is really no php in my view files, because there are people in my team who dont know it.
The problem is that I have no possibility to create a if-statement.
I want to use somethin like this:
{if " displayName = 'TestUser' "} You are the user TestUser! {/if}
instead of this:

if ($displayName == 'TestUser') {
echo 'You are the user TestUser!';

Would be very happy if something like this will be implemented in the next version of CodeIgniter, or if someone could tell me how to do something like the above example without php.


You probably need a Template Library such as http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html and a template engine such as Smarty .


The project you send me above is outdated, so I tried to get Smarty to work. I found a project which could be very nice when it works, but it doesnt: https://github.com/Vheissu/Ci-Smarty.

narfbg commented Jan 23, 2013

There isn't a significant difference:

<? if ($displayName == 'TestUser') { ?>
You are the TestUser!
<? } ?>

Nevertheless, there are plans for the parser to become a driver for different templating systems: #217, #2158

@narfbg narfbg closed this Jan 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment