Page 1 of 1
how to use smarty ??
Posted: Mon Feb 26, 2007 11:22 am
by PHPycho
Hello forum
I am totally new to Smarty..
But i had read the tutorials and understood the basic concepts of smarty
What i want to know ?
How to use the smarty effectively?
Basic conderation that should be made ?
Basic setup files that should be made ?
etc. etc.
can anybody help me with the neccessary code ?
Thanks in advance to all of you !!
Posted: Mon Feb 26, 2007 11:55 am
by evilmonkey
Basic considerations:
-Keep coding and design seperate. Try not to even use smarty functions such as conditions and loops (use them sparingly and only if you really have to)
-Try not to assign too many variables to smarty...arrays are better suited for the purpose. It keeps your code much cleaner. Related information should be in arrays anyway, for example, $age, $weight, $height = bad coding, $user['age'], $user['weight'], $user['height'] = good, then all you have to do is smarty->assign('user', $user) and to access it in your template, it's {user.age} or {user.weight} etc.
As for code, you'd have to give us context.

What have you tried? What's not working? What are you trying to achieve? Good luck!
Posted: Mon Feb 26, 2007 1:20 pm
by PHPycho
Try not to even use smarty functions such as conditions and loops (use them sparingly and only if you really have to)
Try not to assign too many variables to smarty...arrays are better suited for the purpose.
How come we can displays the values in arrays without using loops ?
Whats the problems to use smarty loops ? whats the solution to get the values in arrays without using smarty loops ?
Please Help !!
Posted: Mon Feb 26, 2007 1:27 pm
by jayshields
evilmonkey has already answered all that for you.
Posted: Mon Feb 26, 2007 2:22 pm
by PHPycho
Pardon me !!
I didnt get the answer..
would you not mind telling the answer
Thank you!!
Posted: Mon Feb 26, 2007 2:45 pm
by Begby
evilmonkey wrote: and to access it in your template, it's {user.age} or {user.weight} etc.