Installation Wiki

Smarty

From InstallationWiki

Jump to: navigation, search
Smarty
Official Page
Project Documentation
Download
Source Book
Smarty PHP Template Programming and Applications
Smarty PHP Template Programming and Applications
ISBN 978-1-904811-40-4
Publisher Packt Publishing
Author(s) Joao Prado Maia, Lucian Gheorghe, Hasin Hayder

There is a long time since websites are past the level of presenting summary and contact data for companies and projects. With the evolution of the internet, most websites are now stand-alone businesses rather than summary presentations of companies. More than that, complex applications developers embraced the idea of using websites as interfaces for their software.

For more than 10 years, PHP has been one of the best choices for web developers being the most complete open-source web programming language. With growth of the complexity of PHP applications a new problem was raised How to separate programmers code (PHP) from designers (HTML), or, better phrased How to separate the content from presentation.

From this problem, Smarty was born as being a PHP template system.

Contents

[edit] What are templating systems?

The basic functionality of a templating system is that they introduce a way of separating presentation from content with very little interactions between programmers and designers.

For example the design of a website may look like this:

The designers build the face of the website with pictures, text styles, tables, etc They build templates for how to arrange the content in each page.

Everything the designers need to know is that the site must look like this and that they needs to lay out some content like news, products, jokes, etc

On the other hand, programmers code the application using PHP to do data manipulation (business logic). They are not interested in how the website looks (colors, pictures, text styles) or where the content is laid out on the page. All they need to do is pass the content to the templates using variable names they agree upon with the designers.

This is, in rough lines how template systems work. Starting from this basic functionality, every template system has a set of features that make both designers and programmers life easier as long as they are well documented in the template System they use.

This article is intended to show you how to use all Smarty's features in the most optimum way we are using it.

[edit] Why use a templating system?

Building a web site is no different than creating any types of software. It can be done by building it from scratch, just start coding away, see what you can come up with and solve the problems on the way, or by differentiating the projects components into separate layers and build the web site taking in consideration these layers. This is called multi-tier or multi-level software architecture. If the web site is a small one containing only a few lines of PHP code, the first option might work. Just create a few tables in a database, start coding with PHP, maybe create a few banners, generate a few tables and debug every step people like it fast and easy.

Now, when it comes to much complicated web based projects such as web portals, e-commerce sites, ERPs, etc, the first option may work in some cases, but in most cases it can very difficult to achieve anything by coding away. Besides, with the market so crowded with web projects, in order for your web site to stand a chance, you have to have a great layout adapted for the type of project you are building and of course, a stable code tested in all situations. Thats why people involved in building web sites specialized themselves either in designing great layouts (web designers) or in programming very well (web programmers). Not often you can see a good web programmer creating great designs, or a good web designer writing good, bug-free code.

A software company which creates web sites usually has a designers department and a programmer department, and in most medium to large web projects theres always a programmer and a designer working on it.

Programmers have different ways of coding applications and, using PHP only without a template engine, the designer must be familiar with every programmers way of arranging the code, naming variables, etc Also, the programmer must understand the designers templates and generate the code to print HTML code from PHP where the designer wanted.

Lets take the following example:

for ( $col = 1; $col < $i; $col++ ) {
 print "<tr> <td> $procesid[$col]</td> <td>$data[$col] </td> <td>$value[$col]</td>";

This is a PHP syntax that prints in a table the values of 3 arrays. Even a simple example like this one is hard to read and to arrange in a webpage exactly like it was desired.

With Smarty, the PHP syntax doesnt contain print, instead, the programmer passes those arrays to the designer by assigning them to Smarty templates. After that, its the designers job to make them look good in the web page without worrying about the PHP code. This is one big benefit about using Smarty, and we will learn in this article how all this is done.

[edit] The Smartness of Smarty

Smarty allows designers and programmers to interoperate more effectively, not worrying about each others work. The designer builds the templates for the webpage layout and extracts the data from the PHP files the programmer created. The programmer passes data to the templates without having to generate html code. This way, everyone is happy and more efficient because they all do the job they are good at.

Lets think about an e-commerce site that sells laptop computers. The manufacturer, the laptops name, characteristics and price are content elements that will be displayed to the visitor and are contained in a database.

Using Smarty, both the designer's and the programmer's job becomes much easier.

The Programmers tasks:

Extract database elements with a simple query on the database

Validate and manipulate the data by performing business logic on it (apply discounts for example)

Change the data access and the business logic without interfering with the designers work for example, the whole system could migrate from mySQL to PostgreSQL without the designer making a single change.

The Designers tasks:

Create HTML designs without affecting or risking the programmers PHP code. The designer only needs to be concerned with placing the content elements that the programmer has agreed to provide.

Make changes to the design without consulting or interfering with the programmer's work

Not worry that technical changes to the site will break the way that the site appears to viewers

In the above example, we see that tasks are assigned to people involved in the project depending on the parts they are working at Presentation, Business and Data access.

Lets have a look at the process of building software applications, including websites, using a multi-tier architecture.

[edit] A rough guide to the software design process

The process of building a web site involves a few steps that may vary from project to project, but generally they fit for most projects.

The first step is to establish the customer needs, on which you design a database. These needs are later transcribed in a document or in a spoken agreement (preferably a document)..The document contains a description of the desired functionality of the software as well as the database tables with explanations for every column. Once the customer agrees on this document and maybe makes a few changes, you can start the actual process of building the web site.

If you are your own customer this is not the case, else it is my strong opinion that you should do this. At one of my first projects, I skipped the document part and it was a total fiasco. The customer kept wanting more and more and did not want to pay more for that, but if the document had existed he would have had no choice.

The next step would be to create and show a few layouts to the customer. This is the designers job. He will work with the customer and come with a design that the customer will like. After the customer chose the design, the actual building of the web site begins. When the project is finished, the customer has a testing period in which a few modifications are made or some bugs cleared, and its done.

This is beautiful in theory, but in real life, while programmers speak languages like PHP and SQL and designers speak the tongue of HTML and CSS they often tend to have a few differences.

[edit] Working in teams: Layers and Separation of Concerns

When human interactions might fail, its preferable to separate their work as much as possible. Using a multi-tier software architecture may do the job. The most commonly used architecture is the one with three tiers or layers. These are:

  • Presentation Logic Layer
  • Business Logic Layer
  • Data Access Layer

Separating these layers in project development cycles allows you to achieve rapid application development with project maintainability in mind.

On the three-tier architecture, the interaction between layers is shown in the following diagram:

Starting from the bottom, at the Data Access Layer we find both the data and the ways to extract the data that we want to show to the user. The Data Access Layer may contain:

  • A database (MySQL, PostgreSQL, MSSQL, etc). The SQL language used to extract data from the database is also found at the Data Access Layer
  • Files which store data and PHP functions (or other languages) that parse the files
  • Data acquisition software (e.g a thermometer on the parallel port)

Now that weve extracted the data, we need to manipulate it in order to get the results we need to display. Data manipulation and validation is done at the Business Logic Layer, which may contain:

  • Data validation based on the business plan (e.g. list only in-stock items)
  • Data manipulation according to the business plan (e.g. discounts, stock liquidations, etc)
  • Functions and formulas to calculate things like shipping expenses, etc

The webpage layout, how data from the Business Logic Layer is arranged in the webpage is the Presentation Logic Layer which contains:

  • Web page templates
  • Text/CSS styles
  • Images, Banners, menu styles

Without a templating engine, at the Presentation Logic Layer we find HTML and PHP, creating the layout with pure HTML and generating HTML code from PHP. In this case, we cannot divide the Presentation Logic and Business Logic layers into two separate layers, making the work of designers and programmers very difficult for complex software projects. Thats where Smarty comes in.

[edit] Smarty The ultimate templating system for PHP

Now that weve decided to make our life easier by considering a multi-tier architecture for our web site, we should take a look at what Smarty can do and at what it cant do for us.

Smarty was not built for separating HTML from PHP, instead, its primary goal is to separate the application logic from presentation logic. If Smarty's goal was to separate PHP from HTML then the presentation layer would contain no logic, but Smarty templates can contain logic, as long as it is for presentation only.

This may seem like it breaks the rules of rigid separation between layers and tasks, but there are good practical reasons for it. A simple example would be an e-commerce site with products displayed in four columns:

  • Fist case: If our presentation layer doesnt contain logic, we need to modify the business logic to retrieve the products in four arrays.
  • With Smarty: using logic in the templates, the programmer just passes the products to the templates in a single array and the designer arranges the products in the page as he desires.

Smarty offers an interface to pretty much all of PHP, so PHP can be included in the templates, but its recommended to leave the most of PHP code at the business logic layer. Fortunately Smarty's logic is generally much simpler to use than PHP and designers do not need to become programmers in order to incorporate presentation logic into their Smarty designs.

[edit] Is Smarty fast ?

Template systems introduce another level of processing in the application, so we might suspect that Smarty applications will runs slower than plain PHP equivalents. Basically, we have a new pseudo-scripting language (the template engines tags) inside our scripting language (PHP).

Smarty is extremely fast by doing what they call template compiling. That means that it reads the templates, creates PHP scripts from them and includes the PHP files, resulting a single PHP script that is compiled by the PHP engine which is pretty fast. The beauty of the process is that the templates are parsed only once by Smarty, and only the templates that were modified are compiled again. This is done automatically by Smarty and results in a fast compilation done by the PHP engine with very little overhead from Smarty.

If we concern about the performance of our site, Smarty has a built-in caching support that can speed thing up quite a lot, especially on websites that have content which is not modified very often. You can cache all the content of a webpage or only some of it and you can specify for how long Smarty should keep the content cached.

Since Smarty does template compiling resulting in a PHP script, there is no reason why we should not use a PHP compiler cache solution like Zend Cache or PHP Accelerator.

PHP Accelerator or Zend Cache have no problem with Smartys output and caches the PHP scripts produced by Smarty very well, so if our main concern is performance we should use one of the two caching solutions combined with Smartys built-in caching support.

[edit] Is Smarty secure ?

We came to the conclusion that Smarty is fast, but we need to know about its security which I think is the most important thing at a web site.

By default, using Smarty you are theoretically as secure as you are when using PHP only. This means that by using Smarty you cant be less secure than using PHP only, but Smarty has some features to improve security in case it is needed.

When a site is built by a programmer working with a designer, without using Smarty the designer has access to the application and it can modify all the PHP scripts. This is certainly not good for security, because a designer with bad intentions can breach the security of the system very easily when he has all the power of PHP in his hands.

Smarty comes with some built-in security features for situations when untrusted parties edit templates. When security is set on templates, a designer that modifies templates via an unsecured connection like ftp is unlikely to gain access in the system.

Using Smarty security features, you can:

  • Allow or Deny usage of PHP code in the templates
  • Allow only a set of PHP functions as variable modifiers
  • Restrict the folders from which templates can be included
  • Restrict the folders from which local files can be fetched by templates

My strong advice is to always think about security. Think about having a database with credit cards and your designer includes unsafe PHP code in one webpage. This will result in a disaster for your business.

[edit] Smartys main features

Smarty offers both designers and programmers tools to optimise their work in order to achieve better performance and minimize their work. Reading this entire book you will find out all about those wonderful features and hopefully you will see how great Smarty is. Lets preview some of this features and some of the reasons they should or should not be used.

[edit] Filters

Disciplined designers may write a lot of comments in their templates, resulting after the compilation a big file. Smartys developers thought about this and included a set of filters to solve this problem. Smarty has prefilters which are PHP functions that the templates are ran through before they are compiled. With prefilters you can modify anything in the templates before template compiling, so if you want to remove all the comments you can simply do that with a prefilter.

However, if you want to add some comments to the compiled templates you can do that with postfilters. Smartys postfilters are PHP functions that the templates are ran through after they are compiled.

You can also filter out the content of a template by using output filters, which are PHP functions used for filtering the output of a template when it is executed, for example replacing banned words with *, hiding email addresses, etc With these powerful filters, the programmer has complete control of the templates.


[edit] Variable modifiers

When displaying content on a website, we might want to change some of it from time to time or depending on visitors origin. For example, we might want to show a date in different formats. Using Smarty, theres no need for the programmers intervention on this. He will just pass the date in the proper variable to the template, and the designer can format the date however he desires.

Also, the designer can up-case or low-case a variable, truncate a text block, add spaces between characters, etc. and its all done at display-time with Smarty.

Think about displaying a product category like a small title in upper case and with spaces between the words characters (eg. C A R S). In the database, the corresponding column contains the word cars. With Smarty you dont have to ask the designer to change it to C A R S when he passes the variable to the template, you can do that with proper variable modifiers at display-time, and again, if you want to modify the way you display the product category later (eg. Cars) this doesnt require the programmers intervention.


[edit] Template functions

When going through Smartys syntax you will discover another great thing about Smarty: template functions. Think about designing a large form with many HTML drop-downs. The old fashioned way to do this is to write tags for every drop-down menu. With Smarty you can simply write a function for drop-downs and call it every time you need to display one, making things simpler and faster. This was an easy example, but you can save a lot of time writing functions for displaying content in some manners you repeat frequently.


[edit] Plug-ins

One very important thing for a business in creating software is the possibility to reuse code. This saves time and money when new projects are built that contain functionality related to other projects created before, and this is what really makes a software business profitable. Using code from one application to another with copy & paste requires modification of variables, function names, retesting and careful integration with the new application, but is faster rather than rewriting the piece of code.

However, there is a better method for reusing code using Plug-ins. When building a site keep in mind functionality that can be reused even in the same project and create them as plug-ins. This way, after building a few sites, you will have a portfolio of plug-ins that run well and can be included without modifications in any new project saving a lot of time and work. For doing this, we need to have plug-in support in the software that we use to build our project.

Smarty has a plug-in architecture that is used for most of its customizable functionality. With Smarty, you can write plug-ins for functions, compiler functions, block functions, modifiers, resources, inserts, prefilters, postfilters and outfilters.

A lot of software out there with plugin architecture loads all plugins before compiling. This is not necessarily wrong, but Smartys designers kept performance in mind and made the plug-ins load only when they are invoked in a template. More than that, a plug-in invoked once in a template is only loaded once, even if there are more instances of Smarty requesting the same plug-in.

For example, when creating an e-commerce site, you can create plug-ins for the shopping basket functionality or filters for currency conversion that you can use later in other e-commerce projects you build, without having to write the same code again but being paid similar amounts of money.

[edit] Debugging

At every step of building a software application, programmers and designers need debugging to easily correct their work.

Think how much time you can loose if you misspell a variable and you dont have debugging tools. In my experience as programmer, thats the worst scenario, even worst than having mistakes in your algorithm.

Even if you can debug with PHP, Smarty provides a debugging console for correcting Smarty-related errors. This is a very powerful debugging tool, as you are informed of all the included templates, assigned variables and configuration file variables for the current template.

With Smarty you can modify the format of the debugging console, so you can highlight the things you find important in debugging. Also, you can dump the output of the debugging console to the page using a Smarty function in the template, but since Smartys functions are executed at runtime, you can only see the variables involved not the templates included


[edit] Smarty alternatives

For most people, Smarty is the natural choice of PHP templating systems mainly for its popularity. As you probably know, Smarty is not the only PHP template engine on the market, but it is the most complete and reliable that exists up to today.

From the variety of PHP template engines, we would metion the following:

PHP Savant - http://phpsavant.com/yawiki/

PHPlib - http://phplib.sourceforge.net/

Yats - http://yats.sourceforge.net/

FastTemplate - http://www.thewebmasters.net/php/FastTemplate.phtml

SimpleTemplate - http://simplet.sourceforge.net/

patTemplate - http://www.php-tools.de/site.php?file=/patTemplate/overview.xml

and many others http://www.sitepoint.com/forums/showthread.php?threadid=123769

Most of those PHP templating systems have a few advantages like speed and ease of use, mainly because they are not so complex as Smarty. However Smarty has more features than most of its competitors and it can be customized to be pretty fast.

In my opinion, the true competitor of Smarty is PHP Savant which is a powerful but lightweight object-oriented template system for PHP. There are a lot of similarities and differences between Smarty and Savant and Savant has a lot of Smartys features.

However, there is one big difference between the two that can be either an advantage or a big disadvantage for Savant, depending on which point of view you are looking at. The difference is that templates in Savant are written in PHP and not in other language like Smarty introduces. This can be:

  • An advantage for Savant Designers work with PHP as a template language, they dont have to learn another templating language
  • A disadvantage for Savant and a huge advantage for Smarty concerning security. Savant doesnt compile the templates into PHP as the templates themselves are PHP files. This way, designers have access to the full power of PHP. If the designer is not a trusted one Savant is out of the question and Smarty is the answer.

In most cases, designers are not trusted to have access to the systems where web pages run, therefore Smarty is still the best templating system for PHP. Savant is nice, but it almost totally lacks security while other template engines have only some parts of the functionality Smarty has. Smarty internals

From the designer point of view, Smarty is a new simple and powerful scripting language that can be used together with HTML to simplify the work with the programmer. Also, the new scripting language that Smarty introduces to designers offers them ways to simplify their work.

A very eloquent example to my previous statement would be the following syntax:

<select name="Employee">

{html_options options=$names}

</select>

The first and last lines are HTML but the line in the middle is Smarty. This line creates select options with values in the array $names which is received from the programmer. This way, the designer only has to ask the programmer to pass employee names in an array named $names (minimum interaction). Instead of writing <option></option> a lot of times, the designer uses a Smarty function which simplify its work.

Instead of placing the example above in a HTML file, the designer places it in a file with the .tpl extension and tells the programmer the full name of the template (.tpl) file.

This book has a section called Smarty for Designers in which designers will learn this new scripting language with useful examples, tips and tricks from the authors experience.

From the programmer point of view, Smarty is a large PHP class with variables and methods. The name of the class is Smarty so to assign a Smarty class variable, the programmer must do:

$smarty = new Smarty;

The Smarty class offers programmers more efficient ways of interacting with designers. For example, the designer requested all employee names in a variable named $names. After extracting the names from the database in an array, the programmer passes those to the designer as simple as:

$smarty->assign(names,$names_array);

For the programmer, one of the best things about Smarty is that theres no need to have HTML code in the PHP files. HTML code is in the .tpl files which are displayed using one of the Smarty class methods:

$smarty->display(index.tpl);

The second section of this book is called Smarty for Programmers. By reading this section, programmers will learn about the Smarty class and how to use it in the best ways the authors do.

[edit] Installing and configuring Smarty

Smarty is distributed under the GNU Lesser General Public License, which is the successor for the GNU Library General Public License. The difference between the Lesser GPL and the old Library GPL is that the software is less protected in the Lesser GPL, meaning that the libraries distributed under this license are free software and can be used to create commercial software. The old Library GPL allows you to use the software distributed under its license only to create free software.

The point is that Smarty is a free tool, and we can create commercial software using Smarty without paying for it.

If you want to make sure you are 100% legal, you can read the entire Lesser General Public License at http://www.gnu.org/copyleft/lesser.html

Step 1. Obtaining Smarty

You can download the latest stable Smarty source code from Smartys website at http://smarty.php.net/download.php. Always make sure to download the latest release because it contains bugfixes for all the previous versions.

Smarty is in fact a library for PHP and its requirements are very simple: a WebServer with PHP 4.0.6 or later. Apache can be used as a web server since its the most popular choice, but its not the only one. Instructions on installing apache can be found at http://www.apache.org.

After downloading Smarty from the web server and uncompressing the archive, we have a folder with the current Smarty distribution. In the distribution root you will find a folder named libs which contains the following files and folders:

Smarty.class.php
Smarty_Compiler.class.php
Config_File.class.php
debug.tpl
\internals
\plugins

All these files are needed to run Smarty applications and the PHP files are not to be edited.

Step 2. Configure PHP to find the Smarty libraries

The simple method of installing Smarty is to add the libs folder path to the include path in the php.ini file. On Windows

For example, lets say youve extracted the distribution of Smarty you downloaded in C:\Smarty.

Just edit the php.ini file and add include_path = ".;c:\php\includes;c:\Smarty\libs and its all set. You can also copy the libs folder to any location of the include_path in php.ini if you dont want to edit the file. For instance, php.ini has the default include_path = ".;c:\php\includes so you can just copy the libs folder content to C:\php\includes. On Linux

For example, lets say youve extracted the distribution of Smarty you downloaded in /usr/local/Smarty.

Just edit the php.ini file and add include_path = ".:/usr/local/Smarty/libs and its all set. You can also copy the libs folder to any location of the include_path in php.ini if you dont want to edit the file.

This is the easiest way to install Smarty. The point is that you need to load the Smarty.class.php file in every PHP file that uses Smarty templates,`so if you have it in one folder of the PHP include path, you can create a Smarty instance it by:

<?php
require(Smarty.class.php);
$smarty = new Smarty;
?>

[edit] An alternative to step 2, using Smarty without having full access to the system

If you dont have access to modify the php.ini file or to copy Smarty libs in one of the folders of the php include_path, you can still use Smarty by setting the Smarty libs directory in the PHP files that use Smarty.

Smarty uses a PHP constant called SMARTY_DIR, which doesnt need to be set in the first case when you edit the php.ini file to include the Smarty libs. However, you can manually set the SMARTY_DIR to point the path for the Smarty libs.

For Windows:

<?php
define(SMARTY_DIR, C:\Smarty\libs);
require(SMARTY_DIR . Smarty.class.php);
$smarty = new Smarty;
?>

For Linux:

<?php
define(SMARTY_DIR, /usr/local/Smarty/libs);
require(SMARTY_DIR . Smarty.class.php);
$smarty = new Smarty;
?>

Note: Since there are so many ways of using Smarty, in this book, we will assume that you included the libs folder from Smartys distribution root in the PHP include path.

Step 3. Set up Smarty for your application

After we are sure that we can find the Smarty.class.php file we need to set up the folders for our application. Every Smarty application needs 4 folders which are named by default:

  • templates
  • templates_c
  • configs
  • cache

Each of these folders can be defined by the Smarty class proprieties $template_dir, $compile_dir, $config_dir and $cache_dir. Every Smarty application should have its own folders.

Linux special notes:

Smarty needs write access to the $compile_dir and $cache_dir, so we have to allow the web server user write access to those folders. Look at the httpd.conf (Apache web server configuration) file and see the user and group used to run apache. Usually the user and group is nobody, so I will use it in my example. Lets say we have the document root of our web server in /www/htdocs. We need to set the file permissions of /www/htdocs/templates_c and /www/htdocs/cache to allow write access for user nobody.

chown nobody:nobody /www/htdocs/templates_c
chown nobody.nobody /www/htdocs/cache
chmod 770 /www/hdocs/templates_c
chmod 770 /www/htdocs/cache

Note: chmod 770 is equal to chmod ug+xrw,o-xrw that means no access for other users. If you want to see the content of the folders without being root chmod 775 which is equivalent to chmod ug+xrw,o+xr-w

Step 4. Verifying the installation

To make sure the installation works, copy the demo folder from Smarty distribution root to the document root of your web server (e.g. c:\Program Files\Apache2\htdocs), edit the index.php file to make sure you have require(Smarty.class.php); and type http://localhost/demo/index.php in your web browser. You should see a demo page with some of Smartys capabilities and the debugging console. Make sure your browser allows pop-ups.

[edit] Smarty development versions on CVS

By the way, if you want to play with features in development for future versions of smarty, then the PHP CVS server hosts the latest version of Smarty (the unstable one) and most of the old releases. CVS can be downloaded via web at https://ccvs.cvshome.org/servlets/ProjectDocumentList.

To download Smarty from the PHP CVS server, first you have to login into the server with the command:

cvs -d :pserver:cvsread@cvs.php.net:/repository 

login using phpfi as password.

To download the current Smarty tree just type:

cvs -d :pserver:cvsread@cvs.php.net:/repository co smarty

or any stable version of Smarty by using the following command:

cvs -d :pserver:cvsread@cvs.php.net:/repository co -r Smarty_X_X_X smarty

where X_Y_Z is the corresponding version number, for instance using Smarty_2_6_10 in the above command line will download Smarty release 2.6.10 in the smarty folder.

Important: Using the current Smarty distribution from the PHP CVS server in production is not recommended at all. It is an unstable version used for development and if you want to use Smarty for building web sites you should use the latest stable version.

[edit] Upgrading a Smarty site

Smarty is backward-compatible, so when you need to upgrade a Smarty site all you need to do is:

  • Get the latest Smarty distribution as described earlier in Obtaining Smarty
  • Replace the old content of the libs folder where you installed it with the content of the libs from the new distributions root
  • Make sure you don't have the old file Smarty.class.php in any other PHP include path

[edit] Summary

I will try to summarize what we have learned from this tutorial:

  • Using a multi-tier software architecture makes our life easier
  • Smartys objective is to separate the Business Logic from the Application Logic
  • Smarty is fast and secure because of the way templates are parsed: template compiling
  • Smarty has prefilters, postfilters and output filters giving the programmer complete control of template output and content
  • By creating resource handles you can use templates from any source you can access with PHP
  • Smarty has a plugin architecture so you can use plugins for most of its functionality
  • Smarty includes a very powerful debugging tool
  • Installing Smarty on Windows and Linux

[edit] Additional References

  • For instructions on Designing Smarty Templates, click here
  • For instructions on Debugging Smarty Templates, click here


[edit] Source

The source of this content is Chapter 1: Introduction to Smarty of Smarty PHP Template Programming and Applications by Joao Prado Maia, Lucian Gheorghe and Hasin Hayder (Packt Publishing, 2007).

[edit] Relevant Links

Smarty Website
Download Smarty