AskDefine | Define smarty

User Contributed Dictionary


Alternative spellings


  1. An obnoxiously clever or quick-witted person; a smart aleck

Related terms

Extensive Definition

Smarty is a web template system written in PHP. Smarty is primarily promoted as a tool for separation of concerns, which is a common design strategy for certain kinds of applications.
Smarty generates web content by the placement of special Smarty tags within a document. These tags are processed and substituted with other code.
Tags are directives for Smarty that are enclosed by template delimiters. These directives can be variables, denoted by a dollar sign ($), functions, or logical or control flow statements. Smarty allows PHP programmers to define functions that can be accessed using Smarty tags.
Smarty is intended to simplify compartmentalization, allowing the presentation of a web page to change separately from the back-end. Ideally, this eases the costs and efforts associated with software maintenance. Under successful application of this development strategy, designers are shielded from the back-end coding, and PHP programmers are shielded from the presentation coding.
Smarty supports several high-level template programming features, including:
  • Control flow statements, foreach
  • if, elseif, else
  • variable modifiers - For example
  • user created functions
  • mathematical evaluation within the template
along with other features. There are other template engines that also support these features. Smarty templates are often incorporated into existing PHP web applications to some extent. More often it is used where a web application or a website has a theme system built into it, where the templates can be changed from theme to theme.

Code example

Since Smarty separates PHP from HTML, you have two files:
In the business logic code you can configure Smarty to use this template:
define('SMARTY_DIR', 'smarty-2.6.9/' ); require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty(); $smarty->template_dir = './templates/'; $smarty->compile_dir = './templates/compile/'; $smarty->cache_dir = './templates/cache/'; $smarty->caching = false; $smarty->error_reporting = E_ALL; // LEAVE E_ALL DURING DEVELOPMENT $smarty->debugging = true;
$smarty->assign('title_text', 'TITLE: This is the Smarty basic example ...'); $smarty->assign('body_text', 'BODY: This is the message set using assign()');

Notes and references

External links

smarty in Catalan: Smarty
smarty in Danish: Smarty
smarty in German: Smarty
smarty in Estonian: Smarty
smarty in Spanish: Smarty
smarty in French: Smarty
smarty in Indonesian: Smarty
smarty in Italian: Smarty
smarty in Latvian: Smarty
smarty in Polish: Smarty
smarty in Portuguese: Smarty
smarty in Russian: Smarty
smarty in Serbian: Смарти
smarty in Finnish: Smarty
smarty in Vietnamese: Smarty
smarty in Chinese: Smarty

Synonyms, Antonyms and Related Words

boldface, brazenface, chutzpanik, hussy, know-it-all, malapert, minx, pup, puppy, saucebox, smart, smart aleck, smart-ass, smarty-pants, swaggerer, upstart, whippersnapper, wise guy, wise-ass, wiseacre, wisecracker, wisehead, wisenheimer
Privacy Policy, About Us, Terms and Conditions, Contact Us
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2
Material from Wikipedia, Wiktionary, Dict
Valid HTML 4.01 Strict, Valid CSS Level 2.1