Quantcast

Smarty! A PHP Based Template Engine

Smarty is a well known template engine for PHP developments. Smarty’s main concern is to separate the core PHP code from the design layout and files, including CSS style sheets, actual HTML templates etc.

Smarty uses its own tags structure in the HTML pages and optimize the overall website speed and performance by utilizing its built-in cache. Smarty has a vast range of predefined tags to be used in HTML web page. It also allows us an expert PHP programmer to develop its plugin and call them when needed in the code.

Smarty is being used by several popular websites including Flickr, allthewebsites.org and thousands of other sites.

Smarty supports several high-level template programming features, including

  • Advanced caching of pages
  • if, elseif, else statements
  • Control flow statements, foreach
  • Functions – For example {html_select_date start_year=’-7′ end_year=’+7′}
  • Output filters
  • Variable modifiers – For example {$variable|nl2br}
  • Possibility to create own modifiers / functions / output filters

An HTML template with some basic Smarty tags would look like this:

The PHP code for the above Smarty Template would look like this:

Looking for a quality hosting service? here are a few I suggest.
BlueHost | HostGator | Media Temple
Admin
Admin
Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.