-
caching
...e this page for an hour or more. On the other hand, if you are displaying a page...
...etc. Since templates are dynamic, it is important to be careful what you are cac...
... Chapter 15. Caching Chapter 15. Caching chapter, 15, caching Chapte...
...URRENT); $smarty- display('index.tpl'); ? With caching enabled, the function cal...
...ur website that does not change its content very often, it might work well to ca...
-
advanced.features.objects
...emplate syntax. It is also more secure, as a registered object can be restricted...
...ns that are difficult to manage. See the Best Practices section of the Smarty we...
...ns can be accessed (beginningwith '_'). If a method and property of the same nam...
...$myobj); $smarty- display('index.tpl'); ? And here's how to access your objects ...
-
installing.smarty.basic
...NOT edit. They are shared among all applications and only get changed when you u...
...Smarty uses a PHP constant named SMARTY_DIR which is the full system file path t...
...T edit. They are shared among all applications and only get changed when you upg...
...com/ guestbook/ templates/ index.tpl templates_c/ configs/ cache/ htdocs/ index....
...pplications and only get changed when you upgrade to a new version of Smarty. In...
-
api.get.tags
...ty Class Methods  Next Name getTags() — return tags used by template ...
...y template Description string getTags ( object template ); This function...
...= $smarty- createTemplate('index.tpl'); // get tags $tags = $smarty- getTags($tp...
-
language.function.append
...ion. Attributes: Attribute Name Type Required Default Description var string Yes...
...{append} is used for creating or appending template variable arrays during the e...
...a The value being assigned index string No n/a The index for the new array eleme...
-
variable.default.resource.type
...e the resource chapter for more details. Prev  Up  Next $default_modifie...
...fault value is file , meaning that $smarty- display('index.tpl') and $smarty- di...
...ing that $smarty- display('index.tpl') and $smarty- display('file:index.tpl') ar...
-
language.variables.smarty
...SSION can be accessed as demonstrated in the examples below: Example 4.8. ...
...e value of the cookie "username" ($_COOKIE['username']) *} {$smarty.cookies.user...
...Example 4.8. Displaying request variables {* display value of page from UR...
...ET) http://www.example.com/index.php?page=foo *} {$smarty.get.page} {* display t...
-
api.template.exists
...ty Class Methods  Next Name templateExists() — checks whether the spe...
...l templateExists ( string template ); It can accept either a path to the...
...php // set the filename eg index.inc.tpl $mid_template = $_GET['page'].'.inc.tpl...
-
smarty.for.designers
...smarty.rdelim} 5. Variable Modifiers capitalize cat count_characters count_parag...
...unctions Attributes Embedding Vars in Double Quotes Math Escaping Smarty Parsing...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
-
language.syntax.variables
..., it may be a good idea to move the bits that do not deal explicitly with presen...
...e {assign} Many other combinations are allowed {$foo.bar.baz} {$foo.$bar.$baz} {...
...d referenced with surrounding #hashmarks#, or via the $smarty.config variable. E...
...ou can reference arrays by index numerically or non-numerically. Also reference ...
-
api.assign.by.ref
...Ref() is not necessary for most intents and purposes. assignByRef() is useful if...
...ty Class Methods  Next Name assignByRef() — assign values by referenc...
...void assignByRef ( string varname ,          ...
...ul if you want a PHP array index value to be affected by its reassignment from a...
-
language.variable.scopes
... variable scope. By assigning variables to individual data or template objects y...
...= $smarty- createTemplate('index.tpl'); $tpl- assign('bar','bar-template'); // a...
-
api.create.template
...so the caching section for more information. compile_id is an optional parameter...
...ty Class Methods  Next Name createTemplate() — returns a template obj...
...e createTemplate ( string template ,         Â...
...= $smarty- createTemplate('index.tpl'); // assign variable to template scope $tp...
...es compiled for different languages. parent is an optional parameter. It is an u...
-
api.append.by.ref
...Ref() is not necessary for most intents and purposes. appendByRef() is useful if...
...ty Class Methods  Next Name appendByRef() — append values by referenc...
...void appendByRef ( string varname ,          ...
...ul if you want a PHP array index value to be affected by its reassignment from a...
-
api.is.cached
...ee the caching section for more info. You can also pass a $cache_id as an option...
...ty Class Methods  Next Name isCached() — returns true if there is a v...
...on bool isCached ( string template ,         Â...
...T); if(!$smarty- isCached('index.tpl')) { // do database calls, assign vars here...
...o clearCache() and other changes of the cache-settings may have no effect after ...
-
language.builtin.functions
...and you should not need to modify the built-in functions. A few of these functio...
...om functions with the same name; and you should not need to modify the built-in ...
...rt of the smarty template engine. They are compiled into corresponding inline PH...
...} {foreach},{foreachelse} @index @iteration @first @last @show @total {break} {c...
-
language.function.html.table
... as these three examples demonstrate. Each example shows the template followed b...
... an HTML table . Attribute Name Type Required Default Description loop array Yes...
...arated list of column heading names or an array of column heading names.if the c...
...dd"') ); $smarty- display('index.tpl'); ? The variables assigned from php could ...
-
advanced.features.template.settings
...ure the Smarty settings by modifying the Smarty class variables . Furthermore yo...
... Changing settings by template Changing settings by template changing, settings,...
...= $smarty- createTemplate('index.tpl); $tpl- cache_lifetime = 600; //or $tpl- se...
... Changing settings by template Changing settings by template changing, settings,...
-
bugs
-
language.function.foreach
... /ul Example 7.31. Demonstrates the an additional key variable ?php $peopl...
...syntax does not accept any named attributes. This syntax is new to Smarty 3, how...
...{foreach} is used for looping over arrays of data. {foreach} has a simpler and c...
... {foreach} properties are @index , @iteration , @first , @last , @show , @total ...
-
caching.custom
...y the Smarty_CacheResource module. With a custom cache implementation you're lik...
... Implementation As an alternative to using the default file-based caching mechan...
... Chapter 15. Caching  Next Custom Cache Implementation As an altern...
...L, * PRIMARY KEY (`id`), * INDEX(`name`), * INDEX(`cache_id`), * INDEX(`compile_...
... quote($compile_id); } // range test expiration time if ($exp_time !== null) { $...
-
troubleshooting
...ax error. Here are some common things to look for: missing close tags for {if}{/...
...utes or malformed variable names. If this happens, you will see an error similar...
...ter 20. Troubleshooting Chapter 20. Troubleshooting chapter, 20, tro...
...rrors Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah...
-
preface
...ealed. This approach is common with other template engines (even in other progra...
...eployment and easier maintenance. Smarty syntax requires no working knowledge of...
...rty? Smarty is a template engine for PHP, facilitating the separation of present...
...even in other programming languages), and is also the approach that Smarty takes...
-
advanced.features.static.classes
...arty variable bar as class name Prev  Up  Next Objects Home  Pref...
...ded. This ties the underlying application code structure directly to the present...
-
advanced.features.outputfilters
...can be sent through one or more output filters. This differs from postfilters be...
...l($tpl_output, Smarty_Internal_Template $template) { $tpl_output = preg_replace(...
...he plugins directory by using the loadFilter() method or by setting the $autoloa...
...email"); $smarty- display("index.tpl'); // now any occurrence of an email addres...
-
plugins.resources
... databases, LDAP, shared memory, sockets, and so on. Custom Resources may be put...
...resource by prepending its name to the template you're addressing: foobarxyz:you...
... Chapter 18. Extending Smarty With Plugins  Next Resources Resource p...
...pt $smarty- display("mysql:index.tpl"); ? And from within Smarty template: {incl...
-
language.modifier.strip
... Chapter 5. Variable Modifiers  Next strip This replaces all repeated ...
...newlines and tabs with a single space, or with the supplied string. Note If you ...
... one."); $smarty- display('index.tpl'); ? Where template is: {$articleTitle} {$a...
-
caching.cacheable
...ically executed in nocache mode. Note If a tag is executed in nocache mode you m...
...y of Output If caching is enabled normally the whole final output of the page ge...
... Controlling Cacheability of Output Controlling Cacheability of Output controlli...
...); if (!$smarty- isCached('index.tpl')) { // fetch $obj from db and assign... $s...
...ed template code. If you change the status you must manually delete existing com...
-
caching.groups
...xt Cache Groups You can do more elaborate grouping by setting up $cache_id group...
... If you specify a template name such as clearCache('foo.tpl','a|b|c') then Smart...
... Chapter 15. Caching  Next Cache Groups You can do more elaborate g...
...structure like themes/blue/index.tpl and you want to be able to clear all the ca...
-
api.assign
...{$contact.email} To access more complex array assignments see {foreach} and {sec...
...ty Class Methods  Next Name assign() — assign variables/objects to th...
...r ); void assign ( string varname ,          ...
-
language.variables
...functions , attributes and modifiers , inside conditional expressions, etc. To p...
...modifiers , inside conditional expressions, etc. To print a variable, simply enc...
... so that it is the only thing contained between them. Example 4.1. Example...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
-
advanced.features.postfilters
...t($tpl_source, Smarty_Internal_Template $template) { return " ?php echo \" !-- C...
...he plugins directory by using the loadFilter() function or by setting the $autol...
...mment'); $smarty- display('index.tpl'); ? The postfilter above will make the com...
-
api.fetch
...ee the caching section for more information. As an optional third parameter, you...
...ty Class Methods  Next Name fetch() — returns the template output Des...
...ate output Description string fetch ( string template ,     ...
... $output = $smarty- fetch('index.tpl', $cache_id); // do something with $output ...
...es compiled for different languages. You can also set the $compile_id variable o...
-
api.display
...ee the caching section for more information. As an optional third parameter, you...
...ty Class Methods  Next Name display() — displays the template Descrip...
...ion void display ( string template ,         Â...
...ist if(!$smarty- isCached('index.tpl')) { // dummy up some data $address = '245 ...
...es compiled for different languages. You can also set the $compile_id variable o...
-
language.function.assign
...ars. Attributes: Attribute Name Type Required Default Description var string Yes...
...assign} is used for assigning template variables during the execution of a templ...
...ole_page = $smarty- fetch('index.tpl'); // this will output 'smarty' as the temp...
-
caching.multiple.caches
... Chapter 15. Caching  Next Multiple Caches Per Page You can have mu...
...ay that a call to display('index.tpl') may have several different output content...
-
resources.custom
...source plugins section for more information on the functions you are supposed to...
...ing under another resource name. Example 16.10. Using custom resources ?ph...
... can retrieve templates using whatever possible source you can access with PHP: ...
...pt $smarty- display("mysql:index.tpl"); ? And from within Smarty template: {incl...
-
api.register.object
...ee the objects section for more information. See also getRegisteredObject() , an...
...ty Class Methods  Next Name registerObject() — register an object for...
...d registerObject ( string object_name ,         ...
-
plugins.compiler.functions
... registered under the same name, the compiler function has precedence. mixed sma...
... Chapter 18. Extending Smarty With Plugins  Next Compiler Functions C...
...hing like this: ?php echo 'index.tpl compiled at 2002-02-20 20:02'; ? See also r...
-
installing.smarty.extended
...ead that first! A slightly more flexible way to setup Smarty is to extend the cl...
...URRENT; $this- assign('app_name', 'Guest Book'); } } ? Now lets alter the index....
...instead of repeatedly setting directory paths, assigning the same vars, etc., we...
...; } } ? Now lets alter the index.php file to use setup.php : Example 2.11.Â...
-
tips.componentized.templates
...nentized Templates Traditionally, programming templates into your applications g...
...es Traditionally, programming templates into your applications goes as follows: ...
...sign'], $ticker_info); } ? index.tpl {load_ticker symbol='SMARTY' assign='ticker...
-
api.register.resource
...See template resources for more information on how to setup a function for fetch...
...ty Class Methods  Next Name registerResource() — dynamically register...
... registerResource ( string name ,          Â...
...marty- display('c:/path/to/index.tpl'); Note Prior to Smarty 3.1 registerResourc...
-
index
...piling PHP template engine Monte Ohrt monte at ohrt dot com Uwe Tews uwe dot tew...
...” displays the template enableSecurity() — enables template security fe...
... Next Smarty - the compiling PHP template engine Monte Ohrt monte at ohrt dot c...
...m Uwe Tews uwe dot tews at googlemail dot com Copyright © 2001-2011 New Digit...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
...vanced Features Security Changing settings by template Template Inheritance Stre...
-
api.clear.compiled.tpl
...ty Class Methods  Next Name clearCompiledTemplate() — clears the comp...
...learCompiledTemplate ( string tpl_file ,         Â...
...ty- clearCompiledTemplate('index.tpl'); // clear entire compile directory $smart...
-
language.function.section
...le 7.67. {section} demonstrating the loop variable This example assumes th...
... {foreach} loop. Attribute Name Type Required Default Description name string Ye...
...e} A {section} is for looping over sequentially indexed arrays of data , unlike ...
... looping over sequentially indexed arrays of data , unlike {foreach} which is us...
...ray of 3000 to 3015 $id = range(3000,3015); $smarty- assign('arr',$id); ? Templa...
-
resources
...ropriate path and template name. If a resource is not explicitly given, the valu...
...tory Windows Filepaths String Template Resources Stream Template Resources Exten...
...dir ?php $smarty- display('index.tpl'); $smarty- display('file:index.tpl'); // s...
...t_resource_type has been changed. If the file resource cannot find the requested...
-
api.create.data
...ty Class Methods  Next Name createData() — creates a data object Desc...
...ata object Description string createData ( object parent ); string c...
...= $smarty- createTemplate('index.tpl',$data); // display the template $tpl- disp...
-
api.clear.cache
... together so they can be removed as a group, see the caching section for more in...
...ty Class Methods  Next Name clearCache() — clears the cache for a spe...
... void clearCache ( string template ,         Â...
...plate $smarty- clearCache('index.tpl'); // clear the cache for a particular cach...
-
advanced.features.prefilters
...essing your templates to remove unwanted comments, keeping an eye on what people...
...s($tpl_source, Smarty_Internal_Template $template) { return preg_replace("/ !--#...
...his is good for preprocessing your templates to remove unwanted comments, keepin...
...ments'); $smarty- display('index.tpl'); ? See also registerFilter() , postfilter...