-
caching
...er 15. Caching Table of Contents Setting Up Caching Multiple Caches Per Pa...
...URRENT); $smarty- display('index.tpl'); ? With caching enabled, the function cal...
...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
...se goals: clean separation of presentation from application code PHP backend, Sm...
...liment PHP, not replace it fast development/deployment for programmers and desig...
...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
...the Best Practices section of the Smarty website. There are two ways to access t...
...$myobj); $smarty- display('index.tpl'); ? And here's how to access your objects ...
...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
...n the /libs/ sub directory of the distribution. These are .php files that you SH...
...com/ guestbook/ templates/ index.tpl templates_c/ configs/ cache/ htdocs/ index....
...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
... function returns an array of tagname/attribute pairs for all tags used by the t...
...= $smarty- createTemplate('index.tpl'); // get tags $tags = $smarty- getTags($tp...
...rty.class.php'); $smarty = new Smarty; // create template object $tpl = $smarty-...
... used by template Description string getTags ( object template ); This f...
-
language.function.append
...rrays during the execution of a template . Note Assignment of variables in-templ...
...a The value being assigned index string No n/a The index for the new array eleme...
...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
...ing that $smarty- display('index.tpl') and $smarty- display('file:index.tpl') ar...
...ers Home  $default_config_handler_func ...
-
language.variables.smarty
...t variables. The full list of them follows. Request variables The request variab...
...ET) http://www.example.com/index.php?page=foo *} {$smarty.get.page} {* display t...
...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
...php // set the filename eg index.inc.tpl $mid_template = $_GET['page'].'.inc.tpl...
...d template exists Description bool templateExists ( string template ); I...
-
smarty.for.designers
...r Template Designers Table of Contents 3. Basic Syntax Comments Variables Functi...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
...mplate Designers Table of Contents 3. Basic Syntax Comments Variables Functions ...
-
language.syntax.variables
...-- display the 5th element of a zero-indexed array {$foo.bar} -- display the "ba...
...ou can reference arrays by index numerically or non-numerically. Also reference ...
...he $dollar sign. They can contain numbers, letters and underscores, much like a ...
-
api.assign.by.ref
...Note With the introduction of PHP5, assignByRef() is not necessary for most inte...
...ul if you want a PHP array index value to be affected by its reassignment from a...
...lues by reference Description void assignByRef ( string varname ,  Â...
-
language.variable.scopes
...ign variables to the scope of the main Smarty object, data objects created with ...
...= $smarty- createTemplate('index.tpl'); $tpl- assign('bar','bar-template'); // a...
...ate objects you have full control which variables can be seen by a template. Exa...
-
api.create.template
...e_id variable once instead of passing this to each call to this function. It is ...
...= $smarty- createTemplate('index.tpl'); // assign variable to template scope $tp...
...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
...Note With the introduction of PHP5, appendByRef() is not necessary for most inte...
...ul if you want a PHP array index value to be affected by its reassignment from a...
...lues by reference Description void appendByRef ( string varname ,  Â...
-
api.is.cached
... if $caching is set to one of Smarty::CACHING_LIFETIME_CURRENT or Smarty::CACHIN...
...T); if(!$smarty- isCached('index.tpl')) { // do database calls, assign vars here...
...for this template Description bool isCached ( string template ,   ...
-
language.builtin.functions
... Built-in Functions Table of Contents {$var=...} {append} {assign} {block} {cal...
...} {foreach},{foreachelse} @index @iteration @first @last @show @total {break} {c...
...er 7. Built-in Functions Chapter 7. Built-in Functions chapter, 7, b...
-
language.function.html.table
...nction that dumps an array of data into an HTML table . Attribute Name Type Requ...
...dd"') ); $smarty- display('index.tpl'); ? The variables assigned from php could ...
...pter 8. Custom Functions  Next {html_table} {html_table} is a custom f...
-
advanced.features.template.settings
...= $smarty- createTemplate('index.tpl); $tpl- cache_lifetime = 600; //or $tpl- se...
... by template Normally you configure the Smarty settings by modifying the Smarty ...
-
bugs
...th the latest distribution of Smarty, or check the website. Prev  Up  Ch...
...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
...ed for looping over arrays of data. {foreach} has a simpler and cleaner syntax t...
... {foreach} properties are @index , @iteration , @first , @last , @show , @total ...
...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
...ng to achieve at least one of the following goals: replace the slow filesystem b...
...e the slow filesystem by a faster storage engine, centralize the cache to be acc...
...L, * PRIMARY KEY (`id`), * INDEX(`name`), * INDEX(`cache_id`), * INDEX(`compile_...
...arty.class.php'; $smarty = new Smarty(); $smarty- caching_type = 'mysql'; /** * ...
... Custom Cache Implementation Custom Cache Implementation custom, cache, implemen...
-
troubleshooting
.... Troubleshooting Table of Contents Smarty/PHP errors Smarty/PHP errors Smart...
...rrors Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah...
...Troubleshooting Table of Contents Smarty/PHP errors Smarty/PHP errors Smarty ca...
-
advanced.features.static.classes
...the Best Practices section of the Smarty website. Example 17.10. static cl...
...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
...ction to return the result of the processing. Example 17.13. Using a templ...
...email"); $smarty- display("index.tpl'); // now any occurrence of an email addres...
...output can be sent through one or more output filters. This differs from postfil...
-
plugins.resources
...are meant as a generic way of providing template sources or PHP script component...
...tion times can be accessed faster than loading the comple template source. * @pa...
...pt $smarty- display("mysql:index.tpl"); ? And from within Smarty template: {incl...
...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
...f you want to strip blocks of template text, use the built-in {strip} function. ...
... one."); $smarty- display('index.tpl'); ? Where template is: {$articleTitle} {$a...
...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
... Controlling Cacheability of Output Controlling Cacheability of Output controlli...
...); if (!$smarty- isCached('index.tpl')) { // fetch $obj from db and assign... $s...
... Controlling Cacheability of Output Controlling Cacheability of Output controlli...
-
what.is.smarty
...tes and uses a combination of HTML tags and template tags to format the presenta...
... features: It is extremely fast. It is efficient since the PHP parser does the d...
... page that is displaying a newspaper article. The article $headline , $tagline ,...
...e way to separate application logic and content from its presentation. This is b...
-
caching.groups
...as you like. You can think of cache groups like a directory hierarchy. For insta...
...structure like themes/blue/index.tpl and you want to be able to clear all the ca...
...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
...al third nocache parameter of TRUE , the variable is assigned as nocache variabl...
...ices section of the Smarty website. Example 14.6. assign() ?php // passing...
... to the templates Description void assign ( mixed var ); void assign...
-
language.variables
...r 4. Variables Table of Contents Variables assigned from PHP Associative a...
...email' = 'zaphod@slartibartfast.example.com', 'phone' = array('home' = '555-444-...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
...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
...ction to return the result of the processing. Example 17.12. Using a templ...
...mment'); $smarty- display('index.tpl'); ? The postfilter above will make the com...
... postfilters are PHP functions that your templates are ran through after they ar...
-
api.fetch
...he template output instead of displaying it. Supply a valid template resource ty...
... $output = $smarty- fetch('index.tpl', $cache_id); // do something with $output ...
...rty.class.php'); $smarty = new Smarty; $smarty- setCaching(true); // set a separ...
...e template output Description string fetch ( string template ,   ...
-
api.display
...This displays the contents of a template. To return the contents of a template i...
...ist if(!$smarty- isCached('index.tpl')) { // dummy up some data $address = '245 ...
...rty.class.php'); $smarty = new Smarty(); $smarty- setCaching(true); // only do d...
...lays the template Description void display ( string template ,   ...
-
language.function.assign
...ables during the execution of a template . Note Assignment of variables in-templ...
...ole_page = $smarty- fetch('index.tpl'); // this will output 'smarty' as the temp...
...er 7. Built-in Functions  Next {assign} {assign} is used for assigning...
-
caching.multiple.caches
...id . For each unique value of $my_cache_id , a separate cache will be generated ...
...ay that a call to display('index.tpl') may have several different output content...
...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
...tion times can be accessed faster than loading the comple template source. * @pa...
...pt $smarty- display("mysql:index.tpl"); ? And from within Smarty template: {incl...
...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
...the Best Practices section of the Smarty website. See the objects section for mo...
...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
...ed only during compilation of the template. They are useful for injecting PHP co...
...hing like this: ?php echo 'index.tpl compiled at 2002-02-20 20:02'; ? See also r...
... Compiler Functions Compiler Functions compiler, functions Compiler Functions Pr...
-
installing.smarty.extended
...tup This is a continuation of the basic installation , please read that first! A...
...; } } ? Now lets alter the index.php file to use setup.php : Example 2.11.Â...
...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
...sign'], $ticker_info); } ? index.tpl {load_ticker symbol='SMARTY' assign='ticker...
... Componentized Templates Componentized Templates componentized, templates Compon...
-
api.register.resource
...h Smarty. Pass in the name of the Resource and the object extending Smarty_Resou...
...marty- display('c:/path/to/index.tpl'); Note Prior to Smarty 3.1 registerResourc...
... registerResource('mysql', new Smarty_Resource_Mysql()); ? See also unregisterRe...
...egister resources Description void registerResource ( string name ,  ...
-
index
...oup, Inc. 2011-11-29 Table of Contents Preface I. Getting Started 1. What is Sma...
...P Associative arrays Array indexes Objects Variable scopes Variables loaded from...
...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
...lears the compiled version of the specified template resource Description voidÂ...
...ty- clearCompiledTemplate('index.tpl'); // clear entire compile directory $smart...
... clears the compiled version of the specified template resource Description voi...
-
language.function.section
...equentially indexed arrays of data , unlike {foreach} which is used to loop over...
... looping over sequentially indexed arrays of data , unlike {foreach} which is us...
... {section},{sectionelse} {section},{sectionelse} , ldelim, section, rdelim, ldel...
-
resources
... 16. Resources Table of Contents File Template Resources Templates from $t...
...dir ?php $smarty- display('index.tpl'); $smarty- display('file:index.tpl'); // s...
...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
... variables assigned to any of the objects in it's parent chain. Data objects are...
...= $smarty- createTemplate('index.tpl',$data); // display the template $tpl- disp...
...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
...plate $smarty- clearCache('index.tpl'); // clear the cache for a particular cach...
...specific template Description void clearCache ( string template ,  Â...
-
advanced.features.prefilters
...ments'); $smarty- display('index.tpl'); ? See also registerFilter() , postfilter...
...e prefilters are PHP functions that your templates are ran through before they a...