How to use loops in smarty template engine ? |
[eluser]Mr.SoOoMa[/eluser]
Hello there , When i was programming with the normal PHP without any MVC system, i was using while loops to show the results in smarty templates (with sections). but now i'm using CI and i don't know how to print the loop in the templates, i'm using library which helps me to use smarty with CI, so how can i use the loops in smarty to show the result? i tried : Code: $query=$this->db->get('settings'); and the template is : Code: <ul> but it didn't work but when i'm put Code: foreach ($query->result_array() as $row) in the model, it prints good .. but i want it to print in the template file not the model, cause i want to help users to change templates content so i can't put <div> for example in the model file i need to use templates to print the loop ..
[eluser]Mr.SoOoMa[/eluser]
+ how can i print the result directly without loops if i'm sure that the query gives me 1 result only ..
[eluser]Mr.SoOoMa[/eluser]
I tried this in the model : Code: $query=$this->db->get('settings'); and this is the template: Code: <ul> but still have error: Undefined index: query
[eluser]Aken[/eluser]
You're passing data to the view incorrectly. http://ellislab.com/codeigniter/user-gui...views.html You really need to take time to read through these manuals, because they answer all of the questions you have... I'm not going to help you every time you send me a private message.
[eluser]Mr.SoOoMa[/eluser]
I'm sorry it's working now, i have founded the solution .. sorry for making you angry |
Welcome Guest, Not a member yet? Register Sign In |