Search
User
Recommend this pageIf this page was useful to you, please recommend it to fellow websurfers:
Home > Scripts > Development Tools > Template Engines
Rating | |
---|---|
You may rate this script by simply clicking on the appropriate star (5 stars is the best rating).
|
|
Language | |
PHP | |
License | |
Smarty requires a web server running PHP 5.2 or greater.
When it comes to templating in PHP, there are basically two camps of thought. The first camp exclaims that “PHP is a template engine”. This approach simply mixes PHP code with HTML. Although this approach is fast from a pure script-execution point-of-view, many would argue that the PHP syntax is messy and difficult to maintain when mixed with presentation. PHP works well for programming, but not so well for templating.
The second camp exclaims that presentation should be void of all programming code, and instead use simple tags to indicate where application content is revealed. This approach is common with other template engines (and other programming languages), and is the approach that Smarty takes. The idea is to keep the templates focused squarely on presentation, void of application code, and with as little overhead as possible.
There are many benefits of separating PHP code from templates, some of which are:
Smarty:
No different than PHP being an abstraction layer on top of C to simplify development, Smarty is an abstraction layer on PHP to simplify template maintenance.
A common question: “Web designers have to learn a syntax anyways, why not PHP?” Of course web designers can learn PHP, and they may already be familiar with it. The issue isn’t their ability to learn PHP, it is about the maintenance of PHP mixed with HTML. tags are simpler, more intuitive, and less fragile than PHP statements. Templates also restrict what can be put in a template. PHP makes it too easy to add code into templates that doesn’t belong there. You could teach designers the rules of application design, but this should be unnecessary (now they are developers!). The PHP manual is intended for developers. Designers would only need a small fraction of this manual, and it doesn’t make it easier for them to find what they need. Smarty gives web designers exactly the tools they need, and gives developers fine-grained control over these tools. Numerous features are also available for presentation such as template inheritance, which maximizes template re-use and streamlines organization.
Although Smarty gives you the tools to make a clean separation of presentation from application code, it also gives you plenty of room to bend those rules. A poor implementation (i.e. injecting PHP in templates) will cause more problems than the presentation separation was meant to resolve. The documentation does a good job of indicating what things to watch out for.
Under the hood, Smarty compiles copies of the templates as PHP scripts. This way you get the benefits of both template tag syntax and the speed of PHP. Compilation happens once when each template is first invoked, and then the compiled versions are used from that point forward. Smarty takes care of this for you, so the template designer just edits the Smarty templates and never has to manage the compiled versions. This approach keeps the templates easy to maintain, and yet keeps execution times extremely fast. Since the compiled versions are PHP, op-code accelerators such as APC or ZendCache continue to work on the compiled scripts.
Template inheritance is new to Smarty 3, and it’s one of many great new features. Before template inheritance, we managed our templates in pieces such as header and footer templates. This organization lends itself to many problems that require some hoop-jumping, such as managing content within the header/footer on a per-page basis. With template inheritance, instead of including other templates we maintain our templates as single pages. We can then manipulate blocks of content within by inheriting them. This makes templates intuitive, efficient and easy to manage.
This label indicates that I could install the script without major problems and I could run the script without the need for major modifications to the original code (except for the usual configuration, of course). The label does, on the other hand, not indicate that scripts without this label would not work properly. The missing of the „tested & working“-label just indicates that I did not yet test these scripts.
This label indicates that the owner of this website uses this script / application for his own projects with success and satisfaction. This does, however, not indicate that these projects could not have been realized using other scripts / applications as well or that other scripts would not fit the demands of other projects as well or even better.
Smarty Smarty
23 August 2023, 11:54, by Amado ChitwoodPost writing is also a fun, if you be acquainted with after that you can write
otherwise it is complicated to write.
Feel free to surf to my site: viagra
Smarty Smarty
5 January, 20:38, by EttaHey there, I think your site might be having browser compatibility issues.
When I look at your blog site in Safari, it looks fine but
when opening in Internet Explorer, it has some overlapping.
I just wanted to give you a quick heads up! Other then that,
excellent blog!
Here is my blog post :: Click This Link (Brigida)
Smarty Smarty
11 January, 11:04, by RitaWhat’s up i am kavin, its my first time to commenting anyplace, when i read this piece of writing i thought
i could also make comment due to this brilliant article.
My web blog - his response; Geri,
Smarty Smarty
15 January, 22:21, by Osvaldo BoykinHi! Someone in my Myspace group shared this site with us so
I came to take a look. I’m definitely enjoying
the information. I’m book-marking and will be tweeting this to my followers!
Outstanding blog and amazing design and style.
Review my page - Going Here (Staci)
Smarty Smarty
22 January, 15:42, by Eloy BeichFor most recent news you have to go to see internet and on the web I
found this web page as a finest web page for latest updates.
Also visit my blog post :: have a peek at this website (Francesco)
Smarty Smarty
30 January, 10:21, by Phylliswhoah this weblog is fantastic i like reading your posts.
Keep up the good work! You understand, a lot of persons are looking around for this information, you can aid them greatly.
Feel free to surf to my web page :: look here (Elana)
Smarty Smarty
2 February, 17:13, by ElisabethI’d like to thank you for the efforts you have put in writing this website.
I’m hoping to view the same high-grade blog posts from you later
on as well. In truth, your creative writing abilities has motivated me to get my own, personal website now ;)
Here is my homepage - browse around this site; Flynn,
Smarty Smarty
2 February, 21:35, by MarcelinoWow, amazing blog layout! How lengthy have you been blogging for?
you made running a blog glance easy. The entire glance of your web site is fantastic, as well as the content material!
Take a look at my blog post ... pop over to this web-site (Muriel)
Smarty Smarty
6 February, 16:24, by JessikaIf some one needs to be updated with most up-to-date
technologies afterward he must be pay a quick visit this web
site and be up to date everyday.
My web page click this (Jessie)
Smarty Smarty
6 February, 18:03, by DanteThanks for sharing your thoughts about Continue. Regards
Also visit my site: website link (Reta)
Smarty Smarty
9 February, 05:51, by DeniceWow, that’s what I was exploring for, what a material! present here at this website,
thanks admin of this website.
Here is my web-site; this page (city-wiki.win)
Smarty Smarty
9 February, 08:28, by HelenI for all time emailed this web site post page to all my friends,
because if like to read it next my contacts will too.
Feel free to visit my website - hop over to here [Sallie]
Smarty Smarty
9 February, 10:41, by CheryleAhaa, its nice dialogue regarding this piece of writing at this place at this website, I have read all
that, so now me also commenting at this place.
Also visit my web page: directory (mag-wiki.win)
Smarty Smarty
12 February, 19:26, by Dollie Bunburyall the time i used to read smaller content which also clear their motive,
and that is also happening with this article which I am reading at this time.
Visit my web blog ... directory; Caitlyn,
Smarty Smarty
12 February, 22:38, by GonzaloHello everybody, here every person is sharing these knowledge, thus it’s pleasant to read this
webpage, and I used to visit this webpage every day.
Here is my page - click here now (Elinor)
Smarty Smarty
6 March, 17:16, by TiffaniI feel this is among the so much important information for me.
And i’m satisfied reading your article. However want to statement on some basic issues, The web site style
is perfect, the articles is actually excellent : D. Just
right process, cheers
My page visite site (Melanie)
Smarty Smarty
25 March, 06:31, by Melanie HansfordHey there just wanted to give you a quick heads up and let you know a few of the images aren’t loading properly.
I’m not sure why but I think its a linking issue.
I’ve tried it in two different internet browsers and both show the
same results.
Review my web page ... additional hints (securityguardagency0.blogspot.com)
Smarty Smarty
26 March, 09:26, by Tommy CremorYou should take part in a contest for one of the best blogs on the web.
I will highly recommend this website!
Feel free to visit my web page this link