Page 1 of 1

What is smarty?

Posted: Thu Nov 03, 2005 6:00 pm
by Luke
I would like to know what smarty is and what it is used for.

Posted: Thu Nov 03, 2005 6:20 pm
by timvw
Here is a pretty good source: http://smarty.php.net/.

Posted: Thu Nov 03, 2005 8:50 pm
by sweatje
Smarty is a template engine. The primary purpose is to allow you to separate presentation logic from appliction logic.

See also http://www.phpwact.org/pattern/template_view

Posted: Thu Nov 03, 2005 9:39 pm
by neophyte
In simple terms it would allow you to create template variables that get inserted into template files. Something like:

Code: Select all

<p>{$content}</p>
Which many perfer over:

Code: Select all

<?php echo $content ?>
That's a real simlified explanation....

See the smarty site for more details....

Posted: Fri Nov 04, 2005 5:05 am
by Sanoz0r
It allows you to completely seperate your HTML (presentation) from your PHP (logic). Results are cleaner readable code and the ability for a web designer (with no PHP knowledge) to change the HTML without any problems. You will now also be able to use a WYSIWYG editor (if really want to)

Posted: Sat Nov 05, 2005 10:58 am
by Jens
But be careful, since smarty provides strong template functionality!

For example, if you have some if conditions and/or nested loops in your template, it is not really designer friendly, even with smarty.

Smarty gives you only the possibility to seperate data logic from presentation logic. Thats a bit different from seperating pure, designer friendly HTML-Code from PHP-Code.

Just my two cents...

Regards
Jens

Posted: Sat Nov 05, 2005 12:30 pm
by foobar
Remember, Google is your friend. Search on Google before asking people.

Posted: Sat Nov 05, 2005 1:23 pm
by Sequalit
hey th anks for asknig this questions, i would have never known about smarty if it wernt for this guy... he just changed the way ill be programming my sites now =)