Smarty is a template system written in PHP. It separates the PHP code from the HTML layout.
Usage
The Smarty libraries are accessed via the wrapper class eaSmarty located in code/base/smarty.class.php. The wrapper provides not only basic set-up procedures, but also localization functionality.
The templates for the ea-Geier are stored in html/.
The localization data is stored in ini files in lang/de/ or lang/en/ respectively.
Example
A basic template (html/dummy.tpl):
{include file="dummy.ini"}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>{#fixedTextToBeLocalized#}</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body> {* This is a little comment that won't be visible in the HTML source *}
{$body_text}
</body><!-- this is a little comment that will be seen in the HTML source -->
</html>
An appropriate localization file (lang/en/dummy.ini)
fixedTextToBeLocalized=TITLE: This is the Smarty basic example ...
And its integration into PHP:
require_once('code/base/smarty.class.php')
$smarty = new eaSmarty();
$smarty->assign('body_text', 'BODY: This is the message set using assign()');
$smarty->display('html/dummy.tpl');
See the Reference Guide for a complete list of commands.
Extensions
In addition to the native Smarty functions the ea-Geier provides the following constructs:
- {eaInput} creates input fields with labeling, help text, error handling, etc.
- {eaSelect}{/eaSelect} creates selection fields with labeling, help text, error handling etc.
- {eaSubmitButton} creates submit buttons
- {eaURL} creates beautified links
Bundling
The Smarty library will be bundled with production releases.
But as 3rd-party product it will not be checked into the repository.
If the Smarty code is missing in your ea-Geier distribution, please download it from the Smarty homepage.
Unzip the code into the 3party/smarty/ folder – e.g.:
3party/smarty/Smarty-2.6.18/
and make sure the eaSMARTY_DIR definition is configured properly. To do this, open the the file code/config.php. Look for eaSMARTY_DIR and change the value to the name of the folder you have just uploaded – e.g.:
define('eaSMARTY_DIR', '3party/smarty/Smarty-2.6.18/');