![]() |
Template Parser, if statement? - 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 Parser, if statement? (/showthread.php?tid=25537) |
Template Parser, if statement? - El Forum - 12-15-2009 [eluser]mikepuerto[/eluser] Hello, Let me start out by saying I'm new here ![]() I'm using the template parser with data from mysql. Some columns may or may not be null... My question is, is there a way to check if the var is empty without using regular php? for example, with foreach I know I can use: Code: {result} I'm trying to get around outputting a bunch of empty html tags for columns that are null, while keeping the view files as clean as possible. Thanks, Mike Template Parser, if statement? - El Forum - 12-15-2009 [eluser]kilishan[/eluser] Welcome to CI! First question I would have is are you sure you need to use the Template Parser? If you don't really need it (like for working with designers who you're afraid might accidentally break it) then I would just go with straight PHP for the entire page. It's less resource-intensive and will perform faster. Template Parser, if statement? - El Forum - 12-16-2009 [eluser]saidai jagan[/eluser] In smarty, Code: {if $result_arr|count > 0} Template Parser, if statement? - El Forum - 12-16-2009 [eluser]Phil Sturgeon[/eluser] If you really must, here is one way. You could always try using Dwoo for your CodeIgniter views? It is similar to Smarty, but much quicker seamlessly integrates with the Parser class. Template Parser, if statement? - El Forum - 12-16-2009 [eluser]mikepuerto[/eluser] @kilishan - Yes, I def need some sort of Template Parser... I will be having designers work on it ![]() @saidai - smarty would be nice... i just feel that it's a bit too much for the project... @phil - After taking a look at the second option... I'm going to give that a try! Thanks! Template Parser, if statement? - El Forum - 12-16-2009 [eluser]mikepuerto[/eluser] EDIT: Nevermind! I didn't realize I needed to add dollar signs to my views... thx ![]() @phil - I'm trying to use your dwoo implementation but am a little stuck... this works fine: Code: $this->parser->parse('dwoo_test', array('message' => 'OH HAI!')); Code: $data = array( i get the following error: Code: Fatal error: Uncaught exception 'Dwoo_Exception' with message 'Plugin <em>search_terms</em> can not be found, maybe you forgot to bind it if it's a custom plugin ?' what am i doing wrong? Template Parser, if statement? - El Forum - 12-17-2009 [eluser]Phil Sturgeon[/eluser] Are you using the correct Dwoo syntax? {search_terms} will break, but {$search_terms} will work fine. Dont forget the $ at the start. :-) Template Parser, if statement? - El Forum - 12-18-2009 [eluser]mikepuerto[/eluser] Yeah, I figured it out ![]() One more Question though... Is there something special I need to do to use: Code: {extends "main_view"} Code: $this->parser->parse('some_view', $data); Thanks again! |