CodeIgniter Forums
Template system - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Template system (/showthread.php?tid=23100)



Template system - El Forum - 09-30-2009

[eluser]vtafsar[/eluser]
Hello,
Any one familiar with codeigniter template system ? I just want to know how to write a conditional structure on the template

Thanks.


Template system - El Forum - 10-01-2009

[eluser]Damien K.[/eluser]
You may want to RTFM...
http://ellislab.com/codeigniter/user-guide/


Template system - El Forum - 10-03-2009

[eluser]vtafsar[/eluser]
I saw template parser guide page, http://ellislab.com/codeigniter/user-guide/libraries/parser.html. But there is nothing about conditional structures.


Template system - El Forum - 10-03-2009

[eluser]John_Betong[/eluser]
[quote author="vtafsar" date="1254576713"]I saw template parser guide page, http://ellislab.com/codeigniter/user-guide/libraries/parser.html. But there is nothing about conditional structures.[/quote]
 
Perhaps there is nothing in the user guide about conditional structures because it should not be there.

As far as I understand MVC then the template is similar to a view. If so then the purpose of a view is to display data. The data is processed (maybe wih a little help from a model) and the data output is then sent to the view.
 
 
 


Template system - El Forum - 10-03-2009

[eluser]Jondolar[/eluser]
Conditional statements definitely belong in the view (i.e. template). They are view logic, not business logic.

Wrap your section of html code with a pseudo-variable such as:
{blog_entries}
html bla bla bla
{/blog_entries}

If you do not want the above to display then create your data array with an empty array element called $data['blog_entries'] = array();

This will remove the entry since there are no elements in the array.

Good luck with your project.


Template system - El Forum - 10-03-2009

[eluser]Colin Williams[/eluser]
Use a more robust template system, like Smarty