What is 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
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

What is smarty?

Post by Luke »

I would like to know what smarty is and what it is used for.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Here is a pretty good source: http://smarty.php.net/.
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post 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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post 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....
Sanoz0r
Forum Newbie
Posts: 3
Joined: Thu Nov 03, 2005 10:20 am
Location: Cape Town, South Africa

Post 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)
Jens
Forum Newbie
Posts: 2
Joined: Sat Nov 05, 2005 10:35 am

Post 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
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Remember, Google is your friend. Search on Google before asking people.
Sequalit
Forum Commoner
Posts: 75
Joined: Wed Oct 12, 2005 9:57 pm
Location: Texas

Post 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 =)
Post Reply