how to use smarty ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

how to use smarty ??

Post 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 !!
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post 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!
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post 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 !!
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

evilmonkey has already answered all that for you.
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

Pardon me !!
I didnt get the answer..
would you not mind telling the answer
Thank you!!
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

evilmonkey wrote: and to access it in your template, it's {user.age} or {user.weight} etc.
Post Reply