-
caching
...Cacheability of Plugins Custom Cache Implementation Caching is used to speed up ...
...URRENT); $smarty- display('index.tpl'); ? With caching enabled, the function cal...
... Chapter 15. Caching Chapter 15. Caching chapter, 15, caching Chapte...
...ith a timetable containing new information by the minute, it would not make sens...
...ing the front page of your website that does not change its content very often, ...
... 15. Caching Table of Contents Setting Up Caching Multiple Caches Per Page C...
-
preface
...d designers quick and easy to maintain syntax easy to understand, no PHP knowled...
... for application code, but quickly degenerates when mixed with HTML. Smarty's si...
... Preface Preface preface Preface Prev    Next Preface The Philosophy...
...ce Template inheritance is new to Smarty 3, and it's one of many great new featu...
...ices section of the Smarty website. How does it work? Under the hood, Smarty "co...
...these goals: clean separation of presentation from application code PHP backend,...
-
advanced.features.objects
...jects Smarty allows access to PHP objects through the templates. Note When you a...
...$myobj); $smarty- display('index.tpl'); ? And here's how to access your objects ...
...bjects Objects Prev  Chapter 17. Advanced Features  Next Objects S...
...is my meth1'; } } $myobj = new My_Object; // registering the object (will be by ...
...ices section of the Smarty website. There are two ways to access them. One way i...
...template are for presentation purposes only. It is very easy to inject applicati...
-
installing.smarty.basic
...are in the /libs/ sub directory of the distribution. These are .php files that y...
...com/ guestbook/ templates/ index.tpl templates_c/ configs/ cache/ htdocs/ index....
... Basic Installation Basic Installation basic, installation Basic Installation Pr...
...nged when you upgrade to a new version of Smarty. In the examples below the Smar...
... Basic Installation Basic Installation basic, installation Basic Installation Pr...
-
api.get.tags
...= $smarty- createTemplate('index.tpl'); // get tags $tags = $smarty- getTags($tp...
... getTags() getTags() gettags, getTags() Prev  Chapter 14. Smarty Class...
...rty.class.php'); $smarty = new Smarty; // create template object $tpl = $smarty-...
... used by template Description string getTags ( object template ); This f...
-
language.function.append
...lacing application logic into the presentation that may be better handled in PHP...
...a The value being assigned index string No n/a The index for the new array eleme...
... {append} {append} , ldelim, append, rdelim, {append} Prev  Chapter 7.Â...
...g No n/a The index for the new array element. If not specified the value is appe...
...er 7. Built-in Functions  Next {append} {append} is used for creating ...
-
variable.default.resource.type
... smarty what resource type to use implicitly. The default value is file , meanin...
...ing that $smarty- display('index.tpl') and $smarty- display('file:index.tpl') ar...
... $default_resource_type $default_resource_type , default_resource_type $default_...
...ers Home  $default_config_handler_func ...
-
language.variables.smarty
...arty} variable can be used to access several environment and request variables. ...
...ET) http://www.example.com/index.php?page=foo *} {$smarty.get.page} {* display t...
... {$smarty} reserved variable {$smarty} reserved variable , ldelim, smarty, rdeli...
...is no longer used with the new {foreach} syntax, but is still supported with Sma...
...sed to access several environment and request variables. The full list of them f...
-
api.template.exists
...t can accept either a path to the template on the filesystem or a resource strin...
...php // set the filename eg index.inc.tpl $mid_template = $_GET['page'].'.inc.tpl...
... templateExists() templateExists() templateexists, templateExists() Prev  Ch...
...d template exists Description bool templateExists ( string template ); I...
-
smarty.for.designers
...ng_format strip strip_tags to_charset truncate unescape upper wordwrap 6. Combin...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
... Part II. Smarty For Template Designers Part II. Smarty For Template...
...mplate Designers Table of Contents 3. Basic Syntax Comments Variables Functions ...
-
language.syntax.variables
...variables are an exception to the $dollar syntax and are instead referenced with...
...ou can reference arrays by index numerically or non-numerically. Also reference ...
... Variables Variables variables Variables Prev  Chapter 3. Basic Syntax...
...he $dollar sign. They can contain numbers, letters and underscores, much like a ...
-
api.assign.by.ref
...ed var ); This is used to assign() values to the templates by reference. Tec...
...ul if you want a PHP array index value to be affected by its reassignment from a...
... assignByRef() assignByRef() assignbyref, assignByRef() Prev  Chapter 14....
...lues by reference Description void assignByRef ( string varname ,  Â...
-
language.variable.scopes
...scopes You have the choice to assign variables to the scope of the main Smarty o...
...= $smarty- createTemplate('index.tpl'); $tpl- assign('bar','bar-template'); // a...
... Variable scopes Variable scopes variable, scopes Variable scopes Prev  Chap...
...ate objects you have full control which variables can be seen by a template. Exa...
-
api.create.template
...ce instead of passing this to each call to this function. It is used in the even...
...= $smarty- createTemplate('index.tpl'); // assign variable to template scope $tp...
... createTemplate() createTemplate() createtemplate, createTemplate() Prev  Ch...
...rty.class.php'); $smarty = new Smarty; // create template object with its privat...
...a template object Description Smarty_Internal_Template createTemplate ( stri...
-
api.append.by.ref
... merge ); This is used to append() values to the templates by reference. Tec...
...ul if you want a PHP array index value to be affected by its reassignment from a...
... appendByRef() appendByRef() appendbyref, appendByRef() Prev  Chapter 14....
...lues by reference Description void appendByRef ( string varname ,  Â...
-
api.is.cached
...y works if $caching is set to one of Smarty::CACHING_LIFETIME_CURRENT or Smarty:...
...T); if(!$smarty- isCached('index.tpl')) { // do database calls, assign vars here...
... isCached() isCached() iscached, isCached() Prev  Chapter 14. Smarty C...
...for this template Description bool isCached ( string template ,   ...
-
language.builtin.functions
...ration @first @last @show @total {break} {continue} {function} {if},{elseif},{el...
...} {foreach},{foreachelse} @index @iteration @first @last @show @total {break} {c...
... Chapter 7. Built-in Functions Chapter 7. Built-in Functions chapter...
...er 7. Built-in Functions Chapter 7. Built-in Functions chapter, 7, b...
-
language.function.html.table
...v  Chapter 8. Custom Functions  Next {html_table} {html_table} is ...
...dd"') ); $smarty- display('index.tpl'); ? The variables assigned from php could ...
... {html_table} {html_table} , ldelim, html_table, rdelim, {html_table} Prev  ...
...pter 8. Custom Functions  Next {html_table} {html_table} is a custom f...
-
advanced.features.template.settings
...tions . Modifications done to the Smarty object will be global for all templates...
...= $smarty- createTemplate('index.tpl); $tpl- cache_lifetime = 600; //or $tpl- se...
... Changing settings by template Changing settings by template changing, settings,...
... by template Normally you configure the Smarty settings by modifying the Smarty ...
-
bugs
... Chapter 23. BUGS Chapter 23. BUGS chapter, 23, bugs Chapter 23....
...on of Smarty, or check the website. Prev  Up  Chapter 22. Resource...
... with the latest distribution of Smarty, or check the website. Prev  Up  ...
-
language.function.foreach
...ibutes. This syntax is new to Smarty 3, however the Smarty 2.x syntax {foreach f...
... {foreach} properties are @index , @iteration , @first , @last , @show , @total ...
... {foreach},{foreachelse} {foreach},{foreachelse} , ldelim, foreach, rdelim, ldel...
...attributes. This syntax is new to Smarty 3, however the Smarty 2.x syntax {forea...
...er 7. Built-in Functions  Next {foreach},{foreachelse} {foreach} is us...
-
caching.custom
... Custom Cache Implementation Custom Cache Implementation custom, cache, implemen...
...L, * PRIMARY KEY (`id`), * INDEX(`name`), * INDEX(`cache_id`), * INDEX(`compile_...
... Custom Cache Implementation Custom Cache Implementation custom, cache, implemen...
...arty.class.php'; $smarty = new Smarty(); $smarty- caching_type = 'mysql'; /** * ...
... Custom Cache Implementation Custom Cache Implementation custom, cache, implemen...
-
troubleshooting
... will see an error similar to the following: Example 20.1. Smarty errors W...
...rrors Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah...
... Chapter 20. Troubleshooting Chapter 20. Troubleshooting chapter, 20...
...Troubleshooting Table of Contents Smarty/PHP errors Smarty/PHP errors Smarty ca...
-
advanced.features.static.classes
...in PHP. Note Direct access to PHP classes is not recommended. This ties the unde...
... Static Classes Static Classes static, classes Static Classes Prev  Chapter...
...ices section of the Smarty website. Example 17.10. static class access syn...
...es the underlying application code structure directly to the presentation, and a...
-
advanced.features.outputfilters
...ates before they are saved to the disk, whereas output filters operate on the te...
...email"); $smarty- display("index.tpl'); // now any occurrence of an email addres...
...Output Filters Prev  Chapter 17. Advanced Features  Next Output Fi...
...output can be sent through one or more output filters. This differs from postfil...
-
language.modifier.upper
... Next upper This is used to uppercase a variable. This is equivalent to the PH...
..., "If Strike isn't Settled Quickly it may Last a While."); ? Where template is: ...
...er upper upper Prev  Chapter 5. Variable Modifiers  Next upper Thi...
...the PHP strtoupper() function. Example 5.23. upper ?php $smarty- assign('a...
-
plugins.resources
...s or PHP script components to Smarty. Some examples of resources: databases, LDA...
...pt $smarty- display("mysql:index.tpl"); ? And from within Smarty template: {incl...
...rces Resources Prev  Chapter 18. Extending Smarty With Plugins  Ne...
...ruct() { try { $this- db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty",...
... sources or PHP script components to Smarty. Some examples of resources: databas...
-
language.modifier.strip
...d string. Note If you want to strip blocks of template text, use the built-in {s...
... one."); $smarty- display('index.tpl'); ? Where template is: {$articleTitle} {$a...
...ip strip strip Prev  Chapter 5. Variable Modifiers  Next strip Thi...
...laces all repeated spaces, newlines and tabs with a single space, or with the su...
...the built-in {strip} function. Example 5.19. strip ?php $smarty- assign('a...
-
caching.cacheable
...offers several options how to exclude sections of your output from caching. Gene...
...); if (!$smarty- isCached('index.tpl')) { // fetch $obj from db and assign... $s...
... Controlling Cacheability of Output Controlling Cacheability of Output controlli...
... Controlling Cacheability of Output Controlling Cacheability of Output controlli...
-
caching.groups
...f cache groups like a directory hierarchy. For instance, a cache group of 'a|b|c...
...structure like themes/blue/index.tpl and you want to be able to clear all the ca...
... Cache Groups Cache Groups cache, groups Cache Groups Prev  Chapter 15.Â...
...rty.class.php'); $smarty = new Smarty; $smarty- setCaching(Smarty::CACHING_LIFET...
...ouping works left-to-right ONLY. You will need to group your templates under a s...
-
api.assign
... assign variables/objects to the templates Description void assign ( mixed...
... assign() assign() assign, assign() Prev  Chapter 14. Smarty Class Met...
...ices section of the Smarty website. Example 14.6. assign() ?php // passing...
... to the templates Description void assign ( mixed var ); void assign...
-
language.variables
...ditional expressions, etc. To print a variable, simply enclose it in the delimit...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
... Chapter 4. Variables Chapter 4. Variables chapter, 4, variables Cha...
...es PHP code ?php $smarty = new Smarty(); $smarty- assign('firstname', 'Doug'); $...
...4. Variables Table of Contents Variables assigned from PHP Associative array...
-
advanced.features.postfilters
...aded from the plugins directory by using the loadFilter() function or by setting...
...mment'); $smarty- display('index.tpl'); ? The postfilter above will make the com...
...rs Postfilters Prev  Chapter 17. Advanced Features  Next Postfilte...
... postfilters are PHP functions that your templates are ran through after they ar...
-
api.fetch
...in the event that you want to compile different versions of the same template, s...
... $output = $smarty- fetch('index.tpl', $cache_id); // do something with $output ...
...fetch, fetch() Prev  Chapter 14. Smarty Class Methods  Next Name f...
...rty.class.php'); $smarty = new Smarty; $smarty- setCaching(true); // set a separ...
...e template output Description string fetch ( string template ,   ...
-
api.display
...he contents of a template. To return the contents of a template into a variable,...
...ist if(!$smarty- isCached('index.tpl')) { // dummy up some data $address = '245 ...
... display() display() display, display() Prev  Chapter 14. Smarty Class...
...rty.class.php'); $smarty = new Smarty(); $smarty- setCaching(true); // only do d...
...lays the template Description void display ( string template ,   ...
-
language.function.assign
...lacing application logic into the presentation that may be better handled in PHP...
...ole_page = $smarty- fetch('index.tpl'); // this will output 'smarty' as the temp...
... {assign} {assign} , ldelim, assign, rdelim, {assign} Prev  Chapter 7.Â...
...er 7. Built-in Functions  Next {assign} {assign} is used for assigning...
-
caching.multiple.caches
...he files for a single call to display() or fetch() . Let's say that a call to di...
...ay that a call to display('index.tpl') may have several different output content...
... Multiple Caches Per Page Multiple Caches Per Page multiple, caches, per, page M...
...rty.class.php'); $smarty = new Smarty; $smarty- setCaching(Smarty::CACHING_LIFET...
... several different output contents depending on some condition, and you want sep...
-
resources.custom
... Custom Template Resources Custom Template Resources custom, template, resources...
...pt $smarty- display("mysql:index.tpl"); ? And from within Smarty template: {incl...
... Custom Template Resources Custom Template Resources custom, template, resources...
...ruct() { try { $this- db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty",...
...ting resource plugin functions and registering them with Smarty. See resource pl...
-
api.register.object
...ou register/assign objects to templates, be sure that all properties and methods...
...gisterObject() Prev  Chapter 14. Smarty Class Methods  Next Name r...
...ices section of the Smarty website. See the objects section for more information...
... in the templates Description void registerObject ( string object_name ,...
-
plugins.compiler.functions
...sensitive static content into the template. If there is both a compiler function...
...hing like this: ?php echo 'index.tpl compiled at 2002-02-20 20:02'; ? See also r...
...iler Functions Prev  Chapter 18. Extending Smarty With Plugins  Ne...
... Compiler Functions Compiler Functions compiler, functions Compiler Functions Pr...
-
installing.smarty.extended
...slightly more flexible way to setup Smarty is to extend the class and initialize...
...; } } ? Now lets alter the index.php file to use setup.php : Example 2.11.Â...
...Extended Setup Prev  Chapter 2. Installation  Next Extended Setup ...
...n one place. Lets create a new directory /php/includes/guestbook/ and make a new...
...Chapter 2. Installation  Next Extended Setup This is a continuation of...
-
tips.componentized.templates
...y, programming templates into your applications goes as follows: First, you accu...
...sign'], $ticker_info); } ? index.tpl {load_ticker symbol='SMARTY' assign='ticker...
... Componentized Templates Componentized Templates componentized, templates Compon...
... Componentized Templates Componentized Templates componentized, templates Compon...
-
api.register.resource
...source_handler ); Use this to dynamically register a Resource plugin with Smarty...
...marty- display('c:/path/to/index.tpl'); Note Prior to Smarty 3.1 registerResourc...
...sterResource() Prev  Chapter 14. Smarty Class Methods  Next Name r...
... registerResource('mysql', new Smarty_Resource_Mysql()); ? See also unregisterRe...
...egister resources Description void registerResource ( string name ,  ...
-
index
...ng_format strip strip_tags to_charset truncate unescape upper wordwrap 6. Combin...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
... Smarty 3 Manual Smarty 3 Manual smarty, 3, manual Smarty 3 Manual   Â...
...m Copyright © 2001-2011 New Digital Group, Inc. 2011-11-29 Table of Contents ...
...iling PHP template engine Monte Ohrt monte at ohrt dot com Uwe Tews uwe dot tews...
-
api.clear.compiled.tpl
... clear entire compile directory $smarty- clearCompiledTemplate(); ? See also cle...
...ty- clearCompiledTemplate('index.tpl'); // clear entire compile directory $smart...
... clearCompiledTemplate() clearCompiledTemplate() clearcompiledtemplate, clearCom...
... clears the compiled version of the specified template resource Description voi...
-
language.function.section
...ke {foreach} which is used to loop over a single associative array . Every {sect...
... looping over sequentially indexed arrays of data , unlike {foreach} which is us...
...,{sectionelse} Prev  Chapter 7. Built-in Functions  Next {section}...
... {section},{sectionelse} {section},{sectionelse} , ldelim, section, rdelim, ldel...
-
resources
...ir Templates from any directory Windows Filepaths String Template Resources Stre...
...dir ?php $smarty- display('index.tpl'); $smarty- display('file:index.tpl'); // s...
... Chapter 16. Resources Chapter 16. Resources chapter, 16, resources ...
...template_dir . This allows websites employing multiple sets of templates better ...
...16. Resources Table of Contents File Template Resources Templates from $templ...
-
api.create.data
...parameter. It is an uplink to the main Smarty object, a another user-created dat...
...= $smarty- createTemplate('index.tpl',$data); // display the template $tpl- disp...
... createData() createData() createdata, createData() Prev  Chapter 14. ...
...rty.class.php'); $smarty = new Smarty; // create data object with its private va...
...tes a data object Description string createData ( object parent ); strin...
-
api.clear.cache
...r. You can group templates together so they can be removed as a group, see the c...
...plate $smarty- clearCache('index.tpl'); // clear the cache for a particular cach...
... clearCache() clearCache() clearcache, clearCache() Prev  Chapter 14. ...
...specific template Description void clearCache ( string template ,  Â...
-
advanced.features.prefilters
...eprocessing your templates to remove unwanted comments, keeping an eye on what p...
...ments'); $smarty- display('index.tpl'); ? See also registerFilter() , postfilter...
...ers Prefilters Prev  Chapter 17. Advanced Features  Next Prefilter...
...e prefilters are PHP functions that your templates are ran through before they a...