First Time Template Parser. Need an help. - 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: First Time Template Parser. Need an help. (/showthread.php?tid=15303) |
First Time Template Parser. Need an help. - El Forum - 01-31-2009 [eluser]daweb[/eluser] Hi everybody, it's first time I try to use the CI template parser class. It seems it works fine for me, but... I have a question, hope a studip question: I have this array: Code: Array ( [path] => www.example.com And in my view: Code: {entry_details} It's works fine when I have a result, but when the array is empty I would want to do not print anything. But it prints {entry_details}... What's the best way? Thank you! First Time Template Parser. Need an help. - El Forum - 01-31-2009 [eluser]roj[/eluser] It's writing out the value name as it hasn't found any reference of it. One way to overcome this would be to declare all the items in the array as (even as a NULL value) somewhere very early on in the code: possibly in the Controller __construct if it's specific to one controller or else using hooks if it's across the whole system. First Time Template Parser. Need an help. - El Forum - 01-31-2009 [eluser]daweb[/eluser] I'd try to set a "default value" to NULL, but it always return the {caption value} Maybe I missed something... First Time Template Parser. Need an help. - El Forum - 01-31-2009 [eluser]roj[/eluser] I've not actually tried this but try using simple empty values? Code: Array ( First Time Template Parser. Need an help. - El Forum - 02-02-2009 [eluser]daweb[/eluser] Ok, but... is it rigth to do that in the view, using the template parser class? Code: <div class="primary results"> First Time Template Parser. Need an help. - El Forum - 02-02-2009 [eluser]roj[/eluser] Well, you could use it that way or else to keep all logic out of view files you could put the <?php if($entries) : ?> in the controller and then have a view file for if there are results and another for if there are non. That way removing the problem of the variable names showing up altogether.... So you would then have Controller: Code: if ($entries) With a View file for search results Code: <div class="primary results"> And a view file for no search results Code: <div class="primary results"> By doing the above you'll keep all logic separate including the loading of the sidebar view... First Time Template Parser. Need an help. - El Forum - 02-03-2009 [eluser]daweb[/eluser] Right. Thank you so much. First Time Template Parser. Need an help. - El Forum - 02-03-2009 [eluser]roj[/eluser] Glad to help |