11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.it-ebooks.infoCHAPTER 19 • TEMPLATING WITH SMARTYListing 19-2. Rendering a Smarty Template// Render and display the template.$smarty->display("index.tpl");As you can see, the implementation details are hidden from both the developer and the designer,allowing both to concentrate almost exclusively on building a great application. Now that your interesthas been piqued, let’s move on to a more formal introduction of Smarty.Introducing SmartySmarty (www.php.<strong>net</strong>) is authored by Andrei Zmievski and Monte Orte, is released under the GNU LesserGeneral Public License (LGPL) at www.gnu.org/copyleft/lesser.html, and is arguably the most popularand powerful <strong>PHP</strong> templating engine.Smarty offers a broad array of features, many of which are discussed in this chapter:Powerful presentational logic: Smarty offers constructs capable of bothconditionally evaluating and iteratively processing data. Although it is indeed alanguage unto itself, its syntax is such that a designer can quickly pick up on itwithout prior programming knowledge.Template compilation: To eliminate costly rendering overhead, Smarty converts itstemplates into comparable <strong>PHP</strong> scripts by default, resulting in a much fasterrendering upon subsequent calls. Smarty is also intelligent enough to recompile atemplate if its contents have changed.Caching: Smarty offers an optional feature for caching templates. Caching differsfrom compilation, in that caching prevents the respective logic from evenexecuting, instead just rendering the cached contents. For example, you candesignate a time-to-live for cached documents of, say, five minutes; during thattime database queries pertinent to that template are not executed.Highly configurable and extensible: Smarty’s object-oriented architecture allowsyou to modify and expand upon its default behavior. In addition, configurabilityhas been a design goal from the start, offering users great flexibility in customizingSmarty’s behavior through built-in methods and attributes.Secure: Smarty offers a number of features to shield the server and the applicationdata from potential compromise by the designer, intended or otherwise.389

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!