* some wz

* no tab
* add Cdata section
This commit is contained in:
yannick
2005-05-10 11:42:40 +00:00
parent e48ef064fe
commit 6793e12b17
10 changed files with 1674 additions and 1524 deletions

View File

@@ -73,45 +73,59 @@
<example> <example>
<title>foreach</title> <title>foreach</title>
<programlisting> <programlisting>
<![CDATA[
{* this example will print out all the values of the $custid array *} {* this example will print out all the values of the $custid array *}
{foreach from=$custid item=curr_id} {foreach from=$custid item=curr_id}
id: {$curr_id}&lt;br&gt; id: {$curr_id}<br />
{/foreach} {/foreach}
]]>
OUTPUT: </programlisting>
<para>
id: 1000&lt;br&gt; The above example will output:
id: 1001&lt;br&gt; </para>
id: 1002&lt;br&gt;</programlisting> <screen>
<![CDATA[
id: 1000<br />
id: 1001<br />
id: 1002<br />
]]>
</screen>
</example> </example>
<example> <example>
<title>foreach key</title> <title>foreach key</title>
<programlisting> <programlisting>
<![CDATA[
{* The key contains the key for each looped value {* The key contains the key for each looped value
assignment looks like this: assignment looks like this:
$smarty->assign("contacts", array(array("phone" =&gt; "1", "fax" =&gt; "2", "cell" =&gt; "3"), $smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" =&gt; "555-4444", "fax" =&gt; "555-3333", "cell" =&gt; "760-1234"))); array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
*} *}
{foreach name=outer item=contact from=$contacts} {foreach name=outer item=contact from=$contacts}
{foreach key=key item=item from=$contact} {foreach key=key item=item from=$contact}
{$key}: {$item}&lt;br&gt; {$key}: {$item}<br />
{/foreach} {/foreach}
{/foreach} {/foreach}
]]>
OUTPUT: </programlisting>
<para>
phone: 1&lt;br&gt; The above example will output:
fax: 2&lt;br&gt; </para>
cell: 3&lt;br&gt; <screen>
phone: 555-4444&lt;br&gt; <![CDATA[
fax: 555-3333&lt;br&gt; phone: 1<br />
cell: 760-1234&lt;br&gt;</programlisting> fax: 2<br />
cell: 3<br />
phone: 555-4444<br />
fax: 555-3333<br />
cell: 760-1234<br />
]]>
</screen>
</example> </example>
<para> <para>
@@ -121,7 +135,6 @@ cell: 760-1234&lt;br&gt;</programlisting>
attribute of foreach attribute of foreach
</para> </para>
<sect2 id="foreach.property.iteration"> <sect2 id="foreach.property.iteration">
<title>iteration</title> <title>iteration</title>
<para> <para>
@@ -166,11 +179,6 @@ cell: 760-1234&lt;br&gt;</programlisting>
will loop. This can be used inside or after the foreach. will loop. This can be used inside or after the foreach.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:

View File

@@ -139,6 +139,7 @@
<example> <example>
<title>if statements</title> <title>if statements</title>
<programlisting> <programlisting>
<![CDATA[
{if $name eq "Fred"} {if $name eq "Fred"}
Welcome Sir. Welcome Sir.
{elseif $name eq "Wilma"} {elseif $name eq "Wilma"}
@@ -165,7 +166,7 @@
{* parenthesis are allowed *} {* parenthesis are allowed *}
{if ( $amount &lt; 0 or $amount &gt; 1000 ) and $volume >= #minVolAmt#} {if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
... ...
{/if} {/if}
@@ -199,7 +200,9 @@
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *} {* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
{if $var is even by 3} {if $var is even by 3}
... ...
{/if}</programlisting> {/if}
]]>
</programlisting>
</example> </example>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -94,10 +94,11 @@
<example> <example>
<title>function include_php</title> <title>function include_php</title>
<programlisting> <programlisting>
<![CDATA[
load_nav.php load_nav.php
------------- -------------
&lt;?php <?php
// load in variables from a mysql db and assign them to the template // load in variables from a mysql db and assign them to the template
require_once("MySQL.class.php"); require_once("MySQL.class.php");
@@ -105,18 +106,22 @@ load_nav.php
$sql->query("select * from site_nav_sections order by name",SQL_ALL); $sql->query("select * from site_nav_sections order by name",SQL_ALL);
$this->assign('sections',$sql->record); $this->assign('sections',$sql->record);
?&gt; ?>
]]>
</programlisting>
index.tpl <para>
--------- Where index.pl is:
</para>
<programlisting>
<![CDATA[
{* absolute path, or relative to $trusted_dir *} {* absolute path, or relative to $trusted_dir *}
{include_php file="/path/to/load_nav.php"} {include_php file="/path/to/load_nav.php"}
{foreach item="curr_section" from=$sections} {foreach item="curr_section" from=$sections}
&lt;a href="{$curr_section.url}"&gt;{$curr_section.name}&lt;/a&gt;&lt;br&gt; <a href="{$curr_section.url}">{$curr_section.name}</a><br />
{/foreach}</programlisting> {/foreach}
]]>
</programlisting>
</example> </example>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
@@ -138,4 +143,3 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
-->

View File

@@ -91,146 +91,174 @@
<example> <example>
<title>section</title> <title>section</title>
<programlisting> <programlisting>
<![CDATA[
{* this example will print out all the values of the $custid array *} {* this example will print out all the values of the $custid array *}
{section name=customer loop=$custid} {section name=customer loop=$custid}
id: {$custid[customer]}&lt;br&gt; id: {$custid[customer]}<br />
{/section} {/section}
]]>
OUTPUT: </programlisting>
<para>
id: 1000&lt;br&gt; The above example will output:
id: 1001&lt;br&gt; </para>
id: 1002&lt;br&gt;</programlisting> <screen>
<![CDATA[
id: 1000<br />
id: 1001<br />
id: 1002<br />
]]>
</screen>
</example> </example>
<example> <example>
<title>section loop variable</title> <title>section loop variable</title>
<programlisting> <programlisting>
<![CDATA[
{* the loop variable only determines the number of times to loop. {* the loop variable only determines the number of times to loop.
you can access any variable from the template within the section. you can access any variable from the template within the section.
This example assumes that $custid, $name and $address are all This example assumes that $custid, $name and $address are all
arrays containing the same number of values *} arrays containing the same number of values *}
{section name=customer loop=$custid} {section name=customer loop=$custid}
id: {$custid[customer]}&lt;br&gt; id: {$custid[customer]}<br />
name: {$name[customer]}&lt;br&gt; name: {$name[customer]}<br />
address: {$address[customer]}&lt;br&gt; address: {$address[customer]}<br />
&lt;p&gt; <p>
{/section} {/section}
]]>
</programlisting>
OUTPUT: <para>
The above example will output:
id: 1000&lt;br&gt; </para>
name: John Smith&lt;br&gt; <screen>
address: 253 N 45th&lt;br&gt; <![CDATA[
&lt;p&gt; id: 1000<br />
id: 1001&lt;br&gt; name: John Smith<br />
name: Jack Jones&lt;br&gt; address: 253 N 45th<br />
address: 417 Mulberry ln&lt;br&gt; <p>
&lt;p&gt; id: 1001<br />
id: 1002&lt;br&gt; name: Jack Jones<br />
name: Jane Munson&lt;br&gt; address: 417 Mulberry ln<br />
address: 5605 apple st&lt;br&gt; <p>
&lt;p&gt;</programlisting> id: 1002<br />
name: Jane Munson<br />
address: 5605 apple st<br />
<p>
]]>
</screen>
</example> </example>
<example> <example>
<title>section names</title> <title>section names</title>
<programlisting> <programlisting>
<![CDATA[
{* the name of the section can be anything you like, {* the name of the section can be anything you like,
and it is used to reference the data within the section *} and it is used to reference the data within the section *}
{section name=mydata loop=$custid} {section name=mydata loop=$custid}
id: {$custid[mydata]}&lt;br&gt; id: {$custid[mydata]}<br />
name: {$name[mydata]}&lt;br&gt; name: {$name[mydata]}<br />
address: {$address[mydata]}&lt;br&gt; address: {$address[mydata]}<br />
&lt;p&gt; <p>
{/section}</programlisting> {/section}
]]>
</programlisting>
</example> </example>
<example> <example>
<title>nested sections</title> <title>nested sections</title>
<programlisting> <programlisting>
<![CDATA[
{* sections can be nested as deep as you like. With nested sections, {* sections can be nested as deep as you like. With nested sections,
you can access complex data structures, such as multi-dimensional you can access complex data structures, such as multi-dimensional
arrays. In this example, $contact_type[customer] is an array of arrays. In this example, $contact_type[customer] is an array of
contact types for the current customer. *} contact types for the current customer. *}
{section name=customer loop=$custid} {section name=customer loop=$custid}
id: {$custid[customer]}&lt;br&gt; id: {$custid[customer]}<br />
name: {$name[customer]}&lt;br&gt; name: {$name[customer]}<br />
address: {$address[customer]}&lt;br&gt; address: {$address[customer]}<br />
{section name=contact loop=$contact_type[customer]} {section name=contact loop=$contact_type[customer]}
{$contact_type[customer][contact]}: {$contact_info[customer][contact]}&lt;br&gt; {$contact_type[customer][contact]}: {$contact_info[customer][contact]}<br />
{/section} {/section}
&lt;p&gt; <p>
{/section} {/section}
]]>
</programlisting>
OUTPUT: <para>
The above example will output:
id: 1000&lt;br&gt; </para>
name: John Smith&lt;br&gt; <screen>
address: 253 N 45th&lt;br&gt; <![CDATA[
home phone: 555-555-5555&lt;br&gt; id: 1000<br />
cell phone: 555-555-5555&lt;br&gt; name: John Smith<br />
e-mail: john@myexample.com&lt;br&gt; address: 253 N 45th<br />
&lt;p&gt; home phone: 555-555-5555<br />
id: 1001&lt;br&gt; cell phone: 555-555-5555<br />
name: Jack Jones&lt;br&gt; e-mail: john@myexample.com<br />
address: 417 Mulberry ln&lt;br&gt; <p>
home phone: 555-555-5555&lt;br&gt; id: 1001<br />
cell phone: 555-555-5555&lt;br&gt; name: Jack Jones<br />
e-mail: jack@myexample.com&lt;br&gt; address: 417 Mulberry ln<br />
&lt;p&gt; home phone: 555-555-5555<br />
id: 1002&lt;br&gt; cell phone: 555-555-5555<br />
name: Jane Munson&lt;br&gt; e-mail: jack@myexample.com<br />
address: 5605 apple st&lt;br&gt; <p>
home phone: 555-555-5555&lt;br&gt; id: 1002<br />
cell phone: 555-555-5555&lt;br&gt; name: Jane Munson<br />
e-mail: jane@myexample.com&lt;br&gt; address: 5605 apple st<br />
&lt;p&gt;</programlisting> home phone: 555-555-5555<br />
cell phone: 555-555-5555<br />
e-mail: jane@myexample.com<br />
<p>
]]>
</screen>
</example> </example>
<example> <example>
<title>sections and associative arrays</title> <title>sections and associative arrays</title>
<programlisting> <programlisting>
<![CDATA[
{* This is an example of printing an associative array {* This is an example of printing an associative array
of data within a section *} of data within a section *}
{section name=customer loop=$contacts} {section name=customer loop=$contacts}
name: {$contacts[customer].name}&lt;br&gt; name: {$contacts[customer].name}<br />
home: {$contacts[customer].home}&lt;br&gt; home: {$contacts[customer].home}<br />
cell: {$contacts[customer].cell}&lt;br&gt; cell: {$contacts[customer].cell}<br />
e-mail: {$contacts[customer].email}&lt;p&gt; e-mail: {$contacts[customer].email}<p>
{/section} {/section}
]]>
</programlisting>
OUTPUT: <para>
The above example will output:
name: John Smith&lt;br&gt; </para>
home: 555-555-5555&lt;br&gt; <screen>
cell: 555-555-5555&lt;br&gt; <![CDATA[
e-mail: john@myexample.com&lt;p&gt; name: John Smith<br />
name: Jack Jones&lt;br&gt; home: 555-555-5555<br />
home phone: 555-555-5555&lt;br&gt; cell: 555-555-5555<br />
cell phone: 555-555-5555&lt;br&gt; e-mail: john@myexample.com<p>
e-mail: jack@myexample.com&lt;p&gt; name: Jack Jones<br />
name: Jane Munson&lt;br&gt; home phone: 555-555-5555<br />
home phone: 555-555-5555&lt;br&gt; cell phone: 555-555-5555<br />
cell phone: 555-555-5555&lt;br&gt; e-mail: jack@myexample.com<p>
e-mail: jane@myexample.com&lt;p&gt;</programlisting> name: Jane Munson<br />
home phone: 555-555-5555<br />
cell phone: 555-555-5555<br />
e-mail: jane@myexample.com<p>
]]>
</screen>
</example> </example>
<example> <example>
<title>sectionelse</title> <title>sectionelse</title>
<programlisting> <programlisting>
<![CDATA[
{* sectionelse will execute if there are no $custid values *} {* sectionelse will execute if there are no $custid values *}
{section name=customer loop=$custid} {section name=customer loop=$custid}
id: {$custid[customer]}&lt;br&gt; id: {$custid[customer]}<br />
{sectionelse} {sectionelse}
there are no values in $custid. there are no values in $custid.
{/section}</programlisting> {/section}
]]>
</programlisting>
</example> </example>
<para> <para>
Sections also have their own variables that handle section properties. Sections also have their own variables that handle section properties.
@@ -263,17 +291,22 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property index</title> <title>section property index</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section} {/section}
]]>
OUTPUT:
0 id: 1000&lt;br&gt;
1 id: 1001&lt;br&gt;
2 id: 1002&lt;br&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
0 id: 1000<br />
1 id: 1001<br />
2 id: 1002<br />
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.index.prev"> <sect2 id="section.property.index.prev">
@@ -285,24 +318,29 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property index_prev</title> <title>section property index_prev</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.index} id: {$custid[customer]}<br />
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *} {* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
{if $custid[customer.index_prev] ne $custid[customer.index]} {if $custid[customer.index_prev] ne $custid[customer.index]}
The customer id changed&lt;br&gt; The customer id changed<br />
{/if} {/if}
{/section} {/section}
]]>
OUTPUT:
0 id: 1000&lt;br&gt;
The customer id changed&lt;br&gt;
1 id: 1001&lt;br&gt;
The customer id changed&lt;br&gt;
2 id: 1002&lt;br&gt;
The customer id changed&lt;br&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
0 id: 1000<br />
The customer id changed<br />
1 id: 1001<br />
The customer id changed<br />
2 id: 1002<br />
The customer id changed<br />
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.index.next"> <sect2 id="section.property.index.next">
@@ -315,24 +353,29 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property index_next</title> <title>section property index_next</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.index} id: {$custid[customer]}<br />
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *} {* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
{if $custid[customer.index_next] ne $custid[customer.index]} {if $custid[customer.index_next] ne $custid[customer.index]}
The customer id will change&lt;br&gt; The customer id will change<br />
{/if} {/if}
{/section} {/section}
]]>
OUTPUT:
0 id: 1000&lt;br&gt;
The customer id will change&lt;br&gt;
1 id: 1001&lt;br&gt;
The customer id will change&lt;br&gt;
2 id: 1002&lt;br&gt;
The customer id will change&lt;br&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
0 id: 1000<br />
The customer id will change<br />
1 id: 1001<br />
The customer id will change<br />
2 id: 1002<br />
The customer id will change<br />
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.iteration"> <sect2 id="section.property.iteration">
@@ -351,28 +394,33 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property iteration</title> <title>section property iteration</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid start=5 step=2} {section name=customer loop=$custid start=5 step=2}
current loop iteration: {$smarty.section.customer.iteration}&lt;br&gt; current loop iteration: {$smarty.section.customer.iteration}<br />
{$smarty.section.customer.index} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.index} id: {$custid[customer]}<br />
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *} {* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
{if $custid[customer.index_next] ne $custid[customer.index]} {if $custid[customer.index_next] ne $custid[customer.index]}
The customer id will change&lt;br&gt; The customer id will change<br />
{/if} {/if}
{/section} {/section}
]]>
OUTPUT:
current loop iteration: 1
5 id: 1000&lt;br&gt;
The customer id will change&lt;br&gt;
current loop iteration: 2
7 id: 1001&lt;br&gt;
The customer id will change&lt;br&gt;
current loop iteration: 3
9 id: 1002&lt;br&gt;
The customer id will change&lt;br&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
current loop iteration: 1
5 id: 1000<br />
The customer id will change<br />
current loop iteration: 2
7 id: 1001<br />
The customer id will change<br />
current loop iteration: 3
9 id: 1002<br />
The customer id will change<br />
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.first"> <sect2 id="section.property.first">
@@ -384,28 +432,33 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property first</title> <title>section property first</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{if $smarty.section.customer.first} {if $smarty.section.customer.first}
&lt;table&gt; <table>
{/if} {/if}
&lt;tr&gt;&lt;td&gt;{$smarty.section.customer.index} id: <tr><td>{$smarty.section.customer.index} id:
{$custid[customer]}&lt;/td&gt;&lt;/tr&gt; {$custid[customer]}</td></tr>
{if $smarty.section.customer.last} {if $smarty.section.customer.last}
&lt;/table&gt; </table>
{/if} {/if}
{/section} {/section}
]]>
OUTPUT:
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;0 id: 1000&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1 id: 1001&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;2 id: 1002&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
<table>
<tr><td>0 id: 1000</td></tr>
<tr><td>1 id: 1001</td></tr>
<tr><td>2 id: 1002</td></tr>
</table>
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.last"> <sect2 id="section.property.last">
@@ -417,28 +470,33 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property last</title> <title>section property last</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{if $smarty.section.customer.first} {if $smarty.section.customer.first}
&lt;table&gt; <table>
{/if} {/if}
&lt;tr&gt;&lt;td&gt;{$smarty.section.customer.index} id: <tr><td>{$smarty.section.customer.index} id:
{$custid[customer]}&lt;/td&gt;&lt;/tr&gt; {$custid[customer]}</td></tr>
{if $smarty.section.customer.last} {if $smarty.section.customer.last}
&lt;/table&gt; </table>
{/if} {/if}
{/section} {/section}
]]>
OUTPUT:
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;0 id: 1000&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1 id: 1001&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;2 id: 1002&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
<table>
<tr><td>0 id: 1000</td></tr>
<tr><td>1 id: 1001</td></tr>
<tr><td>2 id: 1002</td></tr>
</table>
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.rownum"> <sect2 id="section.property.rownum">
@@ -451,17 +509,22 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property rownum</title> <title>section property rownum</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{$smarty.section.customer.rownum} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.rownum} id: {$custid[customer]}<br />
{/section} {/section}
]]>
OUTPUT:
1 id: 1000&lt;br&gt;
2 id: 1001&lt;br&gt;
3 id: 1002&lt;br&gt;
</programlisting> </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
1 id: 1000<br />
2 id: 1001<br />
3 id: 1002<br />
]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.loop"> <sect2 id="section.property.loop">
@@ -473,20 +536,26 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property index</title> <title>section property index</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid} {section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section} {/section}
There were {$smarty.section.customer.loop} customers shown above. There were {$smarty.section.customer.loop} customers shown above.
]]>
OUTPUT: </programlisting>
<para>
0 id: 1000&lt;br&gt; The above example will output:
1 id: 1001&lt;br&gt; </para>
2 id: 1002&lt;br&gt; <screen>
<![CDATA[
0 id: 1000<br />
1 id: 1001<br />
2 id: 1002<br />
There were 3 customers shown above. There were 3 customers shown above.
</programlisting> ]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.show"> <sect2 id="section.property.show">
@@ -500,10 +569,11 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section attribute show</title> <title>section attribute show</title>
<programlisting> <programlisting>
<![CDATA[
{* $show_customer_info may have been passed from the PHP {* $show_customer_info may have been passed from the PHP
application, to regulate whether or not this section shows *} application, to regulate whether or not this section shows *}
{section name=customer loop=$custid show=$show_customer_info} {section name=customer loop=$custid show=$show_customer_info}
{$smarty.section.customer.rownum} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.rownum} id: {$custid[customer]}<br />
{/section} {/section}
{if $smarty.section.customer.show} {if $smarty.section.customer.show}
@@ -511,16 +581,20 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
{else} {else}
the section was not shown. the section was not shown.
{/if} {/if}
]]>
</programlisting>
OUTPUT: <para>
The above example will output:
1 id: 1000&lt;br&gt; </para>
2 id: 1001&lt;br&gt; <screen>
3 id: 1002&lt;br&gt; <![CDATA[
1 id: 1000<br />
2 id: 1001<br />
3 id: 1002<br />
the section was shown. the section was shown.
</programlisting> ]]>
</screen>
</example> </example>
</sect2> </sect2>
<sect2 id="section.property.total"> <sect2 id="section.property.total">
@@ -532,20 +606,26 @@ e-mail: jane@myexample.com&lt;p&gt;</programlisting>
<example> <example>
<title>section property total</title> <title>section property total</title>
<programlisting> <programlisting>
<![CDATA[
{section name=customer loop=$custid step=2} {section name=customer loop=$custid step=2}
{$smarty.section.customer.index} id: {$custid[customer]}&lt;br&gt; {$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section} {/section}
There were {$smarty.section.customer.total} customers shown above. There were {$smarty.section.customer.total} customers shown above.
]]>
OUTPUT: </programlisting>
<para>
0 id: 1000&lt;br&gt; The above example will output:
2 id: 1001&lt;br&gt; </para>
4 id: 1002&lt;br&gt; <screen>
<![CDATA[
0 id: 1000<br />
2 id: 1001<br />
4 id: 1002<br />
There were 3 customers shown above. There were 3 customers shown above.
</programlisting> ]]>
</screen>
</example> </example>
</sect2> </sect2>
</sect1> </sect1>

View File

@@ -66,19 +66,22 @@
<example> <example>
<title>eval</title> <title>eval</title>
<programlisting> <programlisting>
<![CDATA[
setup.conf setup.conf
---------- ----------
emphstart = &lt;b&gt; emphstart = <strong>
emphend = &lt;/b&gt; emphend = </strong>
title = Welcome to {$company}'s home page! title = Welcome to {$company}'s home page!
ErrorCity = You must supply a {#emphstart#}city{#emphend#}. ErrorCity = You must supply a {#emphstart#}city{#emphend#}.
ErrorState = You must supply a {#emphstart#}state{#emphend#}. ErrorState = You must supply a {#emphstart#}state{#emphend#}.
]]>
</programlisting>
index.tpl <para>
--------- Where index.tpl is:
</para>
<programlisting>
<![CDATA[
{config_load file="setup.conf"} {config_load file="setup.conf"}
{eval var=$foo} {eval var=$foo}
@@ -86,15 +89,21 @@ index.tpl
{eval var=#ErrorCity#} {eval var=#ErrorCity#}
{eval var=#ErrorState# assign="state_error"} {eval var=#ErrorState# assign="state_error"}
{$state_error} {$state_error}
]]>
OUTPUT: </programlisting>
<para>
The above example will output:
</para>
<screen>
<![CDATA[
This is the contents of foo. This is the contents of foo.
Welcome to Foobar Pub &amp; Grill's home page! Welcome to Foobar Pub & Grill's home page!
You must supply a &lt;b&gt;city&lt;/b&gt;. You must supply a <strong>city</strong>.
You must supply a &lt;b&gt;state&lt;/b&gt;. You must supply a <strong>state</strong>.
</programlisting> ]]>
</screen>
</example> </example>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -70,67 +70,87 @@
</para> </para>
<para> <para>
If the optional <emphasis>name</emphasis> attribute is given, the If the optional <emphasis>name</emphasis> attribute is given, the
&lt;select name="groupname"&gt;&lt;/select&gt; tags will enclose <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.
</para> </para>
<para> <para>
All parameters that are not in the list above are printed as All parameters that are not in the list above are printed as
name/value-pairs inside the &lt;select&gt;-tag. They are ignored if name/value-pairs inside the <select>-tag. They are ignored if
the optional <emphasis>name</emphasis> is not given. the optional <emphasis>name</emphasis> is not given.
</para> </para>
<example> <example>
<title>html_options</title> <title>html_options : Example 1</title>
<programlisting> <programlisting>
EXAMPLE 1 <![CDATA[
---------
index.php: index.php:
----------
require('Smarty.class.php'); require('Smarty.class.php');
$smarty = new Smarty; $smarty = new Smarty;
$smarty-&gt;assign('cust_ids', array(1000,1001,1002,1003)); $smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty-&gt;assign('cust_names', array('Joe Schmoe','Jack Smith','Jane $smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Charlie Brown')); Johnson','Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001); $smarty->assign('customer_id', 1001);
$smarty-&gt;display('index.tpl'); $smarty->display('index.tpl');
]]>
</programlisting>
<para>
Where index.tpl is:
</para>
<programlisting>
<![CDATA[
index.tpl: <select name=customer_id>
&lt;select name=customer_id&gt;
{html_options values=$cust_ids selected=$customer_id output=$cust_names} {html_options values=$cust_ids selected=$customer_id output=$cust_names}
&lt;/select&gt; </select>
]]>
EXAMPLE 2 </programlisting>
--------- <para>
Example 2
</para>
<programlisting>
<![CDATA[
index.php: index.php:
----------
require('Smarty.class.php'); require('Smarty.class.php');
$smarty = new Smarty; $smarty = new Smarty;
$smarty-&gt;assign('cust_options', array( $smarty->assign('cust_options', array(
1001 =&gt; 'Joe Schmoe', 1001 => 'Joe Schmoe',
1002 =&gt; 'Jack Smith', 1002 => 'Jack Smith',
1003 =&gt; 'Jane Johnson', 1003 => 'Jane Johnson',
1004 =&gt; 'Charlie Brown')); 1004 => 'Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001); $smarty->assign('customer_id', 1001);
$smarty-&gt;display('index.tpl'); $smarty->display('index.tpl');
]]>
</programlisting>
<para>
Where index.tpl is:
</para>
<programlisting>
<![CDATA[
index.tpl: <select name=customer_id>
&lt;select name=customer_id&gt;
{html_options options=$cust_options selected=$customer_id} {html_options options=$cust_options selected=$customer_id}
&lt;/select&gt; </select>
]]>
</programlisting>
<para>
Both examples will output:
</para>
<screen>
<![CDATA[
OUTPUT: (both examples) <select name=customer_id>
----------------------- <option label="Joe Schmoe" value="1000">Joe Schmoe</option>
<option label="Jack Smith" value="1001" selected="selected">Jack Smith</option>
<option label="Jane Johnson" value="1002">Jane Johnson</option>
<option label="Charlie Brown" value="1003">Charlie Brown</option>
</select>
&lt;select name=customer_id&gt; ]]>
&lt;option label="Joe Schmoe" value="1000"&gt;Joe Schmoe&lt;/option&gt; </screen>
&lt;option label="Jack Smith" value="1001" selected="selected"&gt;Jack Smith&lt;/option&gt;
&lt;option label="Jane Johnson" value="1002"&gt;Jane Johnson&lt;/option&gt;
&lt;option label="Charlie Brown" value="1003"&gt;Charlie Brown&lt;/option&gt;
&lt;/select&gt;</programlisting>
</example> </example>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -72,54 +72,74 @@
</para> </para>
<para> <para>
All parameters that are not in the list above are printed as All parameters that are not in the list above are printed as
name/value-pairs inside each of the created &lt;input&gt;-tags. name/value-pairs inside each of the created <input>-tags.
</para> </para>
<example> <example>
<title>html_radios</title> <title>html_radios : Example 1</title>
<programlisting> <programlisting>
<![CDATA[
index.php: index.php:
----------
require('Smarty.class.php'); require('Smarty.class.php');
$smarty = new Smarty; $smarty = new Smarty;
$smarty-&gt;assign('cust_ids', array(1000,1001,1002,1003)); $smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty-&gt;assign('cust_names', array('Joe Schmoe','Jack Smith','Jane $smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Charlie Brown')); Johnson','Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001); $smarty->assign('customer_id', 1001);
$smarty-&gt;display('index.tpl'); $smarty->display('index.tpl');
]]>
</programlisting>
index.tpl: <para>
Where index.tpl is:
{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="&lt;br /&gt;"} </para>
<programlisting>
<![CDATA[
{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="<br />"}
]]>
</programlisting>
<para>
Example 2 :
</para>
<programlisting>
<![CDATA[
index.php: index.php:
----------
require('Smarty.class.php'); require('Smarty.class.php');
$smarty = new Smarty; $smarty = new Smarty;
$smarty-&gt;assign('cust_radios', array( $smarty->assign('cust_radios', array(
1000 =&gt; 'Joe Schmoe', 1000 => 'Joe Schmoe',
1001 =&gt; 'Jack Smith', 1001 => 'Jack Smith',
1002 =&gt; 'Jane Johnson', 1002 => 'Jane Johnson',
1003 =&gt; 'Charlie Brown')); 1003 => 'Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001); $smarty->assign('customer_id', 1001);
$smarty-&gt;display('index.tpl'); $smarty->display('index.tpl');
]]>
</programlisting>
index.tpl: <para>
Where index.tpl is:
{html_radios name="id" options=$cust_radios selected=$customer_id separator="&lt;br /&gt;"} </para>
<programlisting>
<![CDATA[
OUTPUT: (both examples) {html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
]]>
&lt;label for="id_1000"&gt;&lt;input type="radio" name="id" value="1000" id="id_1000" /&gt;Joe Schmoe&lt;/label&gt;&lt;br /&gt; </programlisting>
&lt;label for="id_1001"&gt;&lt;input type="radio" name="id" value="1001" id="id_1001" checked="checked" /&gt;Jack Smith&lt;/label&gt;&lt;br /&gt; <para>
&lt;label for="id_1002"&gt;&lt;input type="radio" name="id" value="1002" id="id_1002" /&gt;Jane Johnson&lt;/label&gt;&lt;br /&gt; Both examples will output:
&lt;label for="id_1003"&gt;&lt;input type="radio" name="id" value="1003" id="id_1003" /&gt;Charlie Brown&lt;/label&gt;&lt;br /&gt;</programlisting> </para>
<screen>
<![CDATA[
<label for="id_1000"><input type="radio" name="id" value="1000" id="id_1000" />Joe Schmoe</label><br />
<label for="id_1001"><input type="radio" name="id" value="1001" id="id_1001" checked="checked" />Jack Smith</label><br />
<label for="id_1002"><input type="radio" name="id" value="1002" id="id_1002" />Jane Johnson</label><br />
<label for="id_1003"><input type="radio" name="id" value="1003" id="id_1003" />Charlie Brown</label><br />
]]>
</screen>
</example> </example>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml

View File

@@ -105,6 +105,7 @@
<example> <example>
<title>mailto</title> <title>mailto</title>
<programlisting> <programlisting>
<![CDATA[
{mailto address="me@example.com"} {mailto address="me@example.com"}
{mailto address="me@example.com" text="send me some mail"} {mailto address="me@example.com" text="send me some mail"}
{mailto address="me@example.com" encode="javascript"} {mailto address="me@example.com" encode="javascript"}
@@ -113,25 +114,30 @@
{mailto address="me@example.com" cc="you@example.com,they@example.com"} {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" extra='class="email"'}
{mailto address="me@example.com" encode="javascript_charcode"} {mailto address="me@example.com" encode="javascript_charcode"}
]]>
</programlisting>
OUTPUT: <para>
The above example will output:
&lt;a href="mailto:me@example.com" &gt;me@example.com&lt;/a&gt; </para>
&lt;a href="mailto:me@example.com" &gt;send me some mail&lt;/a&gt; <screen>
&lt;script type="text/javascript" language="javascript"&gt;eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%6 <![CDATA[
<a href="mailto:me@example.com" >me@example.com</a>
<a href="mailto:me@example.com" >send me some mail</a>
<script type="text/javascript" language="javascript">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%6
9%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d% 9%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%
61%69%6e%2e%63%6f%6d%22%20%3e%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%3c%2f%61%3e 61%69%6e%2e%63%6f%6d%22%20%3e%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%3c%2f%61%3e
%27%29%3b'))&lt;/script&gt; %27%29%3b'))</script>
&lt;a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" &gt;&#x6d;&#x65;&#x40;&#x64;&#x6f;&#x6d;&#x61;&#x69;&#x6e;&#x2e;&#x63;&#x6f;&#x6d;&lt;/a&gt; <a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" >&#x6d;&#x65;&#x40;&#x64;&#x6f;&#x6d;&#x61;&#x69;&#x6e;&#x2e;&#x63;&#x6f;&#x6d;</a>
&lt;a href="mailto:me@example.com?subject=Hello%20to%20you%21" &gt;me@example.com&lt;/a&gt; <a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>
&lt;a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" &gt;me@example.com&lt;/a&gt; <a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" >me@example.com</a>
&lt;a href="mailto:me@example.com" class="email"&gt;me@example.com&lt;/a&gt; <a href="mailto:me@example.com" class="email">me@example.com</a>
&lt;script type="text/javascript" language="javascript"&gt; <script type="text/javascript" language="javascript">
&lt;!-- <!--
{document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))} {document.write(String.fromCharCode(60,97,32,104,114,101,102,61,34,109,97,105,108,116,111,58,109,101,64,101,120,97,109,112,108,101,46,99,111,109,34,32,62,109,101,64,101,120,97,109,112,108,101,46,99,111,109,60,47,97,62))}
//--&gt; //-->
&lt;/script&gt;</programlisting> </script>
]]>
</screen>
</example> </example>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file