From b84a9d2d46cc2615cf611a32a993175795ce3e64 Mon Sep 17 00:00:00 2001 From: nlopess Date: Wed, 25 May 2005 19:13:20 +0000 Subject: [PATCH] more patches from Peter: more linking and improvement of examples. thanks :) --- .../language-function-capture.xml | 16 +- .../language-function-config-load.xml | 10 +- .../language-function-foreach.xml | 73 ++- .../language-function-if.xml | 2 +- .../language-function-include-php.xml | 2 +- .../language-function-include.xml | 2 +- .../language-function-insert.xml | 2 +- .../language-function-ldelim.xml | 2 +- .../language-function-literal.xml | 2 +- .../language-function-php.xml | 2 +- .../language-function-section.xml | 519 +++++++++++------- .../language-function-strip.xml | 13 +- .../language-combining-modifiers.xml | 15 +- .../language-function-assign.xml | 2 +- .../language-function-counter.xml | 4 +- .../language-function-cycle.xml | 12 +- .../language-function-debug.xml | 2 +- .../language-function-eval.xml | 13 +- .../language-function-fetch.xml | 2 +- .../language-function-html-checkboxes.xml | 66 ++- .../language-function-html-image.xml | 40 +- .../language-function-html-options.xml | 92 +++- .../language-function-html-radios.xml | 93 +++- .../language-function-html-select-date.xml | 45 +- .../language-function-html-select-time.xml | 16 +- .../language-function-html-table.xml | 10 +- .../language-function-mailto.xml | 54 +- .../language-function-math.xml | 29 +- .../language-function-popup-init.xml | 21 +- .../language-function-popup.xml | 19 +- .../language-function-textformat.xml | 15 +- docs/en/designers/language-modifiers.xml | 2 +- .../language-modifier-capitalize.xml | 8 +- .../language-modifier-cat.xml | 6 +- .../language-modifier-count-characters.xml | 9 +- .../language-modifier-count-paragraphs.xml | 12 +- .../language-modifier-count-sentences.xml | 9 +- .../language-modifier-count-words.xml | 4 +- .../language-modifier-date-format.xml | 17 +- .../language-modifier-default.xml | 4 +- .../language-modifier-escape.xml | 8 +- .../language-modifier-indent.xml | 11 +- .../language-modifier-lower.xml | 4 +- .../language-modifier-nl2br.xml | 8 +- .../language-modifier-regex-replace.xml | 2 - .../language-modifier-replace.xml | 4 +- .../language-modifier-spacify.xml | 6 +- .../language-modifier-string-format.xml | 4 +- .../language-modifier-strip-tags.xml | 10 +- .../language-modifier-strip.xml | 4 +- .../language-modifier-truncate.xml | 4 +- .../language-modifier-upper.xml | 4 +- .../language-modifier-wordwrap.xml | 17 +- docs/entities/global.ent | 1 + 54 files changed, 838 insertions(+), 515 deletions(-) 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 c4a9a970..6df02591 100644 --- a/docs/en/designers/language-builtin-functions/language-function-capture.xml +++ b/docs/en/designers/language-builtin-functions/language-function-capture.xml @@ -1,7 +1,7 @@ - capture + {capture} @@ -37,13 +37,13 @@ - capture is used to collect the output of the template into a + {capture} is used to collect the output of the template into a variable instead of displaying it. Any content between {capture name="foo"} and {/capture} is collected into the variable specified in the name attribute. The captured content can be used in the template from the special variable $smarty.capture.foo - where foo is the value passed in the name attribute. If you do not + where "foo" is the value passed in the name attribute. If you do not supply a name attribute, then "default" will be used. All {capture} commands must be paired with {/capture}. You can nest capture commands. @@ -58,11 +58,12 @@ Be careful when capturing insert + linkend="language.function.insert">{insert} output. If you have caching turned on and you have - insert commands that you expect to run + {insert} + commands that you expect to run within cached content, do not capture this content. @@ -75,12 +76,15 @@ {capture name=banner} {include file="get_banner.tpl"} {/capture} -{if $smarty.capture.banner ne ""} + +{if $smarty.capture.banner ne ''} + +
{$smarty.capture.banner}
{/if} ]]> 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 8215e354..e43b877c 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 @@ -1,7 +1,7 @@ - config_load + {config_load} @@ -64,13 +64,14 @@ - This function is used for loading in variables from a + {config_load} is used for loading config + #variables# from a configuration file into the template. See Config Files for more info. - function config_load + {config_load} - See also Config Files, + See also Config files, Config variables, + $config_dir, get_config_vars() and config_load(). 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 691ef0bc..1ce28b8c 100644 --- a/docs/en/designers/language-builtin-functions/language-function-foreach.xml +++ b/docs/en/designers/language-builtin-functions/language-function-foreach.xml @@ -1,7 +1,7 @@ - foreach,foreachelse + {foreach},{foreachelse} @@ -56,8 +56,8 @@ {foreach} loops are an alternative to {section} - loops. foreach is used to loop over a single - associative array. The syntax for + loops. {foreach} is used to loop over a + single associative array. The syntax for {foreach} is much easier than {section}, but as a tradeoff it can only be used @@ -74,10 +74,17 @@ values in the from variable. - foreach + {foreach} - item + +assign('custid', $arr); +?> +]]> + @@ -97,18 +104,25 @@ - foreach key + {foreach} - item and key + +assign("contacts", array( + array("phone" => "1", + "fax" => "2", + "cell" => "3"), + array("phone" => "555-4444", + "fax" => "555-3333", + "cell" => "760-1234")) + ); +?> +]]> + assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), - array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); - - *} - {foreach name=outer item=contact from=$contacts} {foreach key=key item=item from=$contact} {$key}: {$item}
@@ -131,8 +145,28 @@
+ + {foreach} - database example (eg PEAR or ADODB) + +assign("contacts", $db->getAssoc($sql)); +?> +]]> + + +{$con.name} - {$con.nick}
+{/foreach} +]]> +
+ +
+ - Foreach-loops also have their own variables that handle foreach properties. + {foreach} loops also have their own variables that handle {foreach} properties. These are indicated like so: {$smarty.foreach.foreachname.varname} with @@ -143,11 +177,8 @@ iteration - iteration is used to display the current loop iteration. - - - Iteration always starts with 1 and is incremented by one - one each iteration. + iteration is used to display the current loop iteration.Iteration always + starts with 1 and is incremented by one on each iteration. diff --git a/docs/en/designers/language-builtin-functions/language-function-if.xml b/docs/en/designers/language-builtin-functions/language-function-if.xml index a322de2c..b46b0bb5 100644 --- a/docs/en/designers/language-builtin-functions/language-function-if.xml +++ b/docs/en/designers/language-builtin-functions/language-function-if.xml @@ -1,7 +1,7 @@ - if,elseif,else + {if},{elseif},{else} {if} statements in Smarty have much the same flexibility as PHP if statements, with a few added features for the template engine. diff --git a/docs/en/designers/language-builtin-functions/language-function-include-php.xml b/docs/en/designers/language-builtin-functions/language-function-include-php.xml index 78419a4f..2b826895 100644 --- a/docs/en/designers/language-builtin-functions/language-function-include-php.xml +++ b/docs/en/designers/language-builtin-functions/language-function-include-php.xml @@ -1,7 +1,7 @@ - include_php + {include_php} diff --git a/docs/en/designers/language-builtin-functions/language-function-include.xml b/docs/en/designers/language-builtin-functions/language-function-include.xml index 0c699d57..e304b358 100644 --- a/docs/en/designers/language-builtin-functions/language-function-include.xml +++ b/docs/en/designers/language-builtin-functions/language-function-include.xml @@ -1,7 +1,7 @@ - include + {include} diff --git a/docs/en/designers/language-builtin-functions/language-function-insert.xml b/docs/en/designers/language-builtin-functions/language-function-insert.xml index 5fe1eaa4..179a48f0 100644 --- a/docs/en/designers/language-builtin-functions/language-function-insert.xml +++ b/docs/en/designers/language-builtin-functions/language-function-insert.xml @@ -1,7 +1,7 @@ - insert + {insert} diff --git a/docs/en/designers/language-builtin-functions/language-function-ldelim.xml b/docs/en/designers/language-builtin-functions/language-function-ldelim.xml index 387cebc7..a5326be2 100644 --- a/docs/en/designers/language-builtin-functions/language-function-ldelim.xml +++ b/docs/en/designers/language-builtin-functions/language-function-ldelim.xml @@ -1,7 +1,7 @@ - ldelim,rdelim + {ldelim},{rdelim} ldelim and rdelim are used for escaping template delimiters, in our case "{" or "}". You can also use - literal + {literal} {literal} tags allow a block of data to be taken literally. This is typically used around javascript or stylesheet blocks where curly braces would diff --git a/docs/en/designers/language-builtin-functions/language-function-php.xml b/docs/en/designers/language-builtin-functions/language-function-php.xml index b6112717..5f1ad664 100644 --- a/docs/en/designers/language-builtin-functions/language-function-php.xml +++ b/docs/en/designers/language-builtin-functions/language-function-php.xml @@ -1,7 +1,7 @@ - php + {php} {php} tags allow php to be embedded directly into the template. They will not be escaped, regardless of the - section,sectionelse + {section},{sectionelse} @@ -75,7 +75,9 @@ - Template sections are used for looping over arrays of data. All + Template sections are used for looping over + arrays of data + (unlike {foreach}). All {section} tags must be paired with {/section} tags. Required parameters are name and loop. The name @@ -89,13 +91,29 @@ executed when there are no values in the loop variable. - section + {section} + + +assign('custid',$data); + +?> +]]> + {/section} +
+{* print out all the values of the $custid array reversed *} +{section name=foo loop=$custid step=-1} + {$custid[foo]} +{/section} ]]>
@@ -106,23 +124,71 @@ id: 1000
id: 1001
id: 1002
+
+id: 1002
+id: 1001
+id: 1000
]]> + + Another couple of examples without an assigned array. + + + +{section name=bar loop=21 max=6 step=-2} + {$smarty.section.bar.index} +{/section} +]]> + + + The above example will output: + + + +20 18 16 14 12 10 +]]> + +
- section loop variable + {section} loop variable + +assign('custid',$id); + +$fullnames = array('John Smith','Jack Jones','Jane Munson'); +$smarty->assign('name',$fullnames); + +$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st'); +$smarty->assign('address',$addr); + +?> +]]> + id: {$custid[customer]}
name: {$name[customer]}
- address: {$address[customer]}
-

+ address: {$address[customer]} +

{/section} ]]>
@@ -131,33 +197,39 @@
id: 1000
name: John Smith
- address: 253 N 45th
+ address: 253 N 45th +

id: 1001
name: Jack Jones
- address: 417 Mulberry ln
+ address: 417 Mulberry ln +

id: 1002
name: Jane Munson
- address: 5605 apple st
-

+ address: 5605 apple st +

]]>
- section names + {section} naming - name: {$name[mydata]}
- address: {$address[mydata]}
+{* + the name of the section can be anything you like, + as it is used to reference the data within the section +*} +{section name=anything loop=$custid}

+ id: {$custid[anything]}
+ name: {$name[anything]}
+ address: {$address[anything]} +

{/section} ]]>
@@ -165,20 +237,52 @@ nested sections + +assign('custid',$id); + +$fullnames = array('John Smith','Jack Jones','Jane Munson'); +$smarty->assign('name',$fullnames); + +$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st'); +$smarty->assign('address',$addr); + +$types = array( + array( 'home phone', 'cell phone', 'e-mail'), + array( 'home phone', 'web'), + array( 'cell phone') + ); +$smarty->assign('contact_type', $types); + +$info = array( + array('555-555-5555', '666-555-5555', 'john@myexample.com'), + array( '123-456-4', 'www.example.com'), + array( '0457878') + ); +$smarty->assign('contact_info', $info); + +?> + ]]> + id: {$custid[customer]}
name: {$name[customer]}
address: {$address[customer]}
{section name=contact loop=$contact_type[customer]} {$contact_type[customer][contact]}: {$contact_info[customer][contact]}
{/section} -

{/section} ]]> @@ -187,42 +291,62 @@ id: 1000
name: John Smith
address: 253 N 45th
home phone: 555-555-5555
- cell phone: 555-555-5555
+ cell phone: 666-555-5555
e-mail: john@myexample.com
-

+


id: 1001
name: Jack Jones
address: 417 Mulberry ln
- home phone: 555-555-5555
- cell phone: 555-555-5555
- e-mail: jack@myexample.com
-

+ home phone: 123-456-4
+ web: www.example.com
+ +


id: 1002
name: Jane Munson
address: 5605 apple st
- home phone: 555-555-5555
- cell phone: 555-555-5555
- e-mail: jane@myexample.com
-

+ cell phone: 0457878
]]> sections and associative arrays + + 'John Smith', 'home' => '555-555-5555', + 'cell' => '666-555-5555', 'email' => 'john@myexample.com'), + array('name' => 'Jack Jones', 'home' => '777-555-5555', + 'cell' => '888-555-5555', 'email' => 'jack@myexample.com'), + array('name' => 'Jane Munson', 'home' => '000-555-5555', + 'cell' => '123456', 'email' => 'jane@myexample.com') + ); +$smarty->assign('contacts',$data); + +?> +]]> + + name: {$contacts[customer].name}
home: {$contacts[customer].home}
cell: {$contacts[customer].cell}
- e-mail: {$contacts[customer].email}

+ e-mail: {$contacts[customer].email} +

{/section} ]]>
@@ -231,24 +355,62 @@ name: John Smith
home: 555-555-5555
- cell: 555-555-5555
- e-mail: john@myexample.com

+ cell: 666-555-5555
+ e-mail: john@myexample.com +

+

name: Jack Jones
- home phone: 555-555-5555
- cell phone: 555-555-5555
- e-mail: jack@myexample.com

+ home phone: 777-555-5555
+ cell phone: 888-555-5555
+ e-mail: jack@myexample.com +

+

name: Jane Munson
- home phone: 555-555-5555
- cell phone: 555-555-5555
- e-mail: jane@myexample.com

+ home phone: 000-555-5555
+ cell phone: 123456
+ e-mail: jane@myexample.com +

]]>
+ + Database example (eg using Pear or Adodb) + + assign('contacts',$db->getAll($sql) ); + +?> +]]> + + + + + Name>HomeCellEmail +{section name=co loop=$contacts} + + view + {$contacts[co].name} + {$contacts[co].home} + {$contacts[co].cell} + {$contacts[co].email} + +{/section} + +]]> +
- sectionelse + {sectionelse} As of Smarty 1.5.0, the syntax for section property variables has - been changed from {%sectionname.varname%} to + changed from {%sectionname.varname%} to {$smarty.section.sectionname.varname}. The old syntax is still - supported, but you will only see reference to the new syntax in the - manual examples. + supported, but you will only see examples of the new syntax. index - index is used to display the current loop index, starting with zero + index is used to display the current array index, starting with zero (or the start attribute if given), and incrementing by one (or by the step attribute if given.) @@ -287,13 +448,15 @@ If the step and start section properties are not modified, then this works the same as the iteration section - property, except it starts on 0 instead of 1. + property, except it starts at 0 instead of 1. - section property index +{section} property index {/section} @@ -311,40 +474,16 @@ + + index_prev index_prev is used to display the previous loop index. on the first loop, this is set to -1. - - section property index_prev - - - {* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *} - {if $custid[customer.index_prev] ne $custid[customer.index]} - The customer id changed
- {/if} - {/section} -]]> -
- - The above example will output: - - - - The customer id changed
- 1 id: 1001
- The customer id changed
- 2 id: 1002
- The customer id changed
-]]> -
-
+ index_next @@ -352,34 +491,56 @@ loop, this is still one more than the current index (respecting the setting of the step attribute, if given.) + - section property index_next +{section} property index_next and index_prev + +assign('custid',$data); + +?> +]]> + - {* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *} - {if $custid[customer.index_next] ne $custid[customer.index]} - The customer id will change
- {/if} +{* FYI, $custid[cus.index] and $custid[cus] are identical in meaning *} + + + + + + + +{section name=cus loop=$custid} + + + + + {/section} +
indexidindex_prevprev idindex_nextnext id
{$smarty.section.cus.index}{$custid[cus]}{$smarty.section.cus.index_prev}{$custid[cus.index_prev]}{$smarty.section.cus.index_next}{$custid[cus.index_next]}
]]>
- The above example will output: + The above example will output a table containing the following: - The customer id will change
- 1 id: 1001
- The customer id will change
- 2 id: 1002
- The customer id will change
+index id index_prev previd index_next nextid +0 1001 -1 1 1002 +1 1002 0 1001 2 1003 +2 1003 1 1002 3 1004 +3 1004 2 1003 4 1005 +4 1005 3 1004 5 ]]>
+ + iteration @@ -395,16 +556,24 @@ - section property iteration +{section} property iteration + +assign('custid',$id); + +?> +]]> + - {$smarty.section.customer.index} id: {$custid[customer]}
- {* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *} - {if $custid[customer.index_next] ne $custid[customer.index]} - The customer id will change
- {/if} +{section name=cu loop=$custid start=5 step=2} + iteration={$smarty.section.cu.iteration} + index={$smarty.section.cu.index} + id={$custid[cu]}
{/section} ]]>
@@ -413,95 +582,91 @@ - The customer id will change
- current loop iteration: 2 - 7 id: 1001
- The customer id will change
- current loop iteration: 3 - 9 id: 1002
- The customer id will change
+iteration=1 index=5 id=3005
+iteration=2 index=7 id=3007
+iteration=3 index=9 id=3009
+iteration=4 index=11 id=3011
+iteration=5 index=13 id=3013
+iteration=6 index=15 id=3015
]]>
-
+ + This example uses the iteration property to + output a table header block every five rows + (uses {if} + with the mod operator). + + + +{section name=co loop=$contacts} + {if $smarty.section.co.iteration % 5 == 1} +  Name>HomeCellEmail + {/if} + +
view + {$contacts[co].name} + {$contacts[co].home} + {$contacts[co].cell} + {$contacts[co].email} + + {/section} + +]]> + +
+ + first - first is set to true if the current section iteration is the first + first is set to true if the current section iteration is the first one. - - section property first - - - {/if} - - {$smarty.section.customer.index} id: - {$custid[customer]} - - {if $smarty.section.customer.last} - - {/if} - {/section} -]]> - - - The above example will output: - - - - 0 id: 1000 - 1 id: 1001 - 2 id: 1002 - -]]> - - + + last - last is set to true if the current section iteration is the last + last is set to true if the current section iteration is the last one. - section property last + {section} property first and last + + This example loops the $customers array; + outputs a header block on the first iteration and + on the last outputs the footer block + (uses section total property) + + idcustomer {/if} - {$smarty.section.customer.index} id: - {$custid[customer]} + + {$customers[customer].id}} + {$customers[customer].name} + {if $smarty.section.customer.last} + {$smarty.section.customer.total} customers {/if} {/section} ]]> - - The above example will output: - - - - 0 id: 1000 - 1 id: 1001 - 2 id: 1002 - -]]> - + + rownum @@ -510,26 +675,6 @@ linkend="section.property.iteration">iteration, they work identically. - - section property rownum - - - {/section} -]]> - - - The above example will output: - - - - 2 id: 1001
- 3 id: 1002
-]]> -
-
loop @@ -538,7 +683,7 @@ looped. This can be used inside or after the section. - section property index + {section} property index show is used as a parameter to section. show is a boolean value, true or false. If - false, the section will not be displayed. If there is a sectionelse + false, the section will not be displayed. If there is a {sectionelse} present, that will be alternately displayed. - section attribute show + {section} attribute show {/section} @@ -608,7 +755,7 @@ will loop. This can be used inside or after the section. - section property total + {section} property total - 2 id: 1001
- 4 id: 1002
+2 id: 1002
+4 id: 1004
There were 3 customers shown above. ]]> diff --git a/docs/en/designers/language-builtin-functions/language-function-strip.xml b/docs/en/designers/language-builtin-functions/language-function-strip.xml index 26277d47..037024d1 100644 --- a/docs/en/designers/language-builtin-functions/language-function-strip.xml +++ b/docs/en/designers/language-builtin-functions/language-function-strip.xml @@ -1,7 +1,7 @@ - strip + {strip} Many times web designers run into the issue where white space and carriage returns affect the output of the rendered HTML (browser @@ -20,8 +20,8 @@ Technical Note {strip}{/strip} does not affect the contents of template variables. - See the strip modifier - function. + See the + strip modifier. @@ -47,7 +47,7 @@
This is a test +
strip modifier + + diff --git a/docs/en/designers/language-combining-modifiers.xml b/docs/en/designers/language-combining-modifiers.xml index d5b0632f..dc6bbadc 100644 --- a/docs/en/designers/language-combining-modifiers.xml +++ b/docs/en/designers/language-combining-modifiers.xml @@ -11,15 +11,18 @@ combining modifiers assign('articleTitle', 'Smokers are Productive, but Death Cuts Efficiency.'); -$smarty->display('index.tpl'); + ?> - -index.tpl: - +]]> + + +where template is: + + + - assign + {assign} diff --git a/docs/en/designers/language-custom-functions/language-function-counter.xml b/docs/en/designers/language-custom-functions/language-function-counter.xml index e149c1ab..1c130e66 100644 --- a/docs/en/designers/language-custom-functions/language-function-counter.xml +++ b/docs/en/designers/language-custom-functions/language-function-counter.xml @@ -1,7 +1,7 @@ - counter + {counter} @@ -65,7 +65,7 @@ - counter is used to print out a count. counter will remember the + {counter} is used to print out a count. {counter} will remember the count on each iteration. You can adjust the number, the interval and the direction of the count, as well as determine whether or not to print the value. You can run multiple counters concurrently by diff --git a/docs/en/designers/language-custom-functions/language-function-cycle.xml b/docs/en/designers/language-custom-functions/language-function-cycle.xml index 99a8918f..4685d508 100644 --- a/docs/en/designers/language-custom-functions/language-function-cycle.xml +++ b/docs/en/designers/language-custom-functions/language-function-cycle.xml @@ -1,7 +1,7 @@ - cycle + {cycle} @@ -68,12 +68,12 @@ - Cycle is used to cycle though a set of values. This makes it easy - to alternate between two or more colors in a table, or cycle + {cycle} is used to cycle though a set of values. This makes it easy + to alternate for example between two or more colors in a table, or cycle through an array of values. - You can cycle through more than one set of values in your template + You can {cycle} through more than one set of values in your template by supplying a name attribute. Give each set of values a unique name. @@ -84,11 +84,11 @@ The advance attribute is used to repeat a value. When set to false, - the next call to cycle will print the same value. + the next call to {cycle} will print the same value. If you supply the special "assign" attribute, the output of the - cycle function will be assigned to this template variable instead of + cycle function will be assigned to a template variable instead of being output to the template. diff --git a/docs/en/designers/language-custom-functions/language-function-debug.xml b/docs/en/designers/language-custom-functions/language-function-debug.xml index 40a9a63e..893a6abe 100644 --- a/docs/en/designers/language-custom-functions/language-function-debug.xml +++ b/docs/en/designers/language-custom-functions/language-function-debug.xml @@ -1,7 +1,7 @@ - debug + {debug} diff --git a/docs/en/designers/language-custom-functions/language-function-eval.xml b/docs/en/designers/language-custom-functions/language-function-eval.xml index fb9705a4..5cb17d8a 100644 --- a/docs/en/designers/language-custom-functions/language-function-eval.xml +++ b/docs/en/designers/language-custom-functions/language-function-eval.xml @@ -1,7 +1,7 @@ - eval + {eval} @@ -38,13 +38,13 @@ - eval is used to evaluate a variable as a template. This can be used + {eval} is used to evaluate a variable as a template. This can be used for things like embedding template tags/variables into variables or tags/variables into config file variables. If you supply the special "assign" attribute, the output of the - eval function will be assigned to this template variable instead of + {eval} function will be assigned to this template variable instead of being output to the template. @@ -59,12 +59,14 @@ Technical Note Evaluated variables are compiled on every invocation, the compiled - versions are not saved! However if you have caching enabled, the + versions are not saved! However if you have + caching + enabled, the output will be cached with the rest of the template. - eval + {eval} city. diff --git a/docs/en/designers/language-custom-functions/language-function-fetch.xml b/docs/en/designers/language-custom-functions/language-function-fetch.xml index 9256fb74..a7a5be07 100644 --- a/docs/en/designers/language-custom-functions/language-function-fetch.xml +++ b/docs/en/designers/language-custom-functions/language-function-fetch.xml @@ -1,7 +1,7 @@ - fetch + {fetch} diff --git a/docs/en/designers/language-custom-functions/language-function-html-checkboxes.xml b/docs/en/designers/language-custom-functions/language-function-html-checkboxes.xml index 20ea0e64..34a136b3 100644 --- a/docs/en/designers/language-custom-functions/language-function-html-checkboxes.xml +++ b/docs/en/designers/language-custom-functions/language-function-html-checkboxes.xml @@ -1,7 +1,7 @@ - html_checkboxes + {html_checkboxes} @@ -72,7 +72,9 @@ - html_checkboxes is a custom function that creates an html checkbox + {html_checkboxes} is a + custom function + that creates an html checkbox group with provided data. It takes care of which item(s) are selected by default as well. Required attributes are values and output, unless you use options instead. All output is XHTML @@ -83,30 +85,29 @@ name/value-pairs inside each of the created <input>-tags. - html_checkboxes - - where PHP code is: - + {html_checkboxes} assign('cust_ids', array(1000,1001,1002,1003)); -$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane Johnson','Charlie Brown')); +$smarty->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown')); $smarty->assign('customer_id', 1001); -$smarty->display('index.tpl'); ?> ]]> - and index.tpl is: +where template is "} +{html_checkboxes name="id" values=$cust_ids output=$cust_names + selected=$customer_id separator="
"} ]]>
@@ -116,20 +117,18 @@ $smarty->display('index.tpl'); assign('cust_checkboxes', array( 1000 => 'Joe Schmoe', 1001 => 'Jack Smith', 1002 => 'Jane Johnson', 1003 => 'Charlie Brown')); $smarty->assign('customer_id', 1001); -$smarty->display('index.tpl'); + ?> ]]>
- and index.tpl is: + and the template is display('index.tpl'); Joe Schmoe
-
+ +


]]>
+ + + Database example (eg PEAR or ADODB): + + +assign('types',$db->getAssoc($sql)); + +$sql = 'select * from contacts where contact_id=12'; +$smarty->assign('contact',$db->getRow($sql)); + +?> +]]> + + +"} +]]> + + + + See also + {html_radios} + and + {html_options} +
+ + + diff --git a/docs/en/designers/language-custom-functions/language-function-html-image.xml b/docs/en/designers/language-custom-functions/language-function-html-image.xml index 21bc318e..9347187a 100644 --- a/docs/en/designers/language-custom-functions/language-function-html-image.xml +++ b/docs/en/designers/language-custom-functions/language-function-html-image.xml @@ -1,7 +1,7 @@ - html_image + {html_image} @@ -65,58 +65,52 @@ - html_image is a custom function that generates an HTML tag for an + {html_image} is a + custom function + that generates an HTML tag for an image. The height and width are automatically calculated from the image file if none are supplied. basedir is the base directory that relative image paths are based - from. If not given, the web server document root (env variable - DOCUMENT_ROOT) is used as the base. If security is enabled, the + from. If not given, the web server document root ( + env + variable DOCUMENT_ROOT) is used as the base. If + $security + is enabled, the path to the image must be within a secure directory. href is the href value to link the image to. If link is supplied, an - <a href="LINKVALUE"><a> tag is put around the image tag. + <a href="LINKVALUE"><a> tag is placed around the image tag. All parameters that are not in the list above are printed as - name/value-pairs inside the created <img>-tag. + name/value-pairs inside the created <img> tag. Technical Note - html_image requires a hit to the disk to read the image and + {html_image} requires a hit to the disk to read the image and calculate the height and width. If you don't use template - caching, it is generally better to avoid html_image and leave + caching, + it is generally better to avoid {html_image} and leave image tags static for optimal performance. html_image example - -display('index.tpl'); - -?> - ]]> - - - where index.tpl is: - - a possible output would be: + possible output would be: - html_options + {html_options} @@ -58,90 +58,90 @@ - html_options is a custom function that creates html option group + {html_options} is a + custom function + that creates html <select><option> group with provided data. It takes care of which item(s) are selected by default as well. Required attributes are values and output, unless you use options instead. - If a given value is an array, it will treat it as an html OPTGROUP, - and display the groups. Recursion is supported with OPTGROUP. All + If a given value is an array, it will treat it as an html <optgroup>, + and display the groups. Recursion is supported with <optgroup>. All output is XHTML compatible. If the optional name attribute is given, the <select name="groupname"></select> tags will enclose - the option list. Otherwise only the option list is generated. + the option list. Otherwise only the <option> list is generated. All parameters that are not in the list above are printed as - name/value-pairs inside the <select>-tag. They are ignored if + name/value-pairs inside the <select> tag. They are ignored if the optional name is not given. - html_options : Example 1 - + {html_options} + + Example 2: + + assign('cust_ids', array(1000,1001,1002,1003)); - $smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane - Johnson','Charlie Brown')); +$smarty->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown')); $smarty->assign('customer_id', 1001); - $smarty->display('index.tpl'); + +?> ]]> - Where index.tpl is: + Where template is: - {html_options values=$cust_ids selected=$customer_id output=$cust_names} + {html_options values=$cust_ids output=$cust_names selected=$customer_id} ]]> - Example 2 + Example 2: - + assign('cust_options', array( 1001 => 'Joe Schmoe', 1002 => 'Jack Smith', 1003 => 'Jane Johnson', 1004 => 'Charlie Brown')); $smarty->assign('customer_id', 1001); - $smarty->display('index.tpl'); + +?> ]]> - Where index.tpl is: +where template is: {html_options options=$cust_options selected=$customer_id} - ]]> - Both examples will output: + Both the above examples will output: @@ -152,6 +152,38 @@ ]]> + + {html_options} - Database example (eg PEAR or ADODB): + +assign('types',$db->getAssoc($sql)); + +$sql = 'select * from contacts where contact_id=12'; +$smarty->assign('contact',$db->getRow($sql)); + +?> +]]> + + +where the template is: + + + + {html_options name="type" options=$types selected=$contact.type_id} + +]]> + + + + See also + {html_checkboxes} + and + {html_radios} + - html_radios + {html_radios} @@ -65,7 +65,9 @@ - html_radios is a custom function that creates html radio button + {html_radios} is a + custom function + that creates html radio button group with provided data. It takes care of which item is selected by default as well. Required attributes are values and output, unless you use options instead. All output is XHTML compatible. @@ -76,46 +78,46 @@ - html_radios : Example 1 - + {html_radios} : Example 1 + assign('cust_ids', array(1000,1001,1002,1003)); - $smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane - Johnson','Charlie Brown')); +$smarty->assign('cust_names', array( + 'Joe Schmoe', + 'Jack Smith', + 'Jane Johnson', + 'Charlie Brown')); $smarty->assign('customer_id', 1001); - $smarty->display('index.tpl'); + +?> ]]> - Where index.tpl is: + Where template is: "} +{html_radios name="id" values=$cust_ids output=$cust_names + selected=$customer_id separator="
"} ]]>
- - Example 2 : - - +
+ + {html_radios} : Example 2 + assign('cust_radios', array( 1000 => 'Joe Schmoe', 1001 => 'Jack Smith', 1002 => 'Jane Johnson', 1003 => 'Charlie Brown')); $smarty->assign('customer_id', 1001); - $smarty->display('index.tpl'); + +?> ]]> @@ -131,13 +133,48 @@ Joe Schmoe
-
-
-
+
+
+
+
]]>
+ + {html_radios}- Database example (eg PEAR or ADODB): + +assign('types',$db->getAssoc($sql)); + +$sql = 'select * from contacts where contact_id=12'; +$smarty->assign('contact',$db->getRow($sql)); + +?> +]]> + + +and the template: + + +"} +]]> + + + + See also + {html_checkboxes} + and + {html_options} +
+ + + + diff --git a/docs/en/designers/language-custom-functions/language-function-html-select-date.xml b/docs/en/designers/language-custom-functions/language-function-html-select-date.xml index b41c01ef..c3376a9e 100644 --- a/docs/en/designers/language-custom-functions/language-function-html-select-date.xml +++ b/docs/en/designers/language-custom-functions/language-function-html-select-date.xml @@ -1,7 +1,7 @@ - html_select_date + {html_select_date} @@ -222,13 +222,17 @@ - {html_select_date} is a custom function that creates date dropdowns + {html_select_date} is a + custom function + that creates date dropdowns for you. It can display any or all of year, month, and day. - html_select_date + {html_select_date} @@ -241,12 +245,7 @@ - - - - - - + ..... snipped ..... @@ -255,31 +254,13 @@ - - - - - - - + ..... snipped ..... - - - - - - - - - - - - - + ..... snipped ..... @@ -292,11 +273,12 @@ - html_select_date + {html_select_date} @@ -358,3 +340,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/designers/language-custom-functions/language-function-html-select-time.xml b/docs/en/designers/language-custom-functions/language-function-html-select-time.xml index 122d4057..531887af 100644 --- a/docs/en/designers/language-custom-functions/language-function-html-select-time.xml +++ b/docs/en/designers/language-custom-functions/language-function-html-select-time.xml @@ -1,7 +1,7 @@ - html_select_time + {html_select_time} @@ -133,22 +133,24 @@ - {html_select_time} is a custom function that - creates time dropdowns for you. It can display - any or all of hour, minute, second and - meridian. + {html_select_time} is a + custom function + that creates time dropdowns for you. It can display + any or all of hour, minute, second and meridian. The time-attribute can have different - formats. It can be a unique timestamp or a + formats. It can be a unique timestamp, a string of the format YYYYMMDDHHMMSS or a string that is parseable by php's strtotime(). - html_select_time + {html_select_time} diff --git a/docs/en/designers/language-custom-functions/language-function-html-table.xml b/docs/en/designers/language-custom-functions/language-function-html-table.xml index 624eac0d..fa60cdaa 100644 --- a/docs/en/designers/language-custom-functions/language-function-html-table.xml +++ b/docs/en/designers/language-custom-functions/language-function-html-table.xml @@ -1,7 +1,7 @@ - html_table + {html_table} @@ -117,7 +117,9 @@ - html_table is a custom function that dumps an array of + {html_table} is a + custom function + that dumps an array of data into an HTML table. The cols attribute determines how many columns will be in the table. The table_attr, tr_attr and td_attr values @@ -131,6 +133,8 @@ html_table display('index.tpl'); - mailto + {mailto} @@ -91,9 +91,9 @@ - mailto automates the creation of mailto links and optionally + {mailto} automates the creation of mailto: links and optionally encodes them. Encoding e-mails makes it more difficult for - web spiders to pick up e-mail addresses off of your site. + web spiders to lift e-mail addresses off of your site. Technical Note @@ -103,42 +103,49 @@ - mailto + {mailto} me@example.com
+ {mailto address="me@example.com" text="send me some mail"} +send me some mail + {mailto address="me@example.com" encode="javascript"} + + {mailto address="me@example.com" encode="hex"} +m&..snipped...#x6f;m + {mailto address="me@example.com" subject="Hello to you!"} - {mailto address="me@example.com" cc="you@example.com,they@example.com"} - {mailto address="me@example.com" extra='class="email"'} - {mailto address="me@example.com" encode="javascript_charcode"} -]]> - - - The above example will output: - - -me@example.com - send me some mail - - me@domain.com me@example.com + +{mailto address="me@example.com" cc="you@example.com,they@example.com"} me@example.com + +{mailto address="me@example.com" extra='class="email"'} + +{mailto address="me@example.com" encode="javascript_charcode"} ]]> - + + + See also + escape, + Obfuscating E-mail Addresses + and + {textformat} + + + diff --git a/docs/en/designers/language-custom-functions/language-function-math.xml b/docs/en/designers/language-custom-functions/language-function-math.xml index 57ad3963..25321c93 100644 --- a/docs/en/designers/language-custom-functions/language-function-math.xml +++ b/docs/en/designers/language-custom-functions/language-function-math.xml @@ -1,7 +1,7 @@ - math + {math} @@ -58,7 +58,7 @@ - math allows the template designer to do math equations in the + {math} allows the template designer to do math equations in the template. Any numeric template variables may be used in the equations, and the result is printed in place of the tag. The variables used in the equation are passed as parameters, which can @@ -75,15 +75,21 @@ Technical Note - math is an expensive function in performance due to its use of - the php eval() function. Doing the math in PHP is much more + {math} is an expensive function in performance due to its use of the php + eval() function. Doing the math in PHP is much + more efficient, so whenever possible do the math calculations in PHP - and assign the results to the template. Definately avoid - repetitive math function calls, like within section loops. + and assign() + the results to the template. Definately avoid + repetitive {math} function calls, eg within + {section} loops. - math + {math} + + Example a: + + + Example b: + + + Example c: + + + Example d: + - popup_init + {popup_init} - popup is an integration of overLib, a library used for popup + {popup} + is an integration of + overLib, a library used for popup windows. These are used for context sensitive information, such as - help windows or tooltips. popup_init must be called once at the - top of any page you plan on using the popup function. overLib + help windows or tooltips.{popup_init} must be called once at the + top of any page you plan on using the + {popup} function. + overLib was written by Erik Bosrup, and the homepage is located at - http://www.bosrup.com/web/overlib/. + &url.overLib;. As of Smarty version 2.1.2, overLib does NOT come with the release. - Download overLib, place the overlib.js file under your document + Download overLib, place the 'overlib.js' file under your document root and supply the relative path to this file as the "src" - parameter to popup_init. + parameter to {popup_init}. popup_init {* popup_init must be called once at the top of the page *} {popup_init src="/javascripts/overlib.js"} + ]]> diff --git a/docs/en/designers/language-custom-functions/language-function-popup.xml b/docs/en/designers/language-custom-functions/language-function-popup.xml index 80798daf..cac28100 100644 --- a/docs/en/designers/language-custom-functions/language-function-popup.xml +++ b/docs/en/designers/language-custom-functions/language-function-popup.xml @@ -1,7 +1,7 @@ - popup + {popup} @@ -391,10 +391,12 @@ - popup is used to create javascript popup windows. + {popup} is used to create javascript popup windows. + {popup_init} MUST be called first for + this to work. - popup + {popup}
  • links
  • pages
  • images
  • " snapx=10 -snapy=10}>mypage +text="
    • links
    • pages
    • images
    " +snapx=10 snapy=10}>mypage ]]>
    + + See also + {popup_init} + and + overLib. +
    + diff --git a/docs/en/designers/language-custom-functions/language-function-textformat.xml b/docs/en/designers/language-custom-functions/language-function-textformat.xml index f8e755c0..5a2b04c3 100644 --- a/docs/en/designers/language-custom-functions/language-function-textformat.xml +++ b/docs/en/designers/language-custom-functions/language-function-textformat.xml @@ -1,7 +1,7 @@ - textformat + {textformat} @@ -82,7 +82,9 @@ - textformat is a block function used to format text. It basically + {textformat} is a + block function + used to format text. It basically cleans up spaces and special characters, and formats paragraphs by wrapping at a boundary and indenting lines. @@ -91,7 +93,7 @@ Currently "email" is the only available style.
    - textformat + {textformat} + + See also + {strip} + and + {wordwrap}. + +
    + diff --git a/docs/en/designers/language-modifiers/language-modifier-cat.xml b/docs/en/designers/language-modifiers/language-modifier-cat.xml index bc61dd0f..4abbccc7 100644 --- a/docs/en/designers/language-modifiers/language-modifier-cat.xml +++ b/docs/en/designers/language-modifiers/language-modifier-cat.xml @@ -37,14 +37,14 @@ assign('articleTitle', "Psychics predict world didn't end"); -$smarty->display('index.tpl'); + ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', 'Cold Wave Linked to Temperatures.'); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: - See also count_paragraphs, + See also + count_words, count_sentences and - count_words. + count_paragraphs. diff --git a/docs/en/designers/language-modifiers/language-modifier-count-paragraphs.xml b/docs/en/designers/language-modifiers/language-modifier-count-paragraphs.xml index 8d5c7d35..e956ae90 100644 --- a/docs/en/designers/language-modifiers/language-modifier-count-paragraphs.xml +++ b/docs/en/designers/language-modifiers/language-modifier-count-paragraphs.xml @@ -10,15 +10,17 @@ assign('articleTitle', "War Dims Hope for Peace. Child's Death Ruins -Couple's Holiday.\n\nMan is Fatally Slain. Death Causes Loneliness, Feeling of Isolation."); -$smarty->display('index.tpl'); + +$smarty->assign('articleTitle', + "War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.\n\n + Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation." + ); + ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', 'Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.'); -$smarty->display('index.tpl'); +$smarty->assign('articleTitle', + 'Two Soviet Ships Collide - One Dies. + Enraged Cow Injures Farmer with Axe.' + ); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.'); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: assign('yesterday', strtotime('-1 day')); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: - %p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale + %p - either `am' or `pm' according to the given time value, or the corresponding strings for the + current locale %r - time in a.m. and p.m. notation @@ -172,17 +171,20 @@ Monday, February 5, 2001 %u - weekday as a decimal number [1,7], with 1 representing Monday - %U - week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week + %U - week number of the current year as a decimal number, starting with the first Sunday as the first + day of the first week - %V - The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current + %V - The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week + 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. %w - day of the week as a decimal, Sunday being 0 - %W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week + %W - week number of the current year as a decimal number, starting with the first Monday as the first + day of the first week %x - preferred date representation for the current locale without the time @@ -242,3 +244,4 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> + diff --git a/docs/en/designers/language-modifiers/language-modifier-default.xml b/docs/en/designers/language-modifiers/language-modifier-default.xml index b723b673..ced3513e 100644 --- a/docs/en/designers/language-modifiers/language-modifier-default.xml +++ b/docs/en/designers/language-modifiers/language-modifier-default.xml @@ -41,15 +41,13 @@ assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.'); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', "'Stiff Opposition Expected to Casketless Funeral Plan'"); -$smarty->display('index.tpl'); +$smarty->assign('articleTitle', + "'Stiff Opposition Expected to Casketless Funeral Plan'" + ); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', 'NJ judge to rule on nude beach. +$smarty->assign('articleTitle', + 'NJ judge to rule on nude beach. Sun or rain expected today, dark tonight. -Statistics show that teen pregnancy drops off significantly after 25.'); -$smarty->display('index.tpl'); +Statistics show that teen pregnancy drops off significantly after 25.' + ); + ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.'); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', "Sun or rain expected\ntoday, dark tonight"); -$smarty->display('index.tpl'); +$smarty->assign('articleTitle', + "Sun or rain expected\ntoday, dark tonight" + ); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say."); -$smarty->display('index.tpl'); ?> ]]> diff --git a/docs/en/designers/language-modifiers/language-modifier-replace.xml b/docs/en/designers/language-modifiers/language-modifier-replace.xml index d578c828..6d40dbd3 100644 --- a/docs/en/designers/language-modifiers/language-modifier-replace.xml +++ b/docs/en/designers/language-modifiers/language-modifier-replace.xml @@ -46,15 +46,13 @@ assign('articleTitle', "Child's Stool Great for Use in Garden."); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.'); -$smarty->display('index.tpl'); + ?> ]]> - Where index.tpl is: + Where template is: assign('number', 23.5787446); -$smarty->display('index.tpl'); ?> ]]> - Where index.tpl is: + Where template is: assign('articleTitle', "Blind Woman Gets New -Kidney from Dad she Hasn't Seen in years."); -$smarty->display('index.tpl'); +$smarty->assign('articleTitle', + "Blind Woman Gets New +Kidney from Dad she Hasn't Seen in years." + ); ?> ]]> - where index.tpl is: + where template is: Note If you want to strip blocks of template text, use the strip function. + linkend="language.function.strip">{strip} function. @@ -27,7 +27,7 @@ $smarty->display('index.tpl'); ]]> - where index.tpl is: + where template is: assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'); -$smarty->display('index.tpl'); ?> ]]> - where index.tpl is: + where template is: assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While."); -$smarty->display('index.tpl'); ?> ]]> - where index.tpl is: + where template is: - This wraps a string to a column width, default is 80. As + wordwrap wraps a string to a column width, default is 80. As an optional second parameter, you can specify a string of text to wrap the text to the next line (default is carriage return \n). - By default, wordwrap will attempt to wrap at a word boundary. If + By default, {wordwrap} will attempt to wrap at a word boundary. If you want to cut off at the exact character length, pass the optional third parameter of true. This is equivalent to the PHP wordwrap() function. @@ -60,15 +60,15 @@ assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years."); -$smarty->display('index.tpl'); +$smarty->assign('articleTitle', + "Blind woman gets new kidney from dad she hasn't seen in years." + ); ?> ]]> - where index.tpl is: +where template is - See also nl2br. + See also nl2br + and + {textformat}. @@ -134,3 +136,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/entities/global.ent b/docs/entities/global.ent index bb16918e..c60cffa7 100644 --- a/docs/entities/global.ent +++ b/docs/entities/global.ent @@ -9,6 +9,7 @@ +