From b0507f2ab3907af3eed8ab7e68d6946d40965444 Mon Sep 17 00:00:00 2001 From: pete_morgan Date: Tue, 26 Sep 2006 03:44:02 +0000 Subject: [PATCH] Tidy up formatting on variables --- docs/en/designers/language-variables.xml | 16 ++- .../language-assigned-variables.xml | 43 ++++--- .../language-config-variables.xml | 50 ++++---- .../language-variables-smarty.xml | 112 ++++++++++-------- 4 files changed, 130 insertions(+), 91 deletions(-) diff --git a/docs/en/designers/language-variables.xml b/docs/en/designers/language-variables.xml index cf67c0c4..76dafcf4 100644 --- a/docs/en/designers/language-variables.xml +++ b/docs/en/designers/language-variables.xml @@ -8,23 +8,35 @@ Variables in Smarty can be either displayed directly or used as arguments - for function + 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: + is the only thing contained between them. + +Example variables {$product.description} + {$Contacts[row].Phone} ]]> + + +Top Tip +As easy way to examine Smarty variables is with the +debugging console. + + + &designers.language-variables.language-assigned-variables; &designers.language-variables.language-config-variables; &designers.language-variables.language-variables-smarty; diff --git a/docs/en/designers/language-variables/language-assigned-variables.xml b/docs/en/designers/language-variables/language-assigned-variables.xml index 5acc2cc6..e38b87a4 100644 --- a/docs/en/designers/language-variables/language-assigned-variables.xml +++ b/docs/en/designers/language-variables/language-assigned-variables.xml @@ -4,19 +4,21 @@ Variables assigned from PHP Variables that are - assigned from PHP are referenced by preceding them with - a dollar sign $. Variables assigned from within a - template with the {assign} + assigned from PHP are referenced by + preceding them with a dollar sign $ (like php). + Variables assigned from within a template with the + {assign} function are also displayed this way. + - assigned variables + Assigned variables php script assign('firstname', 'Doug'); $smarty->assign('lastname', 'Evans'); @@ -28,13 +30,13 @@ $smarty->display('index.tpl'); ]]> - where the content of index.tpl is: + where the content of index.tpl is: -{* this will not work as $vars are case sensitive *} +{* this will not work as $variables are case sensitive *} This weeks meeting is in {$meetingplace}. {* this will work *} This weeks meeting is in {$meetingPlace}. @@ -42,7 +44,7 @@ This weeks meeting is in {$meetingPlace}. - This will output: + This above would output: + + Associative arrays @@ -61,7 +65,7 @@ This weeks meeting is in New York. symbol. - accessing associative array variables + Accessing associative array variables display('index.tpl'); ]]> - where the content of index.tpl is: + where the content of index.tpl is: + + Array indexes - You can reference arrays by their index, much like native PHP - syntax. + You can reference arrays by their index, much like native PHP syntax. - accessing arrays by index + Accessing arrays by index display('index.tpl'); ]]> - where index.tpl is: + where index.tpl is: + + Objects Properties of objects assigned from PHP can be referenced by specifying the property - name after the '->' symbol. + name after the -> symbol. - accessing object properties + Accessing object properties name}
+name: {$person->name}
email: {$person->email}
]]>
@@ -167,7 +174,7 @@ email: {$person->email}
+name: Zaphod Beeblebrox
email: zaphod@slartibartfast.example.com
]]>
diff --git a/docs/en/designers/language-variables/language-config-variables.xml b/docs/en/designers/language-variables/language-config-variables.xml index 0ccceb28..5c6b5dd6 100644 --- a/docs/en/designers/language-variables/language-config-variables.xml +++ b/docs/en/designers/language-variables/language-config-variables.xml @@ -1,45 +1,44 @@ - Variables loaded from config files - + Variables loaded from config files + Variables that are loaded from the config files - are referenced by - enclosing them within hash marks (#), or with the smarty variable - $smarty.config. - The second syntax is useful for embedding into quoted attribute - values. - + are referenced by enclosing them within #hash marks#, + or with the smarty variable + + $smarty.config. + The later syntax is useful for embedding into quoted attribute values. + config variables - foo.conf: + Example config file - foo.conf: - index.tpl: + A template demonstrating the #hash# method: {#pageTitle#} - - - + + +
FirstLastAddressFirstLastAddress
@@ -47,19 +46,21 @@ rowBgColor = "#cccccc" ]]>
- index.tpl: (alternate syntax) + A template demonstrating the + + $smarty.config method: {$smarty.config.pageTitle} - - - + + +
FirstLastAddressFirstLastAddress
@@ -67,7 +68,7 @@ rowBgColor = "#cccccc" ]]>
- this will output for both examples: + Both examples would output: {config_load}. + + {config_load}. See also Variables and diff --git a/docs/en/designers/language-variables/language-variables-smarty.xml b/docs/en/designers/language-variables/language-variables-smarty.xml index 8907b443..148c4060 100644 --- a/docs/en/designers/language-variables/language-variables-smarty.xml +++ b/docs/en/designers/language-variables/language-variables-smarty.xml @@ -3,21 +3,26 @@ {$smarty} reserved variable - The PHP reserved {$smarty} variable can be used to access several - enviroment and request variables. The full list of them follows. + The PHP reserved {$smarty} variable can be used to + access several enviroment and request variables. + The full list of them follows. + Request variables The request variables - such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION - (see $request_vars_order - and $request_use_auto_globals - ) can be accessed as demonstrated in the examples below: + such as $_GET, $_POST, + $_COOKIE, $_SERVER, + $_ENV and $_SESSION + (see + $request_vars_order + and + $request_use_auto_globals) + can be accessed as demonstrated in the examples below: - displaying request variables + Displaying request variables - For historical reasons {$SCRIPT_NAME} can be accessed - directly, although {$smarty.server.SCRIPT_NAME} is the + For historical reasons {$SCRIPT_NAME} can be accessed + directly, although {$smarty.server.SCRIPT_NAME} is the proposed way to access this value. @@ -57,45 +62,53 @@ + {$smarty.now} The current timestamp - can be accessed with {$smarty.now}. The value reflects the number of - seconds passed since the so-called Epoch (January 1, 1970) + can be accessed with {$smarty.now}. + The value reflects the number of + seconds passed since the so-called Epoch on January 1, 1970, and can be passed directly to the - date_format - modifier for display purposes. Note that time() is called each invocation. - ie a script that takes 3 seconds to execute with $smarty.now at start and end will show the 3 seconds difference. + date_format + modifier for display. Note that + time() + is called each invocation; eg a script that takes three seconds to execute + with a call to $smarty.now at start and end + will show the three second difference. - using {$smarty.now} + Using {$smarty.now} + {$smarty.const} You can access PHP constant values directly. See also smarty constants + linkend="smarty.constants">smarty constants. - using {$smarty.const} to access constants + Using {$smarty.const} to access a constant ]]> +Output the constant in a template with @@ -104,41 +117,47 @@ define('_MY_CONST_VAL','CHERRIES'); {$smarty.capture} - Template output captured via the {capture}..{/capture} - construct can be accessed using the {$smarty.capture} variable. See the section on - {capture} for an - example. + Template output captured via the built-in + + {capture}..{/capture} function can be accessed + using the {$smarty.capture} variable. + See the + {capture} page for more information. {$smarty.config} - {$smarty} variable can be used to refer to loaded config variables. - {$smarty.config.foo} is a synonym for {#foo#}. See the section on - {config_load} - for an example. + {$smarty.config} variable can be used to refer + to loaded config variables. + {$smarty.config.foo} is a synonym for + {#foo#}. See the + {config_load} page + for more info. {$smarty.section}, {$smarty.foreach} - {$smarty} variable can be used to refer to - {section} and - {foreach} - loop properties. These has very useful values such as .first .index etc + The {$smarty.section} and + {$smarty.foreach} variables can be used to refer to + {section} + and + {foreach} + loop properties respectfully. These have some very useful values such as + .first, .index, etc. {$smarty.template} - Returns the name of the current template being - processed. This example shows the container.tpl and the included banner.tpl - with {$smarty.template} within both + Returns the name of the current template being processed. + The following example shows the container.tpl and the + included banner.tpl with + {$smarty.template} within both. - - + {$smarty.version} @@ -168,19 +186,19 @@ banner.tpl ]]> - - + {$smarty.ldelim}, {$smarty.rdelim} - These variables are used for printing the left-delimiter and right-delimiter value literally, - the same as {ldelim},{rdelim}. + These variables are used for printing the left-delimiter and right-delimiter + value literally, the same as + {ldelim},{rdelim}. See also - Variables and - Config Variables + assigned variables and + config variables