mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
* some wz
* no tab * add Cdata section
This commit is contained in:
@@ -1,194 +1,202 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.foreach">
|
||||
<title>foreach,foreachelse</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>from</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The array you are looping through</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>item</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that is the current
|
||||
element</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>key</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that is the current key</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the foreach loop for accessing
|
||||
foreach properties</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
<emphasis>foreach</emphasis> loops are an alternative to
|
||||
<emphasis>section</emphasis> loops. <emphasis>foreach</emphasis> is
|
||||
used to loop over a single associative array. The syntax for
|
||||
<emphasis>foreach</emphasis> is much easier than
|
||||
<emphasis>section</emphasis>, but as a tradeoff it can only be used
|
||||
for a single array. <emphasis>foreach</emphasis> tags must be
|
||||
paired with <emphasis>/foreach</emphasis> tags. Required parameters
|
||||
are <emphasis>from</emphasis> and <emphasis>item</emphasis>. The
|
||||
name of the foreach loop can be anything you like, made up of
|
||||
letters, numbers and underscores. <emphasis>foreach</emphasis>
|
||||
loops can be nested, and the nested foreach names must be unique
|
||||
from each other. The <emphasis>from</emphasis> variable (usually an
|
||||
array of values) determines the number of times
|
||||
<emphasis>foreach</emphasis> will loop.
|
||||
<emphasis>foreachelse</emphasis> is executed when there are no
|
||||
values in the <emphasis>from</emphasis> variable.
|
||||
</para>
|
||||
<example>
|
||||
<title>foreach</title>
|
||||
<programlisting>
|
||||
<sect1 id="language.function.foreach">
|
||||
<title>foreach,foreachelse</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>from</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The array you are looping through</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>item</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that is the current
|
||||
element</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>key</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that is the current key</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the foreach loop for accessing
|
||||
foreach properties</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
<emphasis>foreach</emphasis> loops are an alternative to
|
||||
<emphasis>section</emphasis> loops. <emphasis>foreach</emphasis> is
|
||||
used to loop over a single associative array. The syntax for
|
||||
<emphasis>foreach</emphasis> is much easier than
|
||||
<emphasis>section</emphasis>, but as a tradeoff it can only be used
|
||||
for a single array. <emphasis>foreach</emphasis> tags must be
|
||||
paired with <emphasis>/foreach</emphasis> tags. Required parameters
|
||||
are <emphasis>from</emphasis> and <emphasis>item</emphasis>. The
|
||||
name of the foreach loop can be anything you like, made up of
|
||||
letters, numbers and underscores. <emphasis>foreach</emphasis>
|
||||
loops can be nested, and the nested foreach names must be unique
|
||||
from each other. The <emphasis>from</emphasis> variable (usually an
|
||||
array of values) determines the number of times
|
||||
<emphasis>foreach</emphasis> will loop.
|
||||
<emphasis>foreachelse</emphasis> is executed when there are no
|
||||
values in the <emphasis>from</emphasis> variable.
|
||||
</para>
|
||||
<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}<br>
|
||||
{/foreach}
|
||||
{* this example will print out all the values of the $custid array *}
|
||||
{foreach from=$custid item=curr_id}
|
||||
id: {$curr_id}<br />
|
||||
{/foreach}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The above example will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
id: 1000<br />
|
||||
id: 1001<br />
|
||||
id: 1002<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
OUTPUT:
|
||||
<example>
|
||||
<title>foreach key</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* The key contains the key for each looped value
|
||||
|
||||
id: 1000<br>
|
||||
id: 1001<br>
|
||||
id: 1002<br></programlisting>
|
||||
</example>
|
||||
assignment looks like this:
|
||||
|
||||
<example>
|
||||
<title>foreach key</title>
|
||||
<programlisting>
|
||||
{* The key contains the key for each looped value
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
||||
assignment looks like this:
|
||||
*}
|
||||
|
||||
$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}<br />
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
]]>
|
||||
</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>
|
||||
|
||||
*}
|
||||
|
||||
{foreach name=outer item=contact from=$contacts}
|
||||
{foreach key=key item=item from=$contact}
|
||||
{$key}: {$item}<br>
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
phone: 1<br>
|
||||
fax: 2<br>
|
||||
cell: 3<br>
|
||||
phone: 555-4444<br>
|
||||
fax: 555-3333<br>
|
||||
cell: 760-1234<br></programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Foreach-loops also have their own variables that handle foreach properties.
|
||||
These are indicated like so: {$smarty.foreach.foreachname.varname} with
|
||||
foreachname being the name specified as the <emphasis>name</emphasis>
|
||||
attribute of foreach
|
||||
</para>
|
||||
|
||||
|
||||
<sect2 id="foreach.property.iteration">
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
iteration is used to display the current loop iteration.
|
||||
</para>
|
||||
<para>
|
||||
Iteration always starts with 1 and is incremented by one
|
||||
one each iteration.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.first">
|
||||
<title>first</title>
|
||||
<para>
|
||||
<emphasis>first</emphasis> is set to true if the current foreach iteration is the first
|
||||
one.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.last">
|
||||
<title>last</title>
|
||||
<para>
|
||||
<emphasis>last</emphasis> is set to true if the current foreach iteration is the last
|
||||
one.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.show">
|
||||
<title>show</title>
|
||||
<para>
|
||||
<emphasis>show</emphasis> is used as a parameter to foreach.
|
||||
<emphasis>show</emphasis> is a boolean value, true or false. If
|
||||
false, the foreach will not be displayed. If there is a foreachelse
|
||||
present, that will be alternately displayed.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
<sect2 id="foreach.property.total">
|
||||
<title>total</title>
|
||||
<para>
|
||||
<emphasis>total</emphasis> is used to display the number of iterations that this foreach
|
||||
will loop. This can be used inside or after the foreach.
|
||||
</para>
|
||||
</sect2>
|
||||
<para>
|
||||
Foreach-loops also have their own variables that handle foreach properties.
|
||||
These are indicated like so: {$smarty.foreach.foreachname.varname} with
|
||||
foreachname being the name specified as the <emphasis>name</emphasis>
|
||||
attribute of foreach
|
||||
</para>
|
||||
|
||||
<sect2 id="foreach.property.iteration">
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
iteration is used to display the current loop iteration.
|
||||
</para>
|
||||
<para>
|
||||
Iteration always starts with 1 and is incremented by one
|
||||
one each iteration.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.first">
|
||||
<title>first</title>
|
||||
<para>
|
||||
<emphasis>first</emphasis> is set to true if the current foreach iteration is the first
|
||||
one.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.last">
|
||||
<title>last</title>
|
||||
<para>
|
||||
<emphasis>last</emphasis> is set to true if the current foreach iteration is the last
|
||||
one.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.show">
|
||||
<title>show</title>
|
||||
<para>
|
||||
<emphasis>show</emphasis> is used as a parameter to foreach.
|
||||
<emphasis>show</emphasis> is a boolean value, true or false. If
|
||||
false, the foreach will not be displayed. If there is a foreachelse
|
||||
present, that will be alternately displayed.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
<sect2 id="foreach.property.total">
|
||||
<title>total</title>
|
||||
<para>
|
||||
<emphasis>total</emphasis> is used to display the number of iterations that this foreach
|
||||
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:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
@@ -1,224 +1,227 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.if">
|
||||
<title>if,elseif,else</title>
|
||||
<para>
|
||||
<emphasis>{if}</emphasis> statements in Smarty have much the same flexibility as PHP if
|
||||
statements, with a few added features for the template engine.
|
||||
Every <emphasis>{if}</emphasis> must be paired with an
|
||||
<emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and
|
||||
<emphasis>{elseif}</emphasis> are also permitted. All PHP conditionals
|
||||
are recognized, such as <emphasis>||</emphasis>, <emphasis>or</emphasis>,
|
||||
<emphasis>&&</emphasis>, <emphasis>and</emphasis>, etc.
|
||||
</para>
|
||||
<sect1 id="language.function.if">
|
||||
<title>if,elseif,else</title>
|
||||
<para>
|
||||
<emphasis>{if}</emphasis> statements in Smarty have much the same flexibility as PHP if
|
||||
statements, with a few added features for the template engine.
|
||||
Every <emphasis>{if}</emphasis> must be paired with an
|
||||
<emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and
|
||||
<emphasis>{elseif}</emphasis> are also permitted. All PHP conditionals
|
||||
are recognized, such as <emphasis>||</emphasis>, <emphasis>or</emphasis>,
|
||||
<emphasis>&&</emphasis>, <emphasis>and</emphasis>, etc.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following is a list of recognized qualifiers, which must be
|
||||
separated from surrounding elements by spaces. Note that items listed
|
||||
in [brackets] are optional. PHP equivalents are shown where applicable.
|
||||
</para>
|
||||
<para>
|
||||
The following is a list of recognized qualifiers, which must be
|
||||
separated from surrounding elements by spaces. Note that items listed
|
||||
in [brackets] are optional. PHP equivalents are shown where applicable.
|
||||
</para>
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="4">
|
||||
<colspec colname="qualifier" align="center" />
|
||||
<colspec colname="alternates" align="center" />
|
||||
<colspec colname="meaning" />
|
||||
<colspec colname="example" />
|
||||
<colspec colname="php" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Qualifier</entry>
|
||||
<entry>Alternates</entry>
|
||||
<entry>Syntax Example</entry>
|
||||
<entry>Meaning</entry>
|
||||
<entry>PHP Equivalent</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>==</entry>
|
||||
<entry>eq</entry>
|
||||
<entry>$a eq $b</entry>
|
||||
<entry>equals</entry>
|
||||
<entry>==</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!=</entry>
|
||||
<entry>ne, neq</entry>
|
||||
<entry>$a neq $b</entry>
|
||||
<entry>not equals</entry>
|
||||
<entry>!=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>></entry>
|
||||
<entry>gt</entry>
|
||||
<entry>$a gt $b</entry>
|
||||
<entry>greater than</entry>
|
||||
<entry>></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><</entry>
|
||||
<entry>lt</entry>
|
||||
<entry>$a lt $b</entry>
|
||||
<entry>less than</entry>
|
||||
<entry><</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>>=</entry>
|
||||
<entry>gte, ge</entry>
|
||||
<entry>$a ge $b</entry>
|
||||
<entry>greater than or equal</entry>
|
||||
<entry>>=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><=</entry>
|
||||
<entry>lte, le</entry>
|
||||
<entry>$a le $b</entry>
|
||||
<entry>less than or equal</entry>
|
||||
<entry><=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>===</entry>
|
||||
<entry></entry>
|
||||
<entry>$a === 0</entry>
|
||||
<entry>check for identity</entry>
|
||||
<entry>===</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!</entry>
|
||||
<entry>not</entry>
|
||||
<entry>not $a</entry>
|
||||
<entry>negation (unary)</entry>
|
||||
<entry>!</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>%</entry>
|
||||
<entry>mod</entry>
|
||||
<entry>$a mod $b</entry>
|
||||
<entry>modulous</entry>
|
||||
<entry>%</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] div by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not div by 4</entry>
|
||||
<entry>divisible by</entry>
|
||||
<entry>$a % $b == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] even</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not even</entry>
|
||||
<entry>[not] an even number (unary)</entry>
|
||||
<entry>$a % 2 == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] even by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not even by $b</entry>
|
||||
<entry>grouping level [not] even</entry>
|
||||
<entry>($a / $b) % 2 == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] odd</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not odd</entry>
|
||||
<entry>[not] an odd number (unary)</entry>
|
||||
<entry>$a % 2 != 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] odd by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not odd by $b</entry>
|
||||
<entry>[not] an odd grouping</entry>
|
||||
<entry>($a / $b) % 2 != 0</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<example>
|
||||
<title>if statements</title>
|
||||
<programlisting>
|
||||
{if $name eq "Fred"}
|
||||
Welcome Sir.
|
||||
{elseif $name eq "Wilma"}
|
||||
Welcome Ma'am.
|
||||
{else}
|
||||
Welcome, whatever you are.
|
||||
{/if}
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="4">
|
||||
<colspec colname="qualifier" align="center" />
|
||||
<colspec colname="alternates" align="center" />
|
||||
<colspec colname="meaning" />
|
||||
<colspec colname="example" />
|
||||
<colspec colname="php" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Qualifier</entry>
|
||||
<entry>Alternates</entry>
|
||||
<entry>Syntax Example</entry>
|
||||
<entry>Meaning</entry>
|
||||
<entry>PHP Equivalent</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>==</entry>
|
||||
<entry>eq</entry>
|
||||
<entry>$a eq $b</entry>
|
||||
<entry>equals</entry>
|
||||
<entry>==</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!=</entry>
|
||||
<entry>ne, neq</entry>
|
||||
<entry>$a neq $b</entry>
|
||||
<entry>not equals</entry>
|
||||
<entry>!=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>></entry>
|
||||
<entry>gt</entry>
|
||||
<entry>$a gt $b</entry>
|
||||
<entry>greater than</entry>
|
||||
<entry>></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><</entry>
|
||||
<entry>lt</entry>
|
||||
<entry>$a lt $b</entry>
|
||||
<entry>less than</entry>
|
||||
<entry><</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>>=</entry>
|
||||
<entry>gte, ge</entry>
|
||||
<entry>$a ge $b</entry>
|
||||
<entry>greater than or equal</entry>
|
||||
<entry>>=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><=</entry>
|
||||
<entry>lte, le</entry>
|
||||
<entry>$a le $b</entry>
|
||||
<entry>less than or equal</entry>
|
||||
<entry><=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>===</entry>
|
||||
<entry></entry>
|
||||
<entry>$a === 0</entry>
|
||||
<entry>check for identity</entry>
|
||||
<entry>===</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!</entry>
|
||||
<entry>not</entry>
|
||||
<entry>not $a</entry>
|
||||
<entry>negation (unary)</entry>
|
||||
<entry>!</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>%</entry>
|
||||
<entry>mod</entry>
|
||||
<entry>$a mod $b</entry>
|
||||
<entry>modulous</entry>
|
||||
<entry>%</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] div by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not div by 4</entry>
|
||||
<entry>divisible by</entry>
|
||||
<entry>$a % $b == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] even</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not even</entry>
|
||||
<entry>[not] an even number (unary)</entry>
|
||||
<entry>$a % 2 == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] even by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not even by $b</entry>
|
||||
<entry>grouping level [not] even</entry>
|
||||
<entry>($a / $b) % 2 == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] odd</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not odd</entry>
|
||||
<entry>[not] an odd number (unary)</entry>
|
||||
<entry>$a % 2 != 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] odd by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not odd by $b</entry>
|
||||
<entry>[not] an odd grouping</entry>
|
||||
<entry>($a / $b) % 2 != 0</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<example>
|
||||
<title>if statements</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{if $name eq "Fred"}
|
||||
Welcome Sir.
|
||||
{elseif $name eq "Wilma"}
|
||||
Welcome Ma'am.
|
||||
{else}
|
||||
Welcome, whatever you are.
|
||||
{/if}
|
||||
|
||||
{* an example with "or" logic *}
|
||||
{if $name eq "Fred" or $name eq "Wilma"}
|
||||
...
|
||||
{/if}
|
||||
{* an example with "or" logic *}
|
||||
{if $name eq "Fred" or $name eq "Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* same as above *}
|
||||
{if $name == "Fred" || $name == "Wilma"}
|
||||
...
|
||||
{/if}
|
||||
{* same as above *}
|
||||
{if $name == "Fred" || $name == "Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* the following syntax will NOT work, conditional qualifiers
|
||||
{* the following syntax will NOT work, conditional qualifiers
|
||||
must be separated from surrounding elements by spaces *}
|
||||
{if $name=="Fred" || $name=="Wilma"}
|
||||
...
|
||||
{/if}
|
||||
{if $name=="Fred" || $name=="Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
|
||||
{* parenthesis are allowed *}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
...
|
||||
{/if}
|
||||
{* parenthesis are allowed *}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* you can also embed php function calls *}
|
||||
{if count($var) gt 0}
|
||||
...
|
||||
{/if}
|
||||
{* you can also embed php function calls *}
|
||||
{if count($var) gt 0}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* test if values are even or odd *}
|
||||
{if $var is even}
|
||||
...
|
||||
{/if}
|
||||
{if $var is odd}
|
||||
...
|
||||
{/if}
|
||||
{if $var is not odd}
|
||||
...
|
||||
{/if}
|
||||
{* test if values are even or odd *}
|
||||
{if $var is even}
|
||||
...
|
||||
{/if}
|
||||
{if $var is odd}
|
||||
...
|
||||
{/if}
|
||||
{if $var is not odd}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* test if var is divisible by 4 *}
|
||||
{if $var is div by 4}
|
||||
...
|
||||
{/if}
|
||||
{* test if var is divisible by 4 *}
|
||||
{if $var is div by 4}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* test if var is even, grouped by two. i.e.,
|
||||
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
|
||||
{if $var is even by 2}
|
||||
...
|
||||
{/if}
|
||||
{* test if var is even, grouped by two. i.e.,
|
||||
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
|
||||
{if $var is even by 2}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
|
||||
{if $var is even by 3}
|
||||
...
|
||||
{/if}</programlisting>
|
||||
</example>
|
||||
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
|
||||
{if $var is even by 3}
|
||||
...
|
||||
{/if}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
@@ -1,141 +1,145 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.include.php">
|
||||
<title>include_php</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the php file to include</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>once</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>true</emphasis></entry>
|
||||
<entry>whether or not to include the php file more than
|
||||
once if included multiple times</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that the output of
|
||||
include_php will be assigned to</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
include_php is pretty much deprecated from Smarty, you can
|
||||
accomplish the same functionality via a custom template function.
|
||||
The only reason to use include_php is if you really have a need to
|
||||
quarantine the php function away from the plugin directory or your
|
||||
application code. See the <link
|
||||
linkend="tips.componentized.templates">componentized template
|
||||
example</link> for details.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
include_php tags are used to include a php script in your template.
|
||||
If security is enabled, then the php script must be located in the
|
||||
$trusted_dir path. The include_php tag must have the attribute
|
||||
"file", which contains the path to the included php file, either
|
||||
relative to $trusted_dir, or an absolute path.
|
||||
</para>
|
||||
<para>
|
||||
include_php is a nice way to handle componentized templates, and
|
||||
keep PHP code separate from the template files. Lets say you have a
|
||||
template that shows your site navigation, which is pulled
|
||||
dynamically from a database. You can keep your PHP logic that grabs
|
||||
database content in a separate directory, and include it at the top
|
||||
of the template. Now you can include this template anywhere without
|
||||
worrying if the database information was assigned by the application
|
||||
before hand.
|
||||
</para>
|
||||
<para>
|
||||
By default, php files are only included once even if called
|
||||
multiple times in the template. You can specify that it should be
|
||||
included every time with the <emphasis>once</emphasis> attribute.
|
||||
Setting once to false will include the php script each time it is
|
||||
included in the template.
|
||||
</para>
|
||||
<para>
|
||||
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
||||
which will specify a template variable name that the output of
|
||||
<emphasis>include_php</emphasis> will be assigned to instead of
|
||||
displayed.
|
||||
</para>
|
||||
<para>
|
||||
The smarty object is available as $this within the PHP script that you
|
||||
include.
|
||||
</para>
|
||||
<example>
|
||||
<title>function include_php</title>
|
||||
<programlisting>
|
||||
load_nav.php
|
||||
-------------
|
||||
<sect1 id="language.function.include.php">
|
||||
<title>include_php</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the php file to include</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>once</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>true</emphasis></entry>
|
||||
<entry>whether or not to include the php file more than
|
||||
once if included multiple times</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that the output of
|
||||
include_php will be assigned to</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
include_php is pretty much deprecated from Smarty, you can
|
||||
accomplish the same functionality via a custom template function.
|
||||
The only reason to use include_php is if you really have a need to
|
||||
quarantine the php function away from the plugin directory or your
|
||||
application code. See the <link
|
||||
linkend="tips.componentized.templates">componentized template
|
||||
example</link> for details.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
include_php tags are used to include a php script in your template.
|
||||
If security is enabled, then the php script must be located in the
|
||||
$trusted_dir path. The include_php tag must have the attribute
|
||||
"file", which contains the path to the included php file, either
|
||||
relative to $trusted_dir, or an absolute path.
|
||||
</para>
|
||||
<para>
|
||||
include_php is a nice way to handle componentized templates, and
|
||||
keep PHP code separate from the template files. Lets say you have a
|
||||
template that shows your site navigation, which is pulled
|
||||
dynamically from a database. You can keep your PHP logic that grabs
|
||||
database content in a separate directory, and include it at the top
|
||||
of the template. Now you can include this template anywhere without
|
||||
worrying if the database information was assigned by the application
|
||||
before hand.
|
||||
</para>
|
||||
<para>
|
||||
By default, php files are only included once even if called
|
||||
multiple times in the template. You can specify that it should be
|
||||
included every time with the <emphasis>once</emphasis> attribute.
|
||||
Setting once to false will include the php script each time it is
|
||||
included in the template.
|
||||
</para>
|
||||
<para>
|
||||
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
||||
which will specify a template variable name that the output of
|
||||
<emphasis>include_php</emphasis> will be assigned to instead of
|
||||
displayed.
|
||||
</para>
|
||||
<para>
|
||||
The smarty object is available as $this within the PHP script that you
|
||||
include.
|
||||
</para>
|
||||
<example>
|
||||
<title>function include_php</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
load_nav.php
|
||||
-------------
|
||||
|
||||
<?php
|
||||
<?php
|
||||
|
||||
// load in variables from a mysql db and assign them to the template
|
||||
require_once("MySQL.class.php");
|
||||
$sql = new MySQL;
|
||||
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
|
||||
$this->assign('sections',$sql->record);
|
||||
// load in variables from a mysql db and assign them to the template
|
||||
require_once("MySQL.class.php");
|
||||
$sql = new MySQL;
|
||||
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
|
||||
$this->assign('sections',$sql->record);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
index.tpl
|
||||
---------
|
||||
|
||||
{* absolute path, or relative to $trusted_dir *}
|
||||
{include_php file="/path/to/load_nav.php"}
|
||||
|
||||
{foreach item="curr_section" from=$sections}
|
||||
<a href="{$curr_section.url}">{$curr_section.name}</a><br>
|
||||
{/foreach}</programlisting>
|
||||
</example>
|
||||
?>
|
||||
]]>
|
||||
</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}
|
||||
<a href="{$curr_section.url}">{$curr_section.name}</a><br />
|
||||
{/foreach}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,101 +1,110 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.eval">
|
||||
<title>eval</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>var</entry>
|
||||
<entry>mixed</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>variable (or string) to evaluate</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>the template variable the output will be assigned
|
||||
to</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the special "assign" attribute, the output of the
|
||||
eval function will be assigned to this template variable instead of
|
||||
being output to the template.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
Evaluated variables are treated the same as templates. They follow
|
||||
the same escapement and security features just as if they were
|
||||
templates.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
Evaluated variables are compiled on every invocation, the compiled
|
||||
versions are not saved! However if you have caching enabled, the
|
||||
output will be cached with the rest of the template.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>eval</title>
|
||||
<programlisting>
|
||||
setup.conf
|
||||
----------
|
||||
<sect1 id="language.function.eval">
|
||||
<title>eval</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>var</entry>
|
||||
<entry>mixed</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>variable (or string) to evaluate</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>the template variable the output will be assigned
|
||||
to</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the special "assign" attribute, the output of the
|
||||
eval function will be assigned to this template variable instead of
|
||||
being output to the template.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
Evaluated variables are treated the same as templates. They follow
|
||||
the same escapement and security features just as if they were
|
||||
templates.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
Evaluated variables are compiled on every invocation, the compiled
|
||||
versions are not saved! However if you have caching enabled, the
|
||||
output will be cached with the rest of the template.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>eval</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
setup.conf
|
||||
----------
|
||||
|
||||
emphstart = <b>
|
||||
emphend = </b>
|
||||
title = Welcome to {$company}'s home page!
|
||||
ErrorCity = You must supply a {#emphstart#}city{#emphend#}.
|
||||
ErrorState = You must supply a {#emphstart#}state{#emphend#}.
|
||||
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#}.
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Where index.tpl is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="setup.conf"}
|
||||
|
||||
{eval var=$foo}
|
||||
{eval var=#title#}
|
||||
{eval var=#ErrorCity#}
|
||||
{eval var=#ErrorState# assign="state_error"}
|
||||
{$state_error}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The above example will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
index.tpl
|
||||
---------
|
||||
This is the contents of foo.
|
||||
Welcome to Foobar Pub & Grill's home page!
|
||||
You must supply a <strong>city</strong>.
|
||||
You must supply a <strong>state</strong>.
|
||||
|
||||
{config_load file="setup.conf"}
|
||||
|
||||
{eval var=$foo}
|
||||
{eval var=#title#}
|
||||
{eval var=#ErrorCity#}
|
||||
{eval var=#ErrorState# assign="state_error"}
|
||||
{$state_error}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
This is the contents of foo.
|
||||
Welcome to Foobar Pub & Grill's home page!
|
||||
You must supply a <b>city</b>.
|
||||
You must supply a <b>state</b>.
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -119,10 +119,10 @@ $smarty->display('index.tpl');
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_checkboxes', array(
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown'));
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
|
@@ -1,131 +1,131 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.image">
|
||||
<title>html_image</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>name/path to image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>height</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>actual image height</emphasis></entry>
|
||||
<entry>height to display image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>width</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>actual image width</emphasis></entry>
|
||||
<entry>width to display image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>basedir</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>web server doc root</emphasis></entry>
|
||||
<entry>directory to base relative paths from</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>alt</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>""</emphasis></entry>
|
||||
<entry>alternative description of the image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>href</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>href value to link the image to</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
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
|
||||
path to the image must be within a secure directory.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>href</parameter> 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.
|
||||
</para>
|
||||
<para>
|
||||
All parameters that are not in the list above are printed as
|
||||
name/value-pairs inside the created <img>-tag.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
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
|
||||
image tags static for optimal performance.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>html_image example</title>
|
||||
<programlisting role="php">
|
||||
<sect1 id="language.function.html.image">
|
||||
<title>html_image</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>name/path to image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>height</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>actual image height</emphasis></entry>
|
||||
<entry>height to display image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>width</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>actual image width</emphasis></entry>
|
||||
<entry>width to display image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>basedir</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>web server doc root</emphasis></entry>
|
||||
<entry>directory to base relative paths from</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>alt</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>""</emphasis></entry>
|
||||
<entry>alternative description of the image</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>href</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>href value to link the image to</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
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
|
||||
path to the image must be within a secure directory.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>href</parameter> 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.
|
||||
</para>
|
||||
<para>
|
||||
All parameters that are not in the list above are printed as
|
||||
name/value-pairs inside the created <img>-tag.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
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
|
||||
image tags static for optimal performance.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>html_image example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->display('index.tpl');
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where index.tpl is:
|
||||
</para>
|
||||
<programlisting>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where index.tpl is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_image file="pumpkin.jpg"}
|
||||
{html_image file="/path/from/docroot/pumpkin.jpg"}
|
||||
{html_image file="../path/relative/to/currdir/pumpkin.jpg"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
a possible output would be:
|
||||
</para>
|
||||
<screen>
|
||||
</programlisting>
|
||||
<para>
|
||||
a possible output would be:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<img src="pumpkin.jpg" alt="" width="44" height="68" />
|
||||
<img src="/path/from/docroot/pumpkin.jpg" alt="" width="44" height="68" />
|
||||
<img src="../path/relative/to/currdir/pumpkin.jpg" alt="" width="44" height="68" />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.options">
|
||||
<title>html_options</title>
|
||||
<title>html_options</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
@@ -57,99 +57,119 @@
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_options is a custom function that creates html 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.
|
||||
</para>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
If the optional <emphasis>name</emphasis> attribute is given, the
|
||||
<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 <select>-tag. They are ignored if
|
||||
the optional <emphasis>name</emphasis> is not given.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_options</title>
|
||||
<programlisting>
|
||||
EXAMPLE 1
|
||||
---------
|
||||
<para>
|
||||
html_options is a custom function that creates html 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.
|
||||
</para>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
If the optional <emphasis>name</emphasis> attribute is given, the
|
||||
<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 <select>-tag. They are ignored if
|
||||
the optional <emphasis>name</emphasis> is not given.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_options : Example 1</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
index.php:
|
||||
----------
|
||||
|
||||
index.php:
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Where index.tpl is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
<select name=customer_id>
|
||||
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Example 2
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
index.php:
|
||||
----------
|
||||
|
||||
index.tpl:
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$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[
|
||||
|
||||
<select name=customer_id>
|
||||
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
|
||||
</select>
|
||||
<select name=customer_id>
|
||||
{html_options options=$cust_options selected=$customer_id}
|
||||
</select>
|
||||
|
||||
EXAMPLE 2
|
||||
---------
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Both examples will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
index.php:
|
||||
<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>
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$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');
|
||||
|
||||
index.tpl:
|
||||
|
||||
<select name=customer_id>
|
||||
{html_options options=$cust_options selected=$customer_id}
|
||||
</select>
|
||||
|
||||
|
||||
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></programlisting>
|
||||
</example>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
|
@@ -1,125 +1,145 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.radios">
|
||||
<title>html_radios</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>radio</emphasis></entry>
|
||||
<entry>name of radio list</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>values</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using options attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of values for radio buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>output</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using options attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of output for radio buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>selected</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>the selected radio element</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>options</entry>
|
||||
<entry>associative array</entry>
|
||||
<entry>Yes, unless using values and output</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an associative array of values and output</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>separator</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>string of text to separate each radio item</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
All parameters that are not in the list above are printed as
|
||||
name/value-pairs inside each of the created <input>-tags.
|
||||
</para>
|
||||
<sect1 id="language.function.html.radios">
|
||||
<title>html_radios</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>radio</emphasis></entry>
|
||||
<entry>name of radio list</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>values</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using options attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of values for radio buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>output</entry>
|
||||
<entry>array</entry>
|
||||
<entry>Yes, unless using options attribute</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an array of output for radio buttons</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>selected</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>the selected radio element</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>options</entry>
|
||||
<entry>associative array</entry>
|
||||
<entry>Yes, unless using values and output</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>an associative array of values and output</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>separator</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry>string of text to separate each radio item</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
All parameters that are not in the list above are printed as
|
||||
name/value-pairs inside each of the created <input>-tags.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>html_radios</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
<example>
|
||||
<title>html_radios : Example 1</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
index.php:
|
||||
----------
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="<br />"}
|
||||
|
||||
|
||||
index.php:
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$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');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
|
||||
|
||||
|
||||
OUTPUT: (both examples)
|
||||
|
||||
<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 /></programlisting>
|
||||
</example>
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Charlie Brown'));
|
||||
$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->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
|
||||
|
@@ -39,8 +39,8 @@
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>none</emphasis></entry>
|
||||
<entry>How to encode the e-mail. Can be one of <literal>none</literal>,
|
||||
<literal>hex</literal>, <literal>javascript</literal>
|
||||
or <literal>javascript_charcode</literal>.</entry>
|
||||
<literal>hex</literal>, <literal>javascript</literal>
|
||||
or <literal>javascript_charcode</literal>.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>cc</entry>
|
||||
@@ -56,7 +56,7 @@
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>e-mail addresses to blind carbon copy.
|
||||
Separate entries by a comma.</entry>
|
||||
Separate entries by a comma.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>subject</entry>
|
||||
@@ -85,72 +85,78 @@
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>any extra information you want passed to the link, such
|
||||
as style sheet classes</entry>
|
||||
as style sheet classes</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
javascript is probably the most thorough form of
|
||||
encoding, although you can use hex encoding too.
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
javascript is probably the most thorough form of
|
||||
encoding, although you can use hex encoding too.
|
||||
</para>
|
||||
</note>
|
||||
</note>
|
||||
<example>
|
||||
<title>mailto</title>
|
||||
<programlisting>
|
||||
{mailto address="me@example.com"}
|
||||
{mailto address="me@example.com" text="send me some mail"}
|
||||
{mailto address="me@example.com" encode="javascript"}
|
||||
{mailto address="me@example.com" encode="hex"}
|
||||
{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"}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
<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'))</script>
|
||||
<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" >me@domain.com</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))}
|
||||
//-->
|
||||
</script></programlisting>
|
||||
</example>
|
||||
<![CDATA[
|
||||
{mailto address="me@example.com"}
|
||||
{mailto address="me@example.com" text="send me some mail"}
|
||||
{mailto address="me@example.com" encode="javascript"}
|
||||
{mailto address="me@example.com" encode="hex"}
|
||||
{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"}
|
||||
]]>
|
||||
</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'))</script>
|
||||
<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" >me@domain.com</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))}
|
||||
//-->
|
||||
</script>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
|
Reference in New Issue
Block a user