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

View File

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

View File

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

View File

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

View File

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

View File

@@ -70,67 +70,87 @@
</para>
<para>
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.
</para>
<para>
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.
</para>
<example>
<title>html_options</title>
<title>html_options : Example 1</title>
<programlisting>
EXAMPLE 1
---------
<![CDATA[
index.php:
----------
require('Smarty.class.php');
$smarty = new Smarty;
$smarty-&gt;assign('cust_ids', array(1000,1001,1002,1003));
$smarty-&gt;assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001);
$smarty-&gt;display('index.tpl');
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');
]]>
</programlisting>
<para>
Where index.tpl is:
</para>
<programlisting>
<![CDATA[
index.tpl:
&lt;select name=customer_id&gt;
<select name=customer_id>
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
&lt;/select&gt;
EXAMPLE 2
---------
</select>
]]>
</programlisting>
<para>
Example 2
</para>
<programlisting>
<![CDATA[
index.php:
----------
require('Smarty.class.php');
$smarty = new Smarty;
$smarty-&gt;assign('cust_options', array(
1001 =&gt; 'Joe Schmoe',
1002 =&gt; 'Jack Smith',
1003 =&gt; 'Jane Johnson',
1004 =&gt; 'Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001);
$smarty-&gt;display('index.tpl');
$smarty->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');
]]>
</programlisting>
<para>
Where index.tpl is:
</para>
<programlisting>
<![CDATA[
index.tpl:
&lt;select name=customer_id&gt;
<select name=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;
&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>
]]>
</screen>
</example>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -72,54 +72,74 @@
</para>
<para>
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>
<example>
<title>html_radios</title>
<title>html_radios : Example 1</title>
<programlisting>
<![CDATA[
index.php:
----------
require('Smarty.class.php');
$smarty = new Smarty;
$smarty-&gt;assign('cust_ids', array(1000,1001,1002,1003));
$smarty-&gt;assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001);
$smarty-&gt;display('index.tpl');
index.tpl:
{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="&lt;br /&gt;"}
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');
]]>
</programlisting>
<para>
Where index.tpl is:
</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:
----------
require('Smarty.class.php');
$smarty = new Smarty;
$smarty-&gt;assign('cust_radios', array(
1000 =&gt; 'Joe Schmoe',
1001 =&gt; 'Jack Smith',
1002 =&gt; 'Jane Johnson',
1003 =&gt; 'Charlie Brown'));
$smarty-&gt;assign('customer_id', 1001);
$smarty-&gt;display('index.tpl');
index.tpl:
{html_radios name="id" options=$cust_radios selected=$customer_id separator="&lt;br /&gt;"}
OUTPUT: (both examples)
&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;
&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;
&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;
&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>
$smarty->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');
]]>
</programlisting>
<para>
Where index.tpl is:
</para>
<programlisting>
<![CDATA[
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
]]>
</programlisting>
<para>
Both examples will output:
</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>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml

View File

@@ -105,6 +105,7 @@
<example>
<title>mailto</title>
<programlisting>
<![CDATA[
{mailto address="me@example.com"}
{mailto address="me@example.com" text="send me some mail"}
{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" extra='class="email"'}
{mailto address="me@example.com" encode="javascript_charcode"}
OUTPUT:
&lt;a href="mailto:me@example.com" &gt;me@example.com&lt;/a&gt;
&lt;a href="mailto:me@example.com" &gt;send me some mail&lt;/a&gt;
&lt;script type="text/javascript" language="javascript"&gt;eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%6
]]>
</programlisting>
<para>
The above example will output:
</para>
<screen>
<![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%
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;
&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;
&lt;a href="mailto:me@example.com?subject=Hello%20to%20you%21" &gt;me@example.com&lt;/a&gt;
&lt;a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" &gt;me@example.com&lt;/a&gt;
&lt;a href="mailto:me@example.com" class="email"&gt;me@example.com&lt;/a&gt;
&lt;script type="text/javascript" language="javascript"&gt;
&lt;!--
%27%29%3b'))</script>
<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>
<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>
<a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" >me@example.com</a>
<a href="mailto:me@example.com" class="email">me@example.com</a>
<script type="text/javascript" language="javascript">
<!--
{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>
</sect1>
<!-- Keep this comment at the end of the file