![]() |
Extended Parser functionality? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Extended Parser functionality? (/showthread.php?tid=23088) |
Extended Parser functionality? - El Forum - 09-29-2009 [eluser]fireproofsocks[/eluser] I like having a simple view, devoid of raw PHP, so I've been using the parser class. I'm new to CI, so I don't know if there are extensions to the parser's functionality? E.g. is there a way to track some basic variables when you've got a loop defined by {items} ... {/items} -- e.g. it'd be great to have a built-in variable that counted which item of the array you're on, e.g. {n}. It'd also be nice to tap into view-level filters, e.g. force a particular value to go through a function in the view layer. All of this is possible in raw PHP, of course, but I'd like to stay away from that if possible. Thanks. Extended Parser functionality? - El Forum - 09-29-2009 [eluser]Colin Williams[/eluser] You might want to look into using something more robust like Smarty. I don't see the point, though. Eventually, even with smarty, you end up with something that is close enough to PHP that you might as well just use <?php and go on with life... Extended Parser functionality? - El Forum - 09-29-2009 [eluser]moodh[/eluser] Even if it's "ugly" it might be warranted to keep the views clean, most of CI's templateclass can be sorted with a hack and a foreach before sending to the view: Code: <?php which means you can use the following in the parsed view: Code: {variables} With variables, loops and simple if-statements most things can be solved in the model (or controller) but it's of course more resource heavy, but sometimes nice views is actually worth it =) There's a few hacks to the parser class to allow multiple blocks of the same name (for example {is_logged_in} twice), and also some other various improvements, search abit and you'll find them! |