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