Moved description to top of page and some tweaks

This commit is contained in:
pete_morgan
2005-09-13 18:41:44 +00:00
parent 0cc11afe51
commit c666426130
10 changed files with 168 additions and 103 deletions

View File

@@ -2,6 +2,20 @@
<!-- $Revision$ -->
<sect1 id="language.function.capture">
<title>{capture}</title>
<para>
{capture} is used to collect the output of the template into a
variable instead of displaying it. Any content between {capture
name="foo"} and {/capture} is collected into the variable specified
in the name attribute. The captured content can be used in the
template from the special variable <link
linkend="language.variables.smarty.capture">$smarty.capture.foo</link>
where "foo" is the value passed in the name attribute. If you do not
supply a name attribute, then "default" will be used as the name. All {capture}
commands must be paired with {/capture}. You can nest capture commands.
</para>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -36,17 +50,7 @@
</tbody>
</tgroup>
</informaltable>
<para>
{capture} is used to collect the output of the template into a
variable instead of displaying it. Any content between {capture
name="foo"} and {/capture} is collected into the variable specified
in the name attribute. The captured content can be used in the
template from the special variable <link
linkend="language.variables.smarty.capture">$smarty.capture.foo</link>
where "foo" is the value passed in the name attribute. If you do not
supply a name attribute, then "default" will be used. All {capture}
commands must be paired with {/capture}. You can nest capture commands.
</para>
<note>
<title>Technical Note</title>
<para>
@@ -61,7 +65,7 @@
linkend="language.function.insert">{insert}</link>
output. If you have
<link linkend="caching">caching</link>
turned on and you have
enabled and you have
<link linkend="language.function.insert">{insert}</link>
commands that you expect to run
within cached content, do not capture this content.
@@ -74,7 +78,7 @@
<![CDATA[
{* we don't want to print a table row unless content is displayed *}
{capture name=banner}
{include file="get_banner.tpl"}
{include file='get_banner.tpl'}
{/capture}
{if $smarty.capture.banner ne ''}
@@ -89,6 +93,24 @@
]]>
</programlisting>
</example>
<example>
<title>capturing content to a variable</title>
<programlisting>
<![CDATA[
{* we don't want to print a table row unless content is displayed *}
{capture name=banner assign=foo}
.... some content ....
{/capture}
{if $condition}
{$foo}
{/if}
]]>
</programlisting>
</example>
</para>
<para>
See also

View File

@@ -2,6 +2,12 @@
<!-- $Revision$ -->
<sect1 id="language.function.config.load">
<title>{config_load}</title>
<para>
{config_load} is used for loading config
<link linkend="language.config.variables">#variables#</link> from a
<link linkend="config.files">configuration file</link> into the template.
</para>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -63,11 +69,7 @@
</tbody>
</tgroup>
</informaltable>
<para>
{config_load} is used for loading config
<link linkend="language.config.variables">#variables#</link> from a
<link linkend="config.files">configuration file</link> into the template.
</para>
<example>
<title>{config_load}</title>
<para>
@@ -146,6 +148,10 @@ pageTitle = "Customer Info"
</programlisting>
</example>
<para>
See <link linkend="variable.config.overwrite">$config_overwrite</link> for arrays of config variables
</para>
<para>
See also <link linkend="config.files">Config files</link>,
<link linkend="language.config.variables">Config variables</link>,

View File

@@ -2,6 +2,28 @@
<!-- $Revision$ -->
<sect1 id="language.function.foreach">
<title>{foreach},{foreachelse}</title>
<para>
<emphasis>{foreach}</emphasis> loops are an alternative to
<link
linkend="language.function.section"><emphasis>{section}</emphasis></link>
loops. <emphasis>{foreach}</emphasis> is used to loop over a
<emphasis role="bold">single associative array</emphasis>. The syntax for
<emphasis>{foreach}</emphasis> is much easier than
<emphasis>{section}</emphasis>, but as a tradeoff it
<emphasis role="bold">can only be used
for a single array</emphasis>. <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>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -52,27 +74,7 @@
</tbody>
</tgroup>
</informaltable>
<para>
<emphasis>{foreach}</emphasis> loops are an alternative to
<link
linkend="language.function.section"><emphasis>{section}</emphasis></link>
loops. <emphasis>{foreach}</emphasis> is used to loop over a
<emphasis role="bold">single associative array</emphasis>. The syntax for
<emphasis>{foreach}</emphasis> is much easier than
<emphasis>{section}</emphasis>, but as a tradeoff it
<emphasis role="bold">can only be used
for a single array</emphasis>. <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} - item</title>
<programlisting role="php">

View File

@@ -209,10 +209,17 @@
...
{/if}
{* ------- if with php functions ------- *}
{* check for array. *}
{if is_array($foo) }
...do something
.....
{/if}
{* check for array. *}
{if isset($foo) }
.....
{/if}
]]>
</programlisting>
</example>

View File

@@ -2,6 +2,21 @@
<!-- $Revision$ -->
<sect1 id="language.function.include.php">
<title>{include_php}</title>
<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
<link linkend="variable.plugins.dir">plugins</link>
directory or your
application code. See the <link
linkend="tips.componentized.templates">componentized template
example</link> for details.
</para>
</note>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -45,20 +60,7 @@
</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
<link linkend="variable.plugins.dir">plugins</link>
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 <link linkend="variable.security">security is enabled</link>,

View File

@@ -2,6 +2,19 @@
<!-- $Revision$ -->
<sect1 id="language.function.include">
<title>{include}</title>
<para>
{include} tags are used for including other templates in the current
template. Any variables available in the current template are also
available within the included template. The {include} tag must have
the attribute "file", which contains the template resource path.
</para>
<para>
You can optionally pass the <emphasis>'assign'</emphasis> attribute,
which will specify a template variable name that the output of
{include} will be assigned to instead of
displayed.
</para>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -44,18 +57,7 @@
</tbody>
</tgroup>
</informaltable>
<para>
{include} tags are used for including other templates in the current
template. Any variables available in the current template are also
available within the included template. The {include} tag must have
the attribute "file", which contains the template resource path.
</para>
<para>
You can optionally pass the <emphasis>'assign'</emphasis> attribute,
which will specify a template variable name that the output of
{include} will be assigned to instead of
displayed.
</para>
<example>
<title>function {include}</title>
<programlisting>
@@ -65,12 +67,12 @@
<title>{$title}</title>
</head>
<body>
{include file="page_header.tpl"}
{include file='page_header.tpl'}
{* body of template goes here *}
{include file="/$tpl_name.tpl"} <-- will replace $tpl_name with value
{include file="$tpl_name.tpl"} <-- will replace $tpl_name with value
{include file="page_footer.tpl"}
{include file='page_footer.tpl'}
</body>
</html>
]]>
@@ -87,11 +89,11 @@
<title>{include} passing variables</title>
<programlisting>
<![CDATA[
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
{include file='header.tpl' title='Main Menu' table_bgcolor='#c0c0c0'}
{* body of template goes here *}
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
{include file='footer.tpl' logo='http://my.example.com/logo.gif'}
]]>
</programlisting>
<para>where header.tpl could be</para>
@@ -115,13 +117,13 @@
<programlisting>
<![CDATA[
<body>
{include file="nav.tpl" assign="navbar"}
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
{include file='nav.tpl' assign=navbar}
{include file='header.tpl' title='Main Menu' table_bgcolor='#effeef'}
{$navbar}
{* body of template goes here *}
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
{include file='footer.tpl' logo='http://my.example.com/logo.gif'}
{$navbar}
</body>
]]>
@@ -140,16 +142,22 @@
<programlisting>
<![CDATA[
{* absolute filepath *}
{include file="/usr/local/include/templates/header.tpl"}
{include file='/usr/local/include/templates/header.tpl'}
{* absolute filepath (same thing) *}
{include file="file:/usr/local/include/templates/header.tpl"}
{include file='file:/usr/local/include/templates/header.tpl'}
{* windows absolute filepath (MUST use "file:" prefix) *}
{include file="file:C:/www/pub/templates/header.tpl"}
{include file='file:C:/www/pub/templates/header.tpl'}
{* include from template resource named "db" *}
{include file="db:header.tpl"}
{include file='db:header.tpl'}
{* include a $variable template - eg $module = 'contacts' *}
{include file="$module.tpl"}
{* wont work as its single quotes ie no variable substitution *}
{include file='$module.tpl'}
]]>
</programlisting>
</example>

View File

@@ -2,6 +2,14 @@
<!-- $Revision$ -->
<sect1 id="language.function.insert">
<title>{insert}</title>
<para>
{insert} tags work much like <link
linkend="language.function.include">{include}</link> tags,
except that {insert} tags are NOT cached when you have
template <link linkend="caching">caching</link> enabled. They
will be executed on every invocation of the template.
</para>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -52,13 +60,7 @@
</tbody>
</tgroup>
</informaltable>
<para>
Insert tags work much like <link
linkend="language.function.include">{include}</link> tags,
except that {insert} tags are not cached when you have
template <link linkend="caching">caching</link> enabled. They
will be executed on every invocation of the template.
</para>
<para>
Let's say you have a template with a banner slot at the top of
the page. The banner can contain any mixture of HTML, images,

View File

@@ -15,7 +15,7 @@
{php}
// including a php script directly
// from the template.
include("/path/to/display_weather.php");
include('/path/to/display_weather.php');
{/php}
]]>
</programlisting>
@@ -29,6 +29,20 @@
</para>
</note>
<example>
<title>{php} tags with global</title>
<programlisting role="php">
<![CDATA[
{php}
global $foo, $bar;
if($foo == $bar){
// do something
}
{/php}
]]>
</programlisting>
</example>
<para>
See also
<link linkend="variable.php.handling">$php_handling</link>,

View File

@@ -2,6 +2,23 @@
<!-- $Revision$ -->
<sect1 id="language.function.section">
<title>{section},{sectionelse}</title>
<para>
Template sections are used for looping over
<emphasis role="bold">arrays of data</emphasis>
(just like <link linkend="language.function.foreach">{foreach}</link>). All
<emphasis>{section}</emphasis> tags must be paired with
<emphasis>{/section}</emphasis> tags. Required parameters are
<emphasis>name</emphasis> and <emphasis>loop</emphasis>. The name
of the {section} can be anything you like, made up of letters,
numbers and underscores. Sections can be nested, and the nested
section names must be unique from each other. The loop variable
(usually an array of values) determines the number of times the
section will loop. When printing a variable within a section, the
section name must be given next to variable name within brackets
[]. <emphasis>{sectionelse}</emphasis> is
executed when there are no values in the loop variable.
</para>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
@@ -74,22 +91,7 @@
</tbody>
</tgroup>
</informaltable>
<para>
Template sections are used for looping over
<emphasis role="bold">arrays of data</emphasis>
(just like <link linkend="language.function.foreach">{foreach}</link>). All
<emphasis>{section}</emphasis> tags must be paired with
<emphasis>{/section}</emphasis> tags. Required parameters are
<emphasis>name</emphasis> and <emphasis>loop</emphasis>. The name
of the {section} can be anything you like, made up of letters,
numbers and underscores. Sections can be nested, and the nested
section names must be unique from each other. The loop variable
(usually an array of values) determines the number of times the
section will loop. When printing a variable within a section, the
section name must be given next to variable name within brackets
[]. <emphasis>{sectionelse}</emphasis> is
executed when there are no values in the loop variable.
</para>
<example>
<title>{section}</title>

View File

@@ -47,7 +47,7 @@
</para>
<screen>
<![CDATA[
<table border=0><tr><td><A HREF="http://w... snipped...</td></tr></table>
<table border='0'><tr><td><a href="http://. snipped...</a></td></tr></table>
]]>
</screen>
</example>