From 26b3e5489e5c5b43a9e2942a716b714bbf824c51 Mon Sep 17 00:00:00 2001 From: nlopess Date: Fri, 27 May 2005 16:25:02 +0000 Subject: [PATCH] more linking and WS from Peter --- .../language-escaping.xml | 19 +-- .../language-basic-syntax/language-math.xml | 4 + .../language-syntax-attributes.xml | 9 +- .../language-syntax-comments.xml | 21 +++- .../language-syntax-functions.xml | 18 ++- .../language-syntax-variables.xml | 2 +- .../language-function-capture.xml | 13 +- .../language-function-config-load.xml | 37 ++++-- .../language-function-foreach.xml | 82 +++++++------ .../language-function-if.xml | 89 +++++++------- .../language-function-include-php.xml | 52 ++++---- .../language-function-include.xml | 80 +++++++++--- .../language-function-insert.xml | 39 +++--- .../language-function-ldelim.xml | 6 +- .../language-function-literal.xml | 8 +- .../language-function-php.xml | 19 ++- .../language-function-section.xml | 18 +-- .../language-function-strip.xml | 6 +- .../language-function-assign.xml | 64 +++++++++- .../language-function-html-options.xml | 43 ++++--- .../language-function-html-radios.xml | 37 +++--- .../language-function-html-select-date.xml | 3 +- .../language-modifier-date-format.xml | 41 ++++--- docs/en/designers/language-variables.xml | 9 +- .../language-assigned-variables.xml | 58 ++++++--- .../language-config-variables.xml | 20 +-- .../language-variables-smarty.xml | 61 +++++----- docs/en/getting-started.xml | 114 ++++++++++-------- docs/en/language-snippets.ent | 6 +- docs/en/preface.xml | 2 +- docs/en/programmers/api-functions.xml | 2 +- .../api-functions/api-append-by-ref.xml | 6 +- .../programmers/api-functions/api-append.xml | 10 +- .../api-functions/api-assign-by-ref.xml | 11 +- .../programmers/api-functions/api-assign.xml | 46 +++++-- .../api-functions/api-clear-all-assign.xml | 22 ++-- .../api-functions/api-clear-all-cache.xml | 11 +- .../api-functions/api-clear-assign.xml | 18 +-- .../api-functions/api-clear-cache.xml | 33 +++-- .../api-functions/api-clear-compiled-tpl.xml | 18 +-- .../api-functions/api-clear-config.xml | 9 +- .../api-functions/api-config-load.xml | 9 +- .../programmers/api-functions/api-display.xml | 29 +++-- .../programmers/api-functions/api-fetch.xml | 100 ++++++++++++--- .../api-functions/api-get-config-vars.xml | 14 ++- .../api-get-registered-object.xml | 22 ++-- .../api-functions/api-get-template-vars.xml | 16 ++- .../api-functions/api-is-cached.xml | 53 +++++--- .../api-functions/api-load-filter.xml | 29 +++-- .../api-functions/api-register-block.xml | 25 ++-- .../api-register-compiler-function.xml | 35 ++++-- .../api-functions/api-register-function.xml | 69 +++++++---- .../api-functions/api-register-modifier.xml | 30 +++-- .../api-functions/api-register-object.xml | 18 +-- .../api-register-outputfilter.xml | 37 ++++-- .../api-functions/api-register-postfilter.xml | 35 ++++-- .../api-functions/api-register-prefilter.xml | 36 ++++-- .../api-functions/api-register-resource.xml | 30 +++-- .../api-functions/api-template-exists.xml | 9 +- .../api-functions/api-trigger-error.xml | 10 +- .../api-functions/api-unregister-block.xml | 17 ++- .../api-unregister-compiler-function.xml | 18 ++- .../api-functions/api-unregister-function.xml | 18 ++- .../api-functions/api-unregister-modifier.xml | 22 ++-- .../api-functions/api-unregister-object.xml | 17 +-- .../api-unregister-outputfilter.xml | 14 ++- .../api-unregister-postfilter.xml | 18 ++- .../api-unregister-prefilter.xml | 17 ++- .../api-functions/api-unregister-resource.xml | 24 ++-- docs/en/programmers/api-variables.xml | 2 +- .../api-variables/variable-cache-dir.xml | 20 ++- .../variable-cache-modified-check.xml | 32 +++-- .../api-variables/variable-caching.xml | 16 ++- .../api-variables/variable-compile-dir.xml | 8 +- .../api-variables/variable-compile-id.xml | 14 ++- .../api-variables/variable-use-sub-dirs.xml | 41 +++++-- .../caching/caching-setting-up.xml | 10 +- docs/en/programmers/smarty-constants.xml | 47 +++++--- 78 files changed, 1400 insertions(+), 727 deletions(-) diff --git a/docs/en/designers/language-basic-syntax/language-escaping.xml b/docs/en/designers/language-basic-syntax/language-escaping.xml index 0c5a75c3..02d22ce9 100644 --- a/docs/en/designers/language-basic-syntax/language-escaping.xml +++ b/docs/en/designers/language-basic-syntax/language-escaping.xml @@ -6,7 +6,8 @@ It is sometimes desirable or even necessary to have Smarty ignore sections it would otherwise parse. A classic example is embedding Javascript or CSS code in a template. The problem arises as those languages use the { and } characters - which are also the default delimiters for Smarty. + which are also the default + delimiters for Smarty. @@ -15,17 +16,17 @@ - Including literal content is possible using {literal} .. {/literal} blocks. - Similar to HTML entity usage, you can use {ldelim},{rdelim} or {ldelim},{rdelim} or {$smarty.ldelim} to display the current delimiters. - It is often convenient to simply change Smarty's $left_delimiter and $right_delimiter. @@ -50,10 +51,10 @@ $smarty->display('example.tpl'); -var foo = ; -function dosomething() { + var foo = 'bar'; + function dosomething() { alert("foo is " + foo); -} + } dosomething(); ]]> diff --git a/docs/en/designers/language-basic-syntax/language-math.xml b/docs/en/designers/language-basic-syntax/language-math.xml index bbec60ad..cac3d741 100644 --- a/docs/en/designers/language-basic-syntax/language-math.xml +++ b/docs/en/designers/language-basic-syntax/language-math.xml @@ -25,6 +25,10 @@ ]]> + + + See also {math} function. + {include file=$includeFile} {include file=#includeFile#} {* display dropdown lists *} + ]]> diff --git a/docs/en/designers/language-basic-syntax/language-syntax-functions.xml b/docs/en/designers/language-basic-syntax/language-syntax-functions.xml index 3e95a618..0c1e3cd2 100644 --- a/docs/en/designers/language-basic-syntax/language-syntax-functions.xml +++ b/docs/en/designers/language-basic-syntax/language-syntax-functions.xml @@ -6,7 +6,9 @@ Each Smarty tag either prints a variable or invokes some sort of function. Functions are processed and displayed by enclosing the - function and its attributes into delimiters like so: {funcname + function and its + attributes + into delimiters like so: {funcname attr1="val" attr2="val"}. @@ -30,16 +32,20 @@ Both built-in functions and custom functions - have the same syntax in the templates. Built-in functions are the - inner workings of Smarty, such as + have the same syntax within templates. + + Built-in functions are the + inner workings of Smarty, such as {if}, {section} and {strip}. - They cannot be modified. Custom functions are - additional functions implemented via plugins. + They cannot be modified. + + Custom functions are additional + functions implemented via plugins. They can be modified to your liking, or you can add new ones. {html_options} and - {html_select_date} + {popup} are examples of custom functions. diff --git a/docs/en/designers/language-basic-syntax/language-syntax-variables.xml b/docs/en/designers/language-basic-syntax/language-syntax-variables.xml index 9ef173d0..81c2ea1c 100644 --- a/docs/en/designers/language-basic-syntax/language-syntax-variables.xml +++ b/docs/en/designers/language-basic-syntax/language-syntax-variables.xml @@ -3,7 +3,7 @@ Variables - Template variables start with a dollar sign. They can contain numbers, + Template variables start with a $dollar sign. They can contain numbers, letters and underscores, much like a PHP variable. You can reference arrays diff --git a/docs/en/designers/language-builtin-functions/language-function-capture.xml b/docs/en/designers/language-builtin-functions/language-function-capture.xml index 6df02591..e07812a7 100644 --- a/docs/en/designers/language-builtin-functions/language-function-capture.xml +++ b/docs/en/designers/language-builtin-functions/language-function-capture.xml @@ -74,15 +74,15 @@ - - {$smarty.capture.banner} - + + {$smarty.capture.banner} + {/if} @@ -91,7 +91,10 @@ - See also {eval}, + See also + $smarty.capture, + {eval}, {fetch}, fetch() and {assign}. diff --git a/docs/en/designers/language-builtin-functions/language-function-config-load.xml b/docs/en/designers/language-builtin-functions/language-function-config-load.xml index e43b877c..8a8e262e 100644 --- a/docs/en/designers/language-builtin-functions/language-function-config-load.xml +++ b/docs/en/designers/language-builtin-functions/language-function-config-load.xml @@ -66,18 +66,35 @@ {config_load} is used for loading config #variables# from a - configuration file into the template. - See Config Files for more - info. + configuration file into the template. {config_load} + + example.conf + + + and the template + + -{#pageTitle#} +{#pageTitle#|default:"No title"} @@ -95,21 +112,23 @@ Config Files may also contain sections. You can load variables from within a section with the added attribute - section. + 'section'. Config file sections and the built-in - template function called section have nothing + template function called + {section} + have nothing to do with each other, they just happen to share a common naming convention. - function config_load with section + function {config_load} with section {#pageTitle#} diff --git a/docs/en/designers/language-builtin-functions/language-function-foreach.xml b/docs/en/designers/language-builtin-functions/language-function-foreach.xml index 1ce28b8c..ee139936 100644 --- a/docs/en/designers/language-builtin-functions/language-function-foreach.xml +++ b/docs/en/designers/language-builtin-functions/language-function-foreach.xml @@ -75,20 +75,20 @@ {foreach} - item - + assign('custid', $arr); +$arr = array( 1001,1002,1003); +$smarty->assign('custid', $arr); ?> ]]> - + - {/foreach} +{* this example will print out all the values of the $custid array *} +{foreach from=$custid item=curr_id} + id: {$curr_id}
+{/foreach} ]]>
@@ -96,51 +96,54 @@ - id: 1001
- id: 1002
+id: 1000
+id: 1001
+id: 1002
]]>
{foreach} - item and key - + assign("contacts", array( - array("phone" => "1", - "fax" => "2", - "cell" => "3"), - array("phone" => "555-4444", - "fax" => "555-3333", - "cell" => "760-1234")) - ); + $smarty->assign('contacts', array( + array('phone' => '1', + 'fax' => '2', + 'cell' => '3'), + array('phone' => '555-4444', + 'fax' => '555-3333', + 'cell' => '760-1234') + )); ?> ]]> - + - {/foreach} - {/foreach} - ]]> +{foreach name=outer item=contact from=$contacts} +
+ {foreach key=key item=item from=$contact} + {$key}: {$item}
+ {/foreach} +{/foreach} +]]>
The above example will output: - fax: 2
- cell: 3
- phone: 555-4444
- fax: 555-3333
- cell: 760-1234
+
+ phone: 1
+ fax: 2
+ cell: 3
+
+ phone: 555-4444
+ fax: 555-3333
+ cell: 760-1234
]]>
@@ -154,14 +157,14 @@ $smarty->assign("contacts", $db->getAssoc($sql)); ?> ]]> -
- + + {$con.name} - {$con.nick}
+ {$con.name} - {$con.nick}
{/foreach} ]]> -
+
@@ -174,6 +177,10 @@ attribute of foreach + See {section} + for examples of the properties below as they are identical + + iteration @@ -220,6 +227,7 @@ + + diff --git a/docs/en/designers/language-variables.xml b/docs/en/designers/language-variables.xml index da000b39..cf67c0c4 100644 --- a/docs/en/designers/language-variables.xml +++ b/docs/en/designers/language-variables.xml @@ -4,12 +4,15 @@ Variables Smarty has several different types of variables. The type of the variable - depends on what symbol it is prefixed with (or enclosed within). + depends on what symbol it is prefixed or enclosed within. Variables in Smarty can be either displayed directly or used as arguments - for function attributes and modifiers, inside conditional expressions, - etc. To print a variable, simply enclose it in the delimiters so that it + for function + attributes and + modifiers, inside conditional expressions, + etc. To print a variable, simply enclose it in the + delimiters so that it is the only thing contained between them. Examples: Variables assigned from PHP - Variables that are assigned from PHP are referenced by preceding them with - a dollar sign $. Variables assigned from within the + Variables that are + assigned from PHP are referenced by preceding them with + a dollar sign $. Variables assigned from within a template with the {assign} function are also displayed this way. assigned variables - + php script + -Your last login was on {$lastLoginDate}. +assign('firstname', 'Doug'); +$smarty->assign('lastname', 'Evans'); +$smarty->assign('meetingPlace', 'New York'); + +$smarty->display('index.tpl'); + +?> ]]> - + + + where the content of index.tpl is: + + + +{* this will not work as $vars are case sensitive *} +This weeks meeting is in {$meetingplace}. +{* this will work *} +This weeks meeting is in {$meetingPlace}. +]]> + + This will output: -Your last login was on January 11th, 2001. +This weeks meeting is in . +This weeks meeting is in New York. ]]> @@ -40,7 +65,6 @@ Your last login was on January 11th, 2001. assign('Contacts', array('fax' => '555-222-9876', 'email' => 'zaphod@slartibartfast.com', @@ -66,7 +90,7 @@ $smarty->display('index.tpl'); this will output: - zaphod@slartibartfast.com
555-444-3333
@@ -87,12 +111,12 @@ zaphod@slartibartfast.com
assign('Contacts', - array('555-222-9876', - 'zaphod@slartibartfast.com', - array('555-444-3333', - '555-111-1234'))); +$smarty->assign('Contacts', array( + '555-222-9876', + 'zaphod@slartibartfast.com', + array('555-444-3333', + '555-111-1234') + )); $smarty->display('index.tpl'); ?> diff --git a/docs/en/designers/language-variables/language-config-variables.xml b/docs/en/designers/language-variables/language-config-variables.xml index ca3f893b..0ccceb28 100644 --- a/docs/en/designers/language-variables/language-config-variables.xml +++ b/docs/en/designers/language-variables/language-config-variables.xml @@ -86,13 +86,17 @@ rowBgColor = "#cccccc" ]]>
- - Config file variables cannot be used until - after they are loaded in from a config file. This procedure is - explained later in this document under config_load. - - See also Variables and $smarty reserved - variables + + Config file variables cannot be used until + after they are loaded in from a config file. This procedure is + explained later in this document under + {config_load}. + + + See also Variables and + $smarty reserved + variables + \ No newline at end of file +--> diff --git a/docs/en/designers/language-variables/language-variables-smarty.xml b/docs/en/designers/language-variables/language-variables-smarty.xml index 4adce2f6..09042d90 100644 --- a/docs/en/designers/language-variables/language-variables-smarty.xml +++ b/docs/en/designers/language-variables/language-variables-smarty.xml @@ -1,22 +1,22 @@ - {$smarty} reserved variables + {$smarty} reserved variable The reserved {$smarty} variable can be used to access several special template variables. The full list of them follows. - - Request variables - - The request variables such as get, post, cookies, server, - environment, and session variables can be accessed as demonstrated - in the examples below: - - - displaying request variables - + + Request variables + + The request variables + such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION + can be accessed as demonstrated in the examples below: + + + displaying request variables + - - - - - For historical reasons {$SCRIPT_NAME} can be accessed - directly though {$smarty.server.SCRIPT_NAME} is the - proposed way to access this value. - - - + + + + + For historical reasons {$SCRIPT_NAME} can be accessed + directly, although {$smarty.server.SCRIPT_NAME} is the + proposed way to access this value. + + + - - {$smarty.now} - - The current timestamp can be accessed with {$smarty.now}. The - number reflects the number of seconds passed since the so-called - Epoch (January 1, 1970) and can be passed directly to - date_format modifier for display purposes. - + + {$smarty.now} + + The current timestamp + can be accessed with {$smarty.now}. The number reflects the number of + seconds passed since the so-called Epoch (January 1, 1970) + and can be passed directly to the + date_format + modifier for display purposes. + using {$smarty.now} @@ -169,3 +171,4 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/docs/en/getting-started.xml b/docs/en/getting-started.xml index f682056a..4fed502d 100644 --- a/docs/en/getting-started.xml +++ b/docs/en/getting-started.xml @@ -9,14 +9,14 @@ Smarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation. This is best described in a situation where the application - programmer and the template designer play different roles, or in most + programmer and the template designer play different roles, or in most cases are not the same person. For example, let's say you are creating a web page that is displaying a - newspaper article. The article headline, tagline, author and body are - content elements, they contain no information about how they will be - presented. They are passed into Smarty by the application, then the + newspaper article. The article headline, tagline, author and body are + content elements, they contain no information about how they will be + presented. They are passed into Smarty by the application, then the template designer edits the templates and uses a combination of HTML tags and template tags to format the presentation of these elements (HTML tables, background colors, font sizes, style sheets, etc.) One day @@ -38,15 +38,15 @@ presentation logic. This does not mean that Smarty forces a separation of business and presentation logic. Smarty has no knowledge of which is which, so placing business logic in the template is your own doing. Also, if you - desire no logic in your templates you certainly can + desire no logic in your templates you certainly can do so by boiling the content down to text and variables only. - One of the unique aspects about Smarty is the template compiling. This - means Smarty reads the template files and creates PHP scripts from them. - Once they are created, they are executed from then on. Therefore there is - no costly template file parsing for each request, and each template can - take full advantage of PHP compiler cache solutions such as Zend + One of the unique aspects about Smarty is the template compiling. This + means Smarty reads the template files and creates PHP scripts from them. + Once they are created, they are executed from then on. Therefore there is + no costly template file parsing for each request, and each template can + take full advantage of PHP compiler cache solutions such as Zend Accelerator (&url.zend;) or PHP Accelerator (&url.php-accelerator;). @@ -76,9 +76,9 @@ - You can make custom functions - and custom variable modifiers, so the template language is extremely extensible. @@ -96,7 +96,7 @@ The if/elseif/else/endif constructs are passed to the - PHP parser, so the {if ...} expression syntax can be as simple or as + PHP parser, so the {if ...} expression syntax can be as simple or as complex as you like. @@ -112,7 +112,7 @@ It is possible to embed PHP code right in your template files, although - this may not be needed (nor recommended) since the engine is so + this may not be needed (nor recommended) since the engine is so customizable. @@ -136,7 +136,7 @@ - Plugin architecture + Plugin architecture @@ -160,25 +160,26 @@ upgrade to a new version of Smarty. - Smarty library files + Required Smarty library files - Smarty uses a PHP constant named SMARTY_DIR which is the system - filepath Smarty library directory. Basically, if your application can find - the Smarty.class.php file, you do not need to set - SMARTY_DIR, Smarty will figure it out on its own. Therefore, if - Smarty.class.php is not in your include_path, or you + Smarty uses a PHP constant named + SMARTY_DIR which is the system + file path to the Smarty 'libs/' directory. Basically, if your application + can find the Smarty.class.php file, you do not need + to set SMARTY_DIR + Smarty will figure it out on its own. Therefore, if + Smarty.class.php is not in your include_path, or you do not supply an absolute path to it in your application, then you must define SMARTY_DIR manually. SMARTY_DIR must include a trailing slash. @@ -247,11 +248,15 @@ $smarty = new Smarty; Now that the library files are in place, it's time to setup the Smarty - directories for your application. Smarty requires four directories which - are (by default) named templates, - templates_c, configs and cache. Each of these are definable by the + directories for your application. + + Smarty requires four directories which + are (by default) named 'templates/', + 'templates_c/', 'configs/' and 'cache/'. + + Each of these are definable by the Smarty class properties $template_dir, @@ -267,7 +272,7 @@ $smarty = new Smarty; Be sure you know the location of your web server document root. In our - example, the document root is /web/www.example.com/docs/. The Smarty directories are only accessed by the Smarty library and never accessed directly by the web browser. Therefore to avoid any security concerns, it @@ -285,20 +290,25 @@ $smarty = new Smarty; You will need as least one file under your document root, and that is the - script accessed by the web browser. We will call our script - index.php, and place it in a subdirectory under the + script accessed by the web browser. We will call our script + 'index.php', and place it in a subdirectory under the document root called /guestbook/. Technical Note - It is convenient to setup the web server so that "index.php" can be + It is convenient to setup the web server so that 'index.php' can be identified as the default directory index, so if you access - "http://www.example.com/guestbook/", the index.php script will be executed - without "index.php" in the URL. In Apache you can set this up by adding - "index.php" onto the end of your DirectoryIndex setting (separate each - entry with a space.) + http://www.example.com/guestbook/, the 'index.php' script will be executed + without adding 'index.php' to the URL. In Apache you can set this up by adding + "index.php" onto the end of your DirectoryIndex setting (separate + each entry with a space.) as in the httpd.conf example + + + DirectoryIndex + index.htm index.html index.php index.php3 default.html index.cgi + @@ -328,7 +338,8 @@ $smarty = new Smarty; - Smarty will need write access to the + Smarty will need write access + (windows users please ignore) to the $compile_dir and @@ -364,8 +375,8 @@ chmod 770 /web/www.example.com/smarty/guestbook/cache/ - We need to create the index.tpl file that Smarty will load. This will be - located in your $template_dir. + We need to create the 'index.tpl' file that Smarty will load. This will be + located in your $template_dir. @@ -383,7 +394,9 @@ Hello, {$name}! Technical Note - {* Smarty *} is a template comment. It is not required, but it is good + {* Smarty *} is a template + comment. + It is not required, but it is good practice to start all your template files with this comment. It makes the file easy to recognize regardless of the file extension. For example, text editors could recognize the file and turn on special @@ -392,8 +405,8 @@ Hello, {$name}! - Now lets edit index.php. We'll create an instance of Smarty, assign a - template variable and display the index.tpl file. In our example + Now lets edit 'index.php'. We'll create an instance of Smarty, assign a + template variable and display the 'index.tpl' file. In our example environment, "/usr/local/lib/php/Smarty" is in our include_path. Be sure you do the same, or use absolute paths. @@ -426,17 +439,17 @@ $smarty->display('index.tpl'); Technical Note In our example, we are setting absolute paths to all of the Smarty - directories. If /web/www.example.com/smarty/guestbook/ is - within your PHP include_path, then these settings are not necessary. + within your PHP include_path, then these settings are not necessary. However, it is more efficient and (from experience) less error-prone to - set them to absolute paths. This ensures that Smarty is getting files + set them to absolute paths. This ensures that Smarty is getting files from the directories you intended. - Now load the index.php file from your web browser. + Now load the index.php file from your web browser. You should see "Hello, Ned!" @@ -456,8 +469,8 @@ $smarty->display('index.tpl'); initialize your Smarty environment. So instead of repeatedly setting directory paths, assigning the same vars, etc., we can do that in one place. Lets create a new directory "/php/includes/guestbook/" and make a new file - called setup.php. In our example environment, - "/php/includes" is in our include_path. Be sure you set this up too, or + called setup.php. In our example environment, + "/php/includes" is in our include_path. Be sure you set this up too, or use absolute file paths. @@ -480,7 +493,7 @@ class Smarty_GuestBook extends Smarty { function Smarty_GuestBook() { - // Class Constructor. + // Class Constructor. // These automatically get set with each new instance. $this->Smarty(); @@ -524,7 +537,7 @@ $smarty->display('index.tpl'); Now you see it is quite simple to bring up an instance of Smarty, just use - Smarty_GuestBook which automatically initializes everything for our + Smarty_GuestBook which automatically initializes everything for our application. @@ -553,3 +566,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/docs/en/language-snippets.ent b/docs/en/language-snippets.ent index 1f573d71..cf9a95d7 100644 --- a/docs/en/language-snippets.ent +++ b/docs/en/language-snippets.ent @@ -12,10 +12,12 @@ '> - As an optional third parameter, you can pass a compile_id. + As an optional third parameter, you can pass a +$compile_id. This is in the event that you want to compile different versions of the same template, such as having separate templates compiled - for different languages. Another use for compile_id is when you + for different languages. Another use for + $compile_id is when you use more than one $template_dir but only one diff --git a/docs/en/preface.xml b/docs/en/preface.xml index 32a63b56..a6673480 100644 --- a/docs/en/preface.xml +++ b/docs/en/preface.xml @@ -66,7 +66,7 @@ meticulous and overbearing the PHP language may look to the average designer, and this could be masked with a much simpler templating syntax. So what if we combined the two strengths? Thus, Smarty was - born... + born... :-) diff --git a/docs/en/programmers/api-functions.xml b/docs/en/programmers/api-functions.xml index 703c93a4..921a7d2b 100644 --- a/docs/en/programmers/api-functions.xml +++ b/docs/en/programmers/api-functions.xml @@ -1,7 +1,7 @@ - Methods + Smarty Class Methods() &programmers.api-functions.api-append; &programmers.api-functions.api-append-by-ref; &programmers.api-functions.api-assign; diff --git a/docs/en/programmers/api-functions/api-append-by-ref.xml b/docs/en/programmers/api-functions/api-append-by-ref.xml index 520394a0..e0117d13 100644 --- a/docs/en/programmers/api-functions/api-append-by-ref.xml +++ b/docs/en/programmers/api-functions/api-append-by-ref.xml @@ -2,11 +2,11 @@ - append_by_ref - + append_by_ref() + append values by reference - + <title>Description voidappend_by_ref stringvarname diff --git a/docs/en/programmers/api-functions/api-append.xml b/docs/en/programmers/api-functions/api-append.xml index 9e62ae50..f5f84dc1 100644 --- a/docs/en/programmers/api-functions/api-append.xml +++ b/docs/en/programmers/api-functions/api-append.xml @@ -2,11 +2,11 @@ - append - - + append() + append an element to an assigned array + - + <title>Description voidappend mixedvar @@ -18,7 +18,7 @@ boolmerge - This is used to append an element to an assigned array. If you append +If you append to a string value, it is converted to an array value and then appended to. You can explicitly pass name/value pairs, or associative arrays containing the name/value pairs. If you pass the optional third diff --git a/docs/en/programmers/api-functions/api-assign-by-ref.xml b/docs/en/programmers/api-functions/api-assign-by-ref.xml index 5ba6cfb8..52b8b04d 100644 --- a/docs/en/programmers/api-functions/api-assign-by-ref.xml +++ b/docs/en/programmers/api-functions/api-assign-by-ref.xml @@ -2,18 +2,19 @@ - assign_by_ref - + assign_by_ref() + assign values by reference - + <title>Description voidassign_by_ref stringvarname mixedvar - This is used to assign values to the templates by reference instead of + This is used to assign() + values to the templates by reference instead of making a copy. See the PHP manual on variable referencing for an explanation. @@ -29,7 +30,7 @@ - assign_by_ref + assign_by_ref() - assign - + assign() + assign values to the templates - + <title>Description voidassign mixedvar @@ -17,13 +17,12 @@ mixedvar - This is used to assign values to the templates. You can - explicitly pass name/value pairs, or associative arrays + You can explicitly pass name/value pairs, or associative arrays containing the name/value pairs. - assign - + assign() + assign('Address', $address); // passing an associative array $smarty->assign(array('city' => 'Lincoln', 'state' => 'Nebraska')); + +// passing a row from a database (eg adodb) +$sql = 'select id, name, email from contacts where contact ='.$id; +$smarty->assign('contact', $db->getRow($sql)); ?> ]]> - + + + Access these in the template with + + + +]]> + + For more complex array assignments see + {foreach} + and + {section} + + + See also assign_by_ref(), + get_template_vars(), clear_assign(), - append(), - {assign}, + append() and - get_template_vars() + {assign} diff --git a/docs/en/programmers/api-functions/api-clear-all-assign.xml b/docs/en/programmers/api-functions/api-clear-all-assign.xml index f2a53657..5cd33741 100644 --- a/docs/en/programmers/api-functions/api-clear-all-assign.xml +++ b/docs/en/programmers/api-functions/api-clear-all-assign.xml @@ -2,25 +2,33 @@ - clear_all_assign - + clear_all_assign() + clears the values of all assigned variables - + <title>Description voidclear_all_assign - - This clears the values of all assigned variables. - - clear_all_assign + clear_all_assign() assign('Name', 'Fred'); +$smarty->assign('Address', $address); + +// will output above +print_r( $smarty->get_template_vars() ); + // clear all assigned variables $smarty->clear_all_assign(); + +// will output nothing +print_r( $smarty->get_template_vars() ); + ?> ]]> diff --git a/docs/en/programmers/api-functions/api-clear-all-cache.xml b/docs/en/programmers/api-functions/api-clear-all-cache.xml index a42febe1..3f50ddf2 100644 --- a/docs/en/programmers/api-functions/api-clear-all-cache.xml +++ b/docs/en/programmers/api-functions/api-clear-all-cache.xml @@ -2,17 +2,17 @@ - clear_all_cache - + clear_all_cache() + clears the entire template cache - + <title>Description voidclear_all_cache intexpire_time - This clears the entire template cache. As an optional + As an optional parameter, you can supply a minimum age in seconds the cache files must be before they will get cleared. @@ -29,7 +29,8 @@ $smarty->clear_all_cache(); See also - clear_cache() + clear_cache(), + is_cached() and caching diff --git a/docs/en/programmers/api-functions/api-clear-assign.xml b/docs/en/programmers/api-functions/api-clear-assign.xml index 11f960d9..e1565a1d 100644 --- a/docs/en/programmers/api-functions/api-clear-assign.xml +++ b/docs/en/programmers/api-functions/api-clear-assign.xml @@ -2,29 +2,28 @@ - clear_assign - + clear_assign() + clears the value of an assigned variable - + <title>Description voidclear_assign mixedvar - This clears the value of an assigned variable. This - can be a single value, or an array of values. +This can be a single value, or an array of values. - clear_assign + clear_assign() clear_assign("Name"); +$smarty->clear_assign('Name'); -// clear multiple variables -$smarty->clear_assign(array("Name", "Address", "Zip")); +// clears multiple variables +$smarty->clear_assign(array('Name', 'Address', 'Zip')); ?> ]]> @@ -33,6 +32,7 @@ $smarty->clear_assign(array("Name", "Address", "Zip")); See also clear_all_assign(), clear_config(), + get_template_vars(), assign() and append() diff --git a/docs/en/programmers/api-functions/api-clear-cache.xml b/docs/en/programmers/api-functions/api-clear-cache.xml index cfd172cb..6a19cd2d 100644 --- a/docs/en/programmers/api-functions/api-clear-cache.xml +++ b/docs/en/programmers/api-functions/api-clear-cache.xml @@ -2,46 +2,52 @@ - clear_cache - + clear_cache() + clears the cache for a specific template - + <title>Description voidclear_cache stringtemplate stringcache_id - stringcompile_id + stringcompile_id + intexpire_time - This clears the cache for a specific template. - If you have multiple caches for this template, you can clear a specific - cache by supplying the cache_id as the second - parameter. - You can also pass a compile_id as a third parameter. - You can "group" templates together so they can be removed as a group. See the + If you have multiple caches + for a template, you can clear a specific + cache by supplying the cache_id as the second + parameter. + You can also pass a + $compile_id + as a third parameter. + You can "group" templates + together so they can be removed as a group. See the caching section for more information. As an optional fourth parameter, you can supply a minimum age in seconds the cache file must be before it will get cleared. - clear_cache + clear_cache() clear_cache("index.tpl"); +$smarty->clear_cache('index.tpl'); // clear the cache for a particular cache id in an multiple-cache template -$smarty->clear_cache("index.tpl", "CACHEID"); +$smarty->clear_cache('index.tpl', 'CACHEID'); ?> ]]> See also + clear_all_cache() + and caching. @@ -66,3 +72,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/docs/en/programmers/api-functions/api-clear-compiled-tpl.xml b/docs/en/programmers/api-functions/api-clear-compiled-tpl.xml index 1a234fd0..c212e89c 100644 --- a/docs/en/programmers/api-functions/api-clear-compiled-tpl.xml +++ b/docs/en/programmers/api-functions/api-clear-compiled-tpl.xml @@ -2,28 +2,31 @@ - clear_compiled_tpl - + clear_compiled_tpl() + clears the compiled version of the specified template resource - + <title>Description voidclear_compiled_tpl stringtpl_file - stringcompile_id + stringcompile_id + intexp_time This clears the compiled version of the specified template resource, or all compiled template files if one is not specified. - if you pass a compile_id only the compiled template for this - specific compile_id is cleared. if you pass an exp_time, then only + If you pass a $compile_id + only the compiled template for this + specific $compile_id + is cleared. if you pass an exp_time, then only compiled templates older than exp_time seconds are cleared, by default all compiled templates are cleared regardless of their age. This function is for advanced use only, not normally needed. - clear_compiled_tpl + clear_compiled_tpl() + diff --git a/docs/en/programmers/api-functions/api-clear-config.xml b/docs/en/programmers/api-functions/api-clear-config.xml index 4f55ae78..48a9dd62 100644 --- a/docs/en/programmers/api-functions/api-clear-config.xml +++ b/docs/en/programmers/api-functions/api-clear-config.xml @@ -2,11 +2,11 @@ - clear_config - + clear_config() + clears assigned config variables - + <title>Description voidclear_config stringvar @@ -18,7 +18,7 @@ supplied, only that variable is cleared. - clear_config + clear_config() clear_config('foobar'); See also + get_config_vars(), config variables, config files, {config_load}, diff --git a/docs/en/programmers/api-functions/api-config-load.xml b/docs/en/programmers/api-functions/api-config-load.xml index 2fcaa467..c2fd8bd0 100644 --- a/docs/en/programmers/api-functions/api-config-load.xml +++ b/docs/en/programmers/api-functions/api-config-load.xml @@ -2,11 +2,11 @@ - config_load - + config_load() + loads config file data and assigns it to the template - + <title>Description voidconfig_load stringfile @@ -35,7 +35,7 @@ - config_load + config_load() config_load('my.conf', 'foobar'); See also {config_load}, + get_config_vars(), clear_config(), and config variables diff --git a/docs/en/programmers/api-functions/api-display.xml b/docs/en/programmers/api-functions/api-display.xml index 4409d554..bd7d1f93 100644 --- a/docs/en/programmers/api-functions/api-display.xml +++ b/docs/en/programmers/api-functions/api-display.xml @@ -2,19 +2,22 @@ - display - + display() + displays the template - + <title>Description voiddisplay stringtemplate stringcache_id - stringcompile_id + stringcompile_id + - This displays the template. Supply a valid fetch(). + Supply a valid template resource type and path. As an optional second parameter, you can pass a $cache id. @@ -23,7 +26,7 @@ ¶meter.compileid; - display + display() display("index.tpl"); Use the syntax for template resources to - display files outside of the $template_dir directory. + display files outside of the + $template_dir directory. - function display template resource examples + function display() template resource examples display("/usr/local/include/templates/header.tpl"); +$smarty->display('/usr/local/include/templates/header.tpl'); // absolute filepath (same thing) -$smarty->display("file:/usr/local/include/templates/header.tpl"); +$smarty->display('file:/usr/local/include/templates/header.tpl'); // windows absolute filepath (MUST use "file:" prefix) -$smarty->display("file:C:/www/pub/templates/header.tpl"); +$smarty->display('file:C:/www/pub/templates/header.tpl'); // include from template resource named "db" -$smarty->display("db:header.tpl"); +$smarty->display('db:header.tpl'); ?> ]]> @@ -106,3 +110,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/docs/en/programmers/api-functions/api-fetch.xml b/docs/en/programmers/api-functions/api-fetch.xml index ac445b89..6d75dcab 100644 --- a/docs/en/programmers/api-functions/api-fetch.xml +++ b/docs/en/programmers/api-functions/api-fetch.xml @@ -2,19 +2,21 @@ - fetch - + fetch() + returns the template output - + <title>Description stringfetch stringtemplate stringcache_id - stringcompile_id + string$compile_id + - This returns the template output instead of displaying it. + This returns the template output instead of + displaying it. Supply a valid template resource type and path. As an optional second parameter, you can pass a @@ -22,45 +24,101 @@ section for more information. ¶meter.compileid; - - - fetch - + + + +fetch() + caching = true; // only do db calls if cache doesn't exist -if(!$smarty->is_cached("index.tpl")) { +if(!$smarty->is_cached('index.tpl')) { // dummy up some data - $address = "245 N 50th"; + $address = '245 N 50th'; $db_data = array( - "City" => "Lincoln", - "State" => "Nebraska", - "Zip" => "68502" + 'City' => 'Lincoln', + 'State' => 'Nebraska', + 'Zip' => '68502' ); - $smarty->assign("Name","Fred"); - $smarty->assign("Address",$address); + $smarty->assign('Name','Fred'); + $smarty->assign('Address',$address); $smarty->assign($db_data); } // capture the output -$output = $smarty->fetch("index.tpl"); +$output = $smarty->fetch('index.tpl'); // do something with $output here echo $output; ?> ]]> - - + + + + + + +Using fetch() to send an email + + The email_body.txt template + + + + + The email_disclaimer.txt template + + + + + + and the php script using the PHP + mail() function + + +getRow($sql); +$smarty->assign('contact', $contact); + +mail($contact['email'], 'Subject', $smarty->fetch('email_body.txt')); + +?> +]]> + + + + + See also {fetch} @@ -92,3 +150,5 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + + diff --git a/docs/en/programmers/api-functions/api-get-config-vars.xml b/docs/en/programmers/api-functions/api-get-config-vars.xml index 8a8fda88..ddede30a 100644 --- a/docs/en/programmers/api-functions/api-get-config-vars.xml +++ b/docs/en/programmers/api-functions/api-get-config-vars.xml @@ -2,24 +2,26 @@ - get_config_vars - + get_config_vars() + returns the given loaded config variable value - + <title>Description arrayget_config_vars stringvarname - This returns the given loaded config variable value. If no parameter - is given, an array of all loaded config variables is returned. + If no parameter is given, an array of all loaded + config variables + is returned. - get_config_vars + get_config_vars() get_config_vars('foo'); diff --git a/docs/en/programmers/api-functions/api-get-registered-object.xml b/docs/en/programmers/api-functions/api-get-registered-object.xml index 2a00ecd3..d400ffda 100644 --- a/docs/en/programmers/api-functions/api-get-registered-object.xml +++ b/docs/en/programmers/api-functions/api-get-registered-object.xml @@ -2,26 +2,27 @@ - get_registered_object - + get_registered_object() + returns a reference to a registered object - + <title>Description arrayget_registered_object stringobject_name - This returns a reference to a registered object. This is useful + This is useful from within a custom function when you need direct access to a - registered object. + registered object. See + objects for more info. - get_registered_object + get_registered_object() + + See also + register_object(), + unregister_object() + and + objects section + - get_template_vars - + get_template_vars() + returns assigned variable value(s) - + <title>Description arrayget_template_vars stringvarname - This returns the given assigned variable value. If no parameter - is given, an array of all assigned variables is returned. + If no parameter + is given, an array of all assigned + variables are returned. get_template_vars @@ -35,7 +36,10 @@ print_r($tpl_vars); See also assign(), {assign}, - clear_assign() + assign_by_ref(), + append(), + clear_assign(), + clear_all_assign() and get_config_vars() diff --git a/docs/en/programmers/api-functions/api-is-cached.xml b/docs/en/programmers/api-functions/api-is-cached.xml index 5acc0273..75ba70a2 100644 --- a/docs/en/programmers/api-functions/api-is-cached.xml +++ b/docs/en/programmers/api-functions/api-is-cached.xml @@ -2,65 +2,69 @@ - is_cached - + is_cached() + returns true if there is a valid cache for this template - + <title>Description boolis_cached stringtemplate stringcache_id - stringcompile_id + stringcompile_id + - This returns &true; if there is a valid cache for this template. This only works if $caching is set to true. + linkend="variable.caching">$caching is set to true. See also the + caching section. - is_cached + is_cached() caching = true; -if(!$smarty->is_cached("index.tpl")) { +if(!$smarty->is_cached('index.tpl')) { // do database calls, assign vars here } -$smarty->display("index.tpl"); +$smarty->display('index.tpl'); ?> ]]> You can also pass a $cache id as an optional second parameter - in case you want multiple caches for the given template. + in case you want + multiple caches + for the given template. You can supply a $compile id as an optional third parameter. - If you omit that parameter the persistent + If you omit that parameter the persistent $compile_id is used. - If you do not want to pass a cache id but want to pass a compile - id you have to pass null as cache id. + If you do not want to pass a cache id but want to pass a + $compile_id + you have to pass null as cache id. - is_cached with multiple-cache template + is_cached() with multiple-cache template caching = true; -if(!$smarty->is_cached("index.tpl", "FrontPage")) { +if(!$smarty->is_cached('index.tpl', 'FrontPage')) { // do database calls, assign vars here } -$smarty->display("index.tpl", "FrontPage"); +$smarty->display('index.tpl', 'FrontPage'); ?> ]]> @@ -70,19 +74,29 @@ $smarty->display("index.tpl", "FrontPage"); Technical Note - If is_cached returns true it actually loads the + If is_cached() returns true it actually loads the cached output and stores it internally. Any subsequent call to display() or fetch() will return this internally stored output and does not try to reload the cache file. This prevents a race condition that may occur when a - second process clears the cache between the calls to is_cached and to - display in the example above. This also means calls to + second process clears the cache between the calls to is_cached() and to + display() + in the example above. This also means calls to clear_cache() and other changes of the cache-settings may have no effect after is_cached() returned true. + + + See also + clear_cache(), + clear_all_cache(), + and + caching section. + + + diff --git a/docs/en/programmers/api-functions/api-load-filter.xml b/docs/en/programmers/api-functions/api-load-filter.xml index 9cde5235..328c109f 100644 --- a/docs/en/programmers/api-functions/api-load-filter.xml +++ b/docs/en/programmers/api-functions/api-load-filter.xml @@ -2,18 +2,18 @@ - load_filter - + load_filter() + load a filter plugin - + <title>Description voidload_filter stringtype stringname - This function can be used to load a filter plugin. The first + The first argument specifies the type of the filter to load and can be one of the following: 'pre', 'post', or 'output'. The second argument specifies the name of the filter plugin, for example, 'trim'. @@ -23,13 +23,28 @@ load_filter('pre', 'trim'); // load prefilter named 'trim' -$smarty->load_filter('pre', 'datefooter'); // load another prefilter named 'datefooter' -$smarty->load_filter('output', 'compress'); // load output filter named 'compress' + +// load prefilter named 'trim' +$smarty->load_filter('pre', 'trim'); + +// load another prefilter named 'datefooter' +$smarty->load_filter('pre', 'datefooter'); + +// load output filter named 'compress' +$smarty->load_filter('output', 'compress'); + ?> ]]> + + See also + register_prefilter(), + register_postfilter(), + register_outputfilter() + and + Advanced features. + - register_block - + register_block() + dynamically register block functions plugins - + <title>Description voidregister_block stringname @@ -15,7 +15,8 @@ mixedcache_attrs - Use this to dynamically register block functions plugins. + Use this to dynamically register + block functions plugins. Pass in the block function name, followed by the PHP function callback that implements it. @@ -33,18 +34,18 @@ cacheable and cache_attrs - can be omitted in most cases. See Controlling Cacheability of Plugins' Output on how to use them properly. - register_block + register_block() register_block("translate", "do_translation"); +$smarty->register_block('translate', 'do_translation'); -function do_translation ($params, $content, &$smarty, &$repeat) +function do_translation ($params, $content, &$smarty, &$repeat) { if (isset($content)) { $lang = $params['lang']; @@ -67,6 +68,14 @@ Hello, world! ]]> + + + See also + unregister_block() + and + Plugin Block Functions. + + - register_compiler_function - + register_compiler_function() + dynamically register a compiler function plugin - + <title>Description boolregister_compiler_function stringname @@ -14,17 +14,22 @@ boolcacheable - Use this to dynamically register a compiler function plugin. - Pass in the compiler function name, followed by the PHP - function that implements it. + Pass in the + compiler function name, + followed by the PHP function that implements it. - The php-function callback impl can be either (a) a string - containing the function name or (b) an array of the form - array(&$object, $method) with + The php-function callback impl can be either: + + + (a) a string containing the function name + + (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string - containing the mehod-name or (c) an array of the form + containing the mehod-name + + (c) an array of the form array(&$class, $method) with $class being a classname and $method being a class method of that @@ -35,6 +40,16 @@ most cases. See Controlling Cacheability of Plugins' Output on how to it properly. + + +See also +unregister_compiler_function() + +and +Plugin Compiler Functions. + + - register_function - + register_function() + dynamically register template function plugins - + <title>Description voidregister_function stringname mixedimpl boolcacheable - mixedcache_attrs + mixedcache_attrs + - Use this to dynamically register template function plugins. - Pass in the template function name, followed by the PHP - function name that implements it. + Pass in the template function + name, followed by the PHP function name that implements it. - The php-function callback impl can be either (a) a string - containing the function name or (b) an array of the form + The php-function callback impl can be either + + + (a) a string containing the function name + + + (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string - containing the mehod-name or (c) an array of the form - array(&$class, $method) with - $class being a classname and + containing the mehod-name + + + (c) an array of the form array(&$class, $method) + with $class being a classname and $method being a class method of that class. - cacheable and cache_attrs can be - omitted in most cases. See Controlling Cacheability of Plugins' Output + cacheable and cache_attrs can be + omitted in most cases. See Controlling Cacheability of Plugins' Output on how to use them properly. - register_function + register_function() register_function("date_now", "print_current_date"); +$smarty->register_function('date_now', 'print_current_date'); -function print_current_date($params) +function print_current_date($params) { if(empty($params['format'])) { $format = "%b %e, %Y"; @@ -53,13 +60,30 @@ function print_current_date($params) return strftime($format,time()); } } - -// now you can use this in Smarty to print the current date: {date_now} -// or, {date_now format="%Y/%m/%d"} to format it. ?> ]]> - + + And in the template + + + + + + + +See also +unregister_function() +and +Plugin functions +. + + + diff --git a/docs/en/programmers/api-functions/api-register-modifier.xml b/docs/en/programmers/api-functions/api-register-modifier.xml index 3a42c765..803a8b94 100644 --- a/docs/en/programmers/api-functions/api-register-modifier.xml +++ b/docs/en/programmers/api-functions/api-register-modifier.xml @@ -2,18 +2,18 @@ - register_modifier - + register_modifier() + dynamically register modifier plugin - + <title>Description voidregister_modifier stringname mixedimpl - Use this to dynamically register modifier plugin. Pass in the + Pass in the template modifier name, followed by the PHP function that it implements it. @@ -30,25 +30,33 @@ class. - register_modifier - + register_modifier() + register_modifier('sslash', 'stripslashes'); -$smarty->register_modifier("sslash", "stripslashes"); - -// now you can use {$var|sslash} to strip slashes from variables ?> ]]> - + +template + + +]]> + + See also unregister_modifier(), register_function(), modifiers, - Extending Smarty with plugins and Plugin modifiers, diff --git a/docs/en/programmers/api-functions/api-register-object.xml b/docs/en/programmers/api-functions/api-register-object.xml index 4758a1bf..9d301ff0 100644 --- a/docs/en/programmers/api-functions/api-register-object.xml +++ b/docs/en/programmers/api-functions/api-register-object.xml @@ -2,26 +2,27 @@ - register_object - + register_object() + register an object for use in the templates - + <title>Description voidregister_object stringobject_name objectobject - arrayallowed_methods_properties + arrayallowed_methods_properties + booleanformat arrayblock_methods - This is to register an object for use in the templates. See the - object section - of the manual for examples. + See the + objects section + for examples. - See Also unregister_object(). + See also unregister_object(). @@ -46,3 +47,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/docs/en/programmers/api-functions/api-register-outputfilter.xml b/docs/en/programmers/api-functions/api-register-outputfilter.xml index b9433f4c..3fcd5a1f 100644 --- a/docs/en/programmers/api-functions/api-register-outputfilter.xml +++ b/docs/en/programmers/api-functions/api-register-outputfilter.xml @@ -2,34 +2,55 @@ - register_outputfilter - + register_outputfilter() + dynamically register outputfilters - + <title>Description voidregister_outputfilter mixedfunction - Use this to dynamically register outputfilters to operate on - a template's output before it is displayed. See + Use this to dynamically register + outputfilters to operate on + a template's output before it is + displayed. See template output filters for more information on how to set up an output filter function. - The php-function callback function can be either (a) a string - containing the function name or (b) an array of the form + The php-function callback function can be either + + + (a) a string + containing the function name + + + (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string - containing the mehod-name or (c) an array of the form + containing the mehod-name + + + (c) an array of the form array(&$class, $method) with $class being a classname and $method being a class method of that class. + +See also +unregister_outputfilter(), +register_prefilter(), +register_postfilter(), +load_filter(), +and +template +output filters. + - register_postfilter - + register_postfilter() + dynamically register postfilters - + <title>Description voidregister_postfilter mixedfunction - Use this to dynamically register postfilters to run templates + Use this to dynamically register + postfilters to run templates through after they are compiled. See template postfilters for more information on how to setup a postfiltering function. - The php-function callback function can be either (a) a string - containing the function name or (b) an array of the form + The php-function callback function can be either + + + (a) a string containing the function name + + + (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string - containing the mehod-name or (c) an array of the form + containing the mehod-name + + + (c) an array of the form array(&$class, $method) with $class being a classname and $method being a class method of that class. + + + See also + unregister_postfilter(), + register_prefilter(), + register_ouputfilter(), + load_filter(), + and + template + output filters. + + - register_prefilter - + register_prefilter() + dynamically register prefilters - + <title>Description voidregister_prefilter mixedfunction - Use this to dynamically register prefilters to run templates - through before they are compiled. See prefilters + to run templates through before they are compiled. See template prefilters for more information on how to setup a prefiltering function. - The php-function callback function can be either (a) a string - containing the function name or (b) an array of the form + The php-function callback function can be either + + + (a) a string + containing the function name + + + (b) an array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string - containing the mehod-name or (c) an array of the form + containing the mehod-name + + + (c) an array of the form array(&$class, $method) with $class being a classname and $method being a class method of that class. + + See also + unregister_prefilter(), + register_postfilter(), + register_ouputfilter(), + load_filter(), + and + template + output filters. + - register_resource - + register_resource() + dynamically register resources - + <title>Descrption voidregister_resource stringname arrayresource_funcs - Use this to dynamically register a resource plugin with Smarty. + Use this to dynamically register a + resource plugin + with Smarty. Pass in the name of the resource and the array of PHP functions implementing it. See template resources @@ -40,18 +42,28 @@ "secure" and "trusted". - register_resource + register_resource() register_resource("db", array("db_get_template", -"db_get_timestamp", -"db_get_secure", -"db_get_trusted")); +$smarty->register_resource('db', array( + 'db_get_template', + 'db_get_timestamp', + 'db_get_secure', + 'db_get_trusted') + ); ?> ]]> + + + See also + unregister_resource() + and + template resources + + - template_exists - + template_exists() + checks whether the specified template exists - + <title>Description booltemplate_exists stringtemplate - This function checks whether the specified template exists. It can - accept either a path to the template on the filesystem or a + It can accept either a path to the template on the filesystem or a resource string specifying the template. diff --git a/docs/en/programmers/api-functions/api-trigger-error.xml b/docs/en/programmers/api-functions/api-trigger-error.xml index 2f03b9e4..9abcf843 100644 --- a/docs/en/programmers/api-functions/api-trigger-error.xml +++ b/docs/en/programmers/api-functions/api-trigger-error.xml @@ -2,11 +2,11 @@ - trigger_error - + trigger_error() + output an error message - + <title>Description voidtrigger_error stringerror_msg @@ -15,9 +15,9 @@ This function can be used to output an error message using Smarty. level parameter can be one of the values - used for + used for the PHP trigger_error() - PHP function, i.e. E_USER_NOTICE, + function, i.e. E_USER_NOTICE, E_USER_WARNING, etc. By default it's E_USER_WARNING. diff --git a/docs/en/programmers/api-functions/api-unregister-block.xml b/docs/en/programmers/api-functions/api-unregister-block.xml index ceff8082..44337d4e 100644 --- a/docs/en/programmers/api-functions/api-unregister-block.xml +++ b/docs/en/programmers/api-functions/api-unregister-block.xml @@ -2,19 +2,28 @@ - unregister_block - + unregister_block() + dynamically unregister block function plugins - + <title>Description voidunregister_block stringname - Use this to dynamically unregister block function plugin. + Use this to dynamically unregister + block function plugins. Pass in the block function name. + + + See also + register_block() + and + Block Functions Plugins. + + - unregister_compiler_function - + unregister_compiler_function() + dynamically unregister a compiler function - + <title>Description voidunregister_compiler_function stringname - Use this to dynamically unregister a compiler function. Pass in + Pass in the name of the compiler function. + + + See also + register_compiler_function() + + and + Plugin Compiler Functions. + + - unregister_modifier - + unregister_modifier() + dynamically unregister modifier plugin - + <title>Description voidunregister_modifier stringname - Use this to dynamically unregister modifier plugin. Pass in the - template modifier name. + Pass in the template modifier name. - unregister_modifier + unregister_modifier() unregister_modifier("strip_tags"); +// we don't want template designers to strip tags from elements +$smarty->unregister_modifier('strip_tags'); + ?> ]]> + + See also + register_modifier() + and + Plugin modifiers, + - unregister_object - + unregister_object() + dynamically unregister an object - + <title>Description voidunregister_object stringobject_name - - Use this to unregister an object. - - See also register_object object section + + + See also + register_object() + and + objects section + - unregister_outputfilter - + unregister_outputfilter() + dynamically unregister an output filter - + <title>Description voidunregister_outputfilter stringfunction_name @@ -14,6 +14,14 @@ Use this to dynamically unregister an output filter. + + + See also + register_outputfilter() + and + template + output filters. + - unregister_postfilter - + unregister_postfilter() + dynamically unregister a postfilter - + <title>Description voidunregister_postfilter stringfunction_name - - Use this to dynamically unregister a postfilter. - + + + See also + register_postfilter() + and + template + post filters. + + - unregister_prefilter - + unregister_prefilter() + dynamically unregister a prefilter - + <title>Description voidunregister_prefilter stringfunction_name - - Use this to dynamically unregister a prefilter. - + + + See also + register_prefilter() + and + pre filters. + + - unregister_resource - + unregister_resource() + dynamically unregister a resource plugin - + <title>Description voidunregister_resource stringname - Use this to dynamically unregister a resource plugin. Pass in the + Pass in the name of the resource. - unregister_resource - + unregister_resource() + unregister_resource("db"); + +$smarty->unregister_resource('db'); + ?> ]]> + + + See also + register_resource() + and + template resources + + - Variables + Smarty Class Variables &programmers.api-variables.variable-template-dir; &programmers.api-variables.variable-compile-dir; diff --git a/docs/en/programmers/api-variables/variable-cache-dir.xml b/docs/en/programmers/api-variables/variable-cache-dir.xml index 8d36f608..dc019e73 100644 --- a/docs/en/programmers/api-variables/variable-cache-dir.xml +++ b/docs/en/programmers/api-variables/variable-cache-dir.xml @@ -6,11 +6,16 @@ This is the name of the directory where template caches are stored. By default this is "./cache", meaning that it will look for the cache directory in the same directory as the executing - php script. You can also use your own + php script. + This directory must + be writeable by the web server. + You can also use your own custom cache handler function to control cache files, which will ignore this setting. + See also + $use_sub_dirs. Technical Note @@ -26,7 +31,18 @@ the web server document root. - + + + See also + $caching, + $use_sub_dirs, + $cache_lifetime, + $cache_handler_func, + $cache_modified_check + and + Caching section. + + - - $cache_modified_check - - If set to true, Smarty will respect the If-Modified-Since - header sent from the client. If the cached file timestamp has - not changed since the last visit, then a "304 Not Modified" - header will be sent instead of the content. This works only on - cached content without insert tags. - - + +$cache_modified_check + + If set to true, Smarty will respect the If-Modified-Since + header sent from the client. If the cached file timestamp has + not changed since the last visit, then a "304 Not Modified" + header will be sent instead of the content. This works only on + cached content without + {insert} + tags. + + + + See also + $caching, + $cache_lifetime, + $cache_handler_func, + and + Caching section. + + + $use_sub_dirs - - Set this to false if your PHP environment does not allow the creation of - sub directories by Smarty. Sub directories are more efficient, so use them - if you can. - + +Smarty will create subdirectories under the +templates_c and +cache +directories if $use_sub_dirs is set to true. +In an environment where there are potentially tens of thousands of files created, +this may help the filesystem speed. +On the other hand, some environments do not allow PHP processes to +create directories, so this must be disabled. The default is false (disabled). +Sub directories are more efficient, so use them if you can. + + +Theoretically you get much better perfomance on a filesystem with 10 +directories each having 100 files, than with 1 directory having 1000 +files. This was certainly the case with Solaris 7 (UFS)... with newer +filesystems such as ext3 and especially reiserfs, the difference is almost +nothing. + + +Technical Note + +$use_sub_dirs=true doesn't work with safe_mode=On, that's why it's +switchable and why it's off by default. + + - Technical Note + Note Since Smarty-2.6.2 $use_sub_dirs defaults to false. - See also $template_dir, + See also $compile_dir, - $config_dir, - $plugins_dir - and + and $cache_dir. @@ -41,4 +59,5 @@ End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 ---> \ No newline at end of file +--> + diff --git a/docs/en/programmers/caching/caching-setting-up.xml b/docs/en/programmers/caching/caching-setting-up.xml index beef17f9..f5281fe7 100644 --- a/docs/en/programmers/caching/caching-setting-up.xml +++ b/docs/en/programmers/caching/caching-setting-up.xml @@ -3,8 +3,8 @@ Setting Up Caching - The first thing to do is enable caching. This is done by setting $caching = true (or 1.) + The first thing to do is enable caching by setting $caching = true (or 1.) enabling caching @@ -49,7 +49,7 @@ $smarty->display('index.tpl'); linkend="variable.cache.lifetime">$cache_lifetime for details. - setting cache_lifetime per cache + setting $cache_lifetime per cache display('index.tpl'); You can clear all the cache files with the clear_all_cache() function, or individual cache files (or groups) with the clear_cache() function. + linkend="api.clear.cache">clear_cache() function. clearing the cache @@ -175,7 +175,7 @@ $smarty->display('index.tpl'); - + - - Constants + +Constants - - SMARTY_DIR + + SMARTY_DIR This should be the full system path to the location of the Smarty class files. If this is not defined, then Smarty will attempt to determine the appropriate value automatically. If defined, the path - must end with a slash. + must end with a slash. SMARTY_DIR ]]> - - See also - $smarty.const - - - + + See also + $smarty.const + and + $php_handling constants + + + + SMARTY_CORE_DIR This should be the full system path to the location of the Smarty core - files. If not defined, Smarty will default this constant to the internals/ + files. If not defined, Smarty will default this constant to the + libs/ sub-directory below SMARTY_DIR. If defined, the path must end with a slash. @@ -44,9 +56,10 @@ require_once(SMARTY_DIR."Smarty.class.php"); ]]>