Prev | Current Page 543 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Instead,
pay particular attention to the fact that the layers are completely separated, and try to
understand how this is accomplished in the example.
Listing 19-2. Rendering a Smarty Template
// Reference the Smarty class library.
require("Smarty.class.php");
// Create a new instance of the Smarty class.
$smarty = new Smarty;
474 CHAPTER 19 ?–  T EMPLAT I NG WITH SMARTY
// Assign a few page variables.
$smarty->assign("pagetitle","Welcome to the Starship.");
$smarty->assign("name","Kirk");
// 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 interest has been piqued, let??™s move on to a more formal
introduction of Smarty.
Introducing Smarty
Smarty (http://smarty.php.net/) is PHP??™s ???unofficial official??? templating engine, as
you might infer from its URL. Smarty, authored by Andrei Zmievski and Monte Orte, is
released under the GNU Lesser General Public License (LGPL) (http://www.gnu.org/
copyleft/lesser.html), and is arguably the most popular and powerful PHP templating
engine.
Smarty offers a powerful array of features, many of which are discussed in this
chapter. Several of those features are highlighted here:
Powerful presentational logic: Smarty offers constructs capable of both conditionally
evaluating and iteratively processing data.


Pages:
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555