Template parser |
[eluser]Avril[/eluser]
Hello, I like that CI has a template parser, it gives a nice code overview when your passing your data to the view. Now I'm stuck with an array that I want to pass to the view by using the template parser off course . Here's my array code: Code: $data = array( The data in the $dates variables are from a Model. The output of that array: Code: Array This is the code in the Model: Code: function get_dates(){ I would like to pass it to the parser so that I can make 3 select drop-down, how can I do that? Anyone an idea? Thanks!
[eluser]Phil Sturgeon[/eluser]
You'll have to create the dropdowns in the controller and assign them to $data['month_dropdown'] which is horribly un-MVC. The CI Template Parser is really just for outputting simple tags and loops, you cannot use helper functions, maths, statements, etc.
[eluser]Avril[/eluser]
For the moment I did it like this, but it's really not "template friendly", but it does the trick: Code: <select name="day">
[eluser]Phil Sturgeon[/eluser]
Right, thats what most people end up doing. If you need stronger parsing then take a look at codeigniter-dwoo which will give you all the power of Dwoo in place of the CI Parser. Then you can use helper functions, do foreach, etc.
[eluser]Avril[/eluser]
Hmm, I'll try it out, is there some documentation? Or does it uses the same syntax as the usual parser?
[eluser]Avril[/eluser]
Ah okay, sorry I've never heard of Dwoo, so I didn't knew it |
Welcome Guest, Not a member yet? Register Sign In |