A lot of formatting, tagging and tidy up. Some consistency at last

This commit is contained in:
pete_morgan
2006-09-25 21:47:31 +00:00
parent cffb3cf957
commit 345a0d56fa
12 changed files with 259 additions and 236 deletions

View File

@@ -2,23 +2,24 @@
<!-- $Revision$ --> <!-- $Revision$ -->
<sect1 id="language.function.capture"> <sect1 id="language.function.capture">
<title>{capture}</title> <title>{capture}</title>
<para> <para>
{capture} is used to collect the output of the template between the tags into a <varname>{capture}</varname> is used to collect the output of the template between the
variable instead of displaying it. Any content between {capture tags into a variable instead of displaying it. Any content between
name='foo'} and {/capture} is collected into the variable specified <varname>{capture name='foo'}</varname> and <varname>{/capture}</varname> is collected
in the name attribute. into the variable specified in the <parameter>name</parameter> attribute.
</para> </para>
<para>The captured content can be used in the <para>The captured content can be used in the
template from the variable <link template from the variable <link
linkend="language.variables.smarty.capture">$smarty.capture.foo</link> linkend="language.variables.smarty.capture"><parameter>$smarty.capture.foo</parameter></link>
where "foo" is the value passed in the name attribute. If you do not where <quote>foo</quote> is the value passed in the <parameter>name</parameter> attribute.
supply a name attribute, then "default" will be used as the name If you do not supply the <parameter>name</parameter> attribute, then <quote>default</quote> will
ie $smarty.capture.default </para> be used as the name ie <parameter>$smarty.capture.default</parameter>.
<para>{capture}'s can be nested. </para>
</para> <para><varname>{capture}'s</varname> can be nested.
</para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -58,11 +59,11 @@
<caution> <caution>
<para> <para>
Be careful when capturing <link Be careful when capturing <link
linkend="language.function.insert">{insert}</link> linkend="language.function.insert"><varname>{insert}</varname></link>
output. If you have output. If you have
<link linkend="caching">$caching</link> <link linkend="caching"><parameter>$caching</parameter></link>
enabled and you have enabled and you have
<link linkend="language.function.insert">{insert}</link> <link linkend="language.function.insert"><varname>{insert}</varname></link>
commands that you expect to run commands that you expect to run
within cached content, do not capture this content. within cached content, do not capture this content.
</para> </para>
@@ -83,11 +84,11 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<example> <example>
<title>{capture} into a template variable</title> <title>{capture} into a template variable</title>
<para>This example also demonstrates the <para>This example also demonstrates the
<link linkend="language.function.popup">{popup}</link> <link linkend="language.function.popup"><varname>{popup}</varname></link>
function</para> function</para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -99,17 +100,17 @@ Your ip is {$smarty.server.REMOTE_ADDR}.
]]> ]]>
</programlisting> </programlisting>
</example> </example>
</para> </para>
<para> <para>
See also See also
<link <link
linkend="language.variables.smarty.capture">$smarty.capture</link>, linkend="language.variables.smarty.capture"><parameter>$smarty.capture</parameter></link>,
<link linkend="language.function.eval">{eval}</link>, <link linkend="language.function.eval"><varname>{eval}</varname></link>,
<link linkend="language.function.fetch">{fetch}</link>, <link linkend="language.function.fetch"><varname>{fetch}</varname></link>,
<link linkend="api.fetch">fetch()</link> <link linkend="api.fetch"><varname>fetch()</varname></link>
and <link linkend="language.function.assign">{assign}</link>. and <link linkend="language.function.assign"><varname>{assign}</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -3,11 +3,11 @@
<sect1 id="language.function.config.load"> <sect1 id="language.function.config.load">
<title>{config_load}</title> <title>{config_load}</title>
<para> <para>
{config_load} is used for loading config <varname>{config_load}</varname> is used for loading config
<link linkend="language.config.variables">#variables#</link> from a <link linkend="language.config.variables"><parameter>#variables#</parameter></link>
<link linkend="config.files">configuration file</link> into the template. from a <link linkend="config.files">configuration file</link> into the template.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -73,7 +73,7 @@
<example> <example>
<title>{config_load}</title> <title>{config_load}</title>
<para> <para>
example.conf The <filename>example.conf</filename> file.
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -114,15 +114,14 @@ pageTitle = "Customer Info"
<link linkend="config.files">Config Files</link> <link linkend="config.files">Config Files</link>
may also contain sections. You can load variables from may also contain sections. You can load variables from
within a section with the added attribute within a section with the added attribute
<emphasis>'section'</emphasis>. <parameter>section</parameter>.
</para> </para>
<note> <note>
<para> <para>
<emphasis>Config file sections</emphasis> and the built-in Config file <emphasis>sections</emphasis> and the built-in
template function called template function called
<link linkend="language.function.section"><emphasis>{section}</emphasis></link> <link linkend="language.function.section"><varname>{section}</varname></link>
have nothing have nothing to do with each other, they just happen to share a common naming
to do with each other, they just happen to share a common naming
convention. convention.
</para> </para>
</note> </note>
@@ -149,16 +148,17 @@ pageTitle = "Customer Info"
</example> </example>
<para> <para>
See <link linkend="variable.config.overwrite">$config_overwrite</link> for arrays of config variables See <link linkend="variable.config.overwrite"><parameter>$config_overwrite</parameter></link>
to create arrays of config file variables.
</para> </para>
<para> <para>
See also <link linkend="config.files">Config files</link>, See also the <link linkend="config.files">config files</link> page,
<link linkend="language.config.variables">Config variables</link>, <link linkend="language.config.variables">config variables</link> page,
<link linkend="variable.config.dir">$config_dir</link>, <link linkend="variable.config.dir"><parameter>$config_dir</parameter></link>,
<link linkend="api.get.config.vars">get_config_vars()</link> <link linkend="api.get.config.vars"><varname>get_config_vars()</varname></link>
and and
<link linkend="api.config.load">config_load()</link>. <link linkend="api.config.load"><varname>config_load()</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -80,7 +80,7 @@
<listitem><para> <listitem><para>
<varname>{foreach}</varname> loops can be nested, and the nested <varname>{foreach}</varname> loops can be nested, and the nested
<varname>{foreach}</varname> names MUST be unique from each other. <varname>{foreach}</varname> names must be unique from each other.
</para></listitem> </para></listitem>
<listitem><para> <listitem><para>
@@ -95,10 +95,11 @@
<listitem><para> <listitem><para>
<varname>{foreach}</varname> loops also have their own variables that handle properties. <varname>{foreach}</varname> loops also have their own variables that handle properties.
These are accessible as: These are accessed with:
<link linkend="language.variables.smarty.loops"> <link linkend="language.variables.smarty.loops">
<parameter>{$smarty.foreach.name.property}</parameter></link> with <parameter>{$smarty.foreach.name.property}</parameter></link> with
<quote>name</quote> being the <parameter>name</parameter> attribute. <quote>name</quote> being the
<parameter>name</parameter> attribute.
</para> </para>
<note> <note>
<title>Note</title> <title>Note</title>
@@ -168,7 +169,7 @@ $smarty->assign('myArray', $arr);
]]> ]]>
</programlisting> </programlisting>
<para>Template to output <parameter>$myArray</parameter> as key/val pair, <para>Template to output <parameter>$myArray</parameter> as key/val pair,
like PHP's <ulink url="&url.php-manual;foreach">foreach</ulink>.</para> like PHP's <ulink url="&url.php-manual;foreach"><varname>foreach</varname></ulink>.</para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<ul> <ul>
@@ -425,8 +426,8 @@ $smarty->assign('items', $items_list);
</example> </example>
<para> <para>
See also <link linkend="language.function.section">{section}</link> and See also <link linkend="language.function.section"><varname>{section}</varname></link>
<link linkend="language.variables.smarty.loops">$smarty.foreach</link>. and <link linkend="language.variables.smarty.loops"><parameter>$smarty.foreach</parameter></link>.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>

View File

@@ -3,21 +3,21 @@
<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 <varname>{if}</varname> statements in Smarty have much the same flexibility as PHP
<ulink url="&url.php-manual;if"><command>if</command></ulink> <ulink url="&url.php-manual;if">if</ulink>
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 <varname>{if}</varname> must be paired with a matching
<emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and <varname>{/if}</varname>. <varname>{else}</varname> and
<emphasis>{elseif}</emphasis> are also permitted. All PHP conditionals <varname>{elseif}</varname> are also permitted. All PHP conditionals
and functions and functions
are recognized, such as <emphasis>||</emphasis>, <emphasis>or</emphasis>, are recognized, such as <emphasis>||</emphasis>, <emphasis>or</emphasis>,
<emphasis>&amp;&amp;</emphasis>, <emphasis>and</emphasis>, <emphasis>&amp;&amp;</emphasis>, <emphasis>and</emphasis>,
<emphasis>is_array()</emphasis>, etc. <emphasis>is_array()</emphasis>, etc.
</para> </para>
<para> <para>
If <link linkend="variable.security">$security</link> is enabled If <link linkend="variable.security"><parameter>$security</parameter></link> is enabled
then <emphasis>IF_FUNCS</emphasis> array in the <link then <emphasis>IF_FUNCS</emphasis> array in the <link
linkend="variable.security.settings">$security_settings</link> array. linkend="variable.security.settings"><parameter>$security_settings</parameter></link> array.
</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
@@ -221,8 +221,8 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<example> <example>
<title>{if} with more examples</title> <title>{if} with more examples</title>
<programlisting> <programlisting>
@@ -239,7 +239,7 @@
]]> ]]>
</programlisting> </programlisting>
</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:

View File

@@ -5,18 +5,18 @@
<note> <note>
<title>Technical Note</title> <title>Technical Note</title>
<para> <para>
{include_php} is pretty much deprecated from Smarty, you can <varname>{include_php}</varname> 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 <varname>{include_php}</varname> is if you really have a need to
quarantine the php function away from the quarantine the php function away from the
<link linkend="variable.plugins.dir">plugins</link> <link linkend="variable.plugins.dir"><filename>plugins/</filename></link>
directory or your 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>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -45,7 +45,7 @@
<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>
@@ -62,36 +62,35 @@
</informaltable> </informaltable>
<para> <para>
{include_php} tags are used to include a php script in your template. <varname>{include_php}</varname> tags are used to include a php script in your template.
If <link linkend="variable.security">$security</link> is enabled, If <link linkend="variable.security"><parameter>$security</parameter></link> is enabled,
then the php script must be located in the <link then the php script must be located in the <link
linkend="variable.trusted.dir">$trusted_dir</link> path. linkend="variable.trusted.dir"><parameter>$trusted_dir</parameter></link> path.
The {include_php} tag must have the attribute The <varname>{include_php}</varname> tag must have the attribute
"file", which contains the path to the included php file, either <parameter>file</parameter>, which contains the path to the included php file, either
relative to relative to <link linkend="variable.trusted.dir"><parameter>$trusted_dir</parameter></link>,
<link linkend="variable.trusted.dir">$trusted_dir</link>,
or an absolute path. or an absolute path.
</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 <parameter>once</parameter> 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 <parameter>assign</parameter> 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 <varname>{include_php}</varname> 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 <parameter>$this</parameter> within
include. the PHP script that you include.
</para> </para>
<example> <example>
<title>function {include_php}</title> <title>function {include_php}</title>
<para>load_nav.php</para> <para>The <filename>load_nav.php</filename> template.</para>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
@@ -106,26 +105,25 @@ $this->assign('sections',$sql->record);
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Where index.tpl is: Where the teamplate is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* absolute path, or relative to $trusted_dir *} {* absolute path, or relative to $trusted_dir *}
{include_php file='/path/to/load_nav.php'} {include_php file='/path/to/load_nav.php'}
{foreach item="curr_section" from=$sections} {foreach item='curr_section' from=$sections}
<a href="{$curr_section.url}">{$curr_section.name}</a><br /> <a href="{$curr_section.url}">{$curr_section.name}</a><br />
{/foreach} {/foreach}
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para> <para>
See also <link linkend="language.function.include">{include}</link>, See also <link linkend="language.function.include"><varname>{include}</varname></link>,
<link linkend="language.function.php">{php}</link>, <link <link linkend="language.function.php"><varname>{php}</varname></link>, <link
linkend="language.function.capture">{capture}</link>, <link linkend="language.function.capture"><varname>{capture}</varname></link>, <link
linkend="template.resources">Template Resources</link> and <link linkend="template.resources">template resources</link> and <link
linkend="tips.componentized.templates">Componentized linkend="tips.componentized.templates">componentized templates</link> </para>
Templates</link> </para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:

View File

@@ -3,25 +3,50 @@
<sect1 id="language.function.include"> <sect1 id="language.function.include">
<title>{include}</title> <title>{include}</title>
<para> <para>
{include} tags are used for including other templates in the current <varname>{include}</varname> tags are used for including other templates in the current
template. Any variables available in the current template are also template. Any variables available in the current template are also
available within the included template. The {include} tag must have available within the included template.
the attribute <emphasis>'file'</emphasis>, </para>
<itemizedlist>
<listitem><para>
The <varname>{include}</varname> tag must have
the <parameter>file</parameter> attribute
which contains the template resource path. which contains the template resource path.
</para> </para></listitem>
<para>
You can optionally pass the <emphasis>'assign'</emphasis> attribute, <listitem><para>
which will specify a template variable name that the output of Setting the optional <parameter>assign</parameter> attribute
{include} will be assigned to instead of specifies the template variable that the output of
displayed. <varname>{include}</varname> is assigned to, instead of being displayed. Similar to
</para> <link linkend="language.function.assign"><varname>{assign}</varname></link>.
<para> </para></listitem>
All assigned variables' values are restored after the scope of the
<listitem><para>
Variables can be passed to included templates as
<link linkend="language.syntax.attributes">attributes</link>.
Any variables explicitly passed to an included template
are only available within the scope of the included
file. Attribute variables override current template variables, in
the case when they are named the same.
</para></listitem>
<listitem><para>
All assigned variable values are restored after the scope of the
included template is left. This means you can use all variables from included template is left. This means you can use all variables from
the including template inside the included template. But changes to the including template inside the included template. But changes to
variables inside the included template are not visible inside the variables inside the included template are not visible inside the
including template after the {include} statement. including template after the <varname>{include}</varname> statement.
</para> </para></listitem>
<listitem><para>
Use the syntax for <link
linkend="template.resources">template resources</link> to
<varname>{include}</varname> files outside of the
<link linkend="variable.template.dir"><parameter>$template_dir</parameter></link> directory.
</para></listitem>
</itemizedlist>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -66,7 +91,7 @@
</informaltable> </informaltable>
<example> <example>
<title>function {include}</title> <title>Simple {include} example</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<html> <html>
@@ -76,8 +101,10 @@
<body> <body>
{include file='page_header.tpl'} {include file='page_header.tpl'}
{* body of template goes here *} {* body of template goes here, the $tpl_name variable
{include file="$tpl_name.tpl"} <-- will replace $tpl_name with value is replaced with a value eg 'contact.tpl'
*}
{include file="$tpl_name.tpl"}
{include file='page_footer.tpl'} {include file='page_footer.tpl'}
</body> </body>
@@ -85,33 +112,27 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>
You can also pass variables to included templates as
<link linkend="language.syntax.attributes">attributes</link>.
Any variables explicitly passed to an included template as
attributes are only available within the scope of the included
file. Attribute variables override current template variables, in
the case they are named alike.
</para>
<example> <example>
<title>{include} passing variables</title> <title>{include} passing variables</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{include file='header.tpl' title='Main Menu' table_bgcolor='#c0c0c0'} {include file='links.tpl' title='Newest links' links=$link_array}
{* body of template goes here *} {* body of template goes here *}
{include file='footer.tpl' foo='bar'}
{include file='footer.tpl' logo='http://my.example.com/logo.gif'}
]]> ]]>
</programlisting> </programlisting>
<para>where header.tpl could be</para> <para>The template above includes the example <filename>links.tpl</filename> below</para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<table border='1' width='100%' bgcolor='{$table_bgcolor|default:"#0000FF"}'> <div id="box">
<tr><td> <h3>{$title}{/h3>
<h1>{$title}</h1> <ul>
</td></tr> {foreach from=$links item=l}
</table> .. do stuff ...
</foreach}
</ul>
</div>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
@@ -119,34 +140,26 @@
<example> <example>
<title>{include} and assign to variable</title> <title>{include} and assign to variable</title>
<para>This example assigns the contents of nav.tpl to the $navbar variable, <para>This example assigns the contents of <filename>nav.tpl</filename>
which is then output at the top and bottom of the page. to the <varname>$navbar</varname> variable,
which is then output at both the top and bottom of the page.
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<body> <body>
{include file='nav.tpl' assign=navbar} {include file='nav.tpl' assign=navbar}
{include file='header.tpl' title='Main Menu' table_bgcolor='#effeef'} {include file='header.tpl' title='Smarty is cool'}
{$navbar} {$navbar}
{* body of template goes here *}
{* body of template goes here *} {$navbar}
{include file='footer.tpl'}
{include file='footer.tpl' logo='http://my.example.com/logo.gif'}
{$navbar}
</body> </body>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>
Use the syntax for <link
linkend="template.resources">template resources</link> to
include files outside of the <link linkend="variable.template.dir">$template_dir</link>
directory.
</para>
<example> <example>
<title>{include} template resource examples</title> <title>Various {include} resource examples</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* absolute filepath *} {* absolute filepath *}
@@ -162,20 +175,23 @@
{include file='db:header.tpl'} {include file='db:header.tpl'}
{* include a $variable template - eg $module = 'contacts' *} {* include a $variable template - eg $module = 'contacts' *}
{include file="$module.tpl"} {include file="$module.tpl"}
{* wont work as its single quotes ie no variable substitution *} {* wont work as its single quotes ie no variable substitution *}
{include file='$module.tpl'} {include file='$module.tpl'}
{* include a multi $variable template - eg amber/links.view.tpl *}
{include file="$style_dir/$module.$view.tpl"}
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para> <para>
See also See also
<link linkend="language.function.include.php">{include_php}</link>, <link linkend="language.function.include.php"><varname>{include_php}</varname></link>,
<link linkend="language.function.insert">{insert}</link>, <link linkend="language.function.insert"><varname>{insert}</varname></link>,
<link linkend="language.function.php">{php}</link>, <link linkend="language.function.php"><varname>{php}</varname></link>,
<link linkend="template.resources">Template Resources</link> and <link linkend="template.resources">template resources</link> and
<link linkend="tips.componentized.templates">Componentized Templates</link>. <link linkend="tips.componentized.templates">componentized templates</link>.
</para> </para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -3,13 +3,13 @@
<sect1 id="language.function.insert"> <sect1 id="language.function.insert">
<title>{insert}</title> <title>{insert}</title>
<para> <para>
{insert} tags work much like <link <varname>{insert}</varname> tags work much like <link
linkend="language.function.include">{include}</link> tags, linkend="language.function.include"><varname>{include}</varname></link> tags,
except that {insert} tags are NOT cached when except that <varname>{insert}</varname> tags are NOT cached when
template <link linkend="caching">caching</link> is enabled. They template <link linkend="caching">caching</link> is enabled. They
will be executed on every invocation of the template. will be executed on every invocation of the template.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -80,7 +80,7 @@
</programlisting> </programlisting>
</example> </example>
<para> <para>
In this example, we are using the name "getBanner" and passing the In this example, we are using the name <quote>getBanner</quote> and passing the
parameters #banner_location_id# and #site_id#. Smarty will look parameters #banner_location_id# and #site_id#. Smarty will look
for a function named insert_getBanner() in your PHP application, passing for a function named insert_getBanner() in your PHP application, passing
the values of #banner_location_id# and #site_id# as the first argument the values of #banner_location_id# and #site_id# as the first argument
@@ -93,34 +93,46 @@
insert_getBanner(array("lid" => "12345","sid" => "67890")); insert_getBanner(array("lid" => "12345","sid" => "67890"));
and display the returned results in place of the {insert} tag. and display the returned results in place of the {insert} tag.
</para> </para>
<para> <itemizedlist>
If you supply the "assign" attribute, the output of the {insert} tag <listitem><para>
If you supply the <parameter>assign</parameter> attribute,
the output of the <varname>{insert}</varname> tag
will be assigned to this template variable instead of being output will be assigned to this template variable instead of being output
to the template. NOTE: assigning the output to a template variable to the template.
isn't too useful with <note>
<para>
Assigning the output to a template variable isn't too useful with
<link linkend="variable.caching">caching</link> enabled. <link linkend="variable.caching">caching</link> enabled.
</para> </para>
<para> </note>
If you supply the "script" attribute, this php script will be </para></listitem>
included (only once) before the {insert} function is executed. This
<listitem><para>
If you supply the <parameter>script</parameter> attribute,
this php script will be
included (only once) before the <varname>{insert}</varname> function is executed. This
is the case where the insert function may not exist yet, and a php is the case where the insert function may not exist yet, and a php
script must be included first to make it work. The path can be script must be included first to make it work.
</para>
<para>
The path can be
either absolute, or relative to either absolute, or relative to
<link linkend="variable.trusted.dir">$trusted_dir</link>. When <link <link linkend="variable.trusted.dir"><parameter>$trusted_dir</parameter></link>. When <link
linkend="variable.security">$security</link> is enabled, the script linkend="variable.security"><parameter>$security</parameter></link> is enabled, the script
must reside in <link linkend="variable.trusted.dir">$trusted_dir</link>. must reside in <link linkend="variable.trusted.dir"><parameter>$trusted_dir</parameter></link>.
</para> </para></listitem>
</itemizedlist>
<para> <para>
The Smarty object is passed as the second argument. This way you The Smarty object is passed as the second argument. This way you
can reference and modify information in the Smarty object from can reference and modify information in the Smarty object from
within the {insert} function. within the <varname>{insert}</varname> function.
</para> </para>
<note> <note>
<title>Technical Note</title> <title>Technical Note</title>
<para> <para>
It is possible to have portions of the template not It is possible to have portions of the template not
cached. If you have <link linkend="caching">caching</link> cached. If you have <link linkend="caching">caching</link>
turned on, {insert} tags will not be cached. They will run turned on, <varname>{insert}</varname> tags will not be cached. They will run
dynamically every time the page is created, even within cached dynamically every time the page is created, even within cached
pages. This works good for things like banners, polls, live pages. This works good for things like banners, polls, live
weather, search results, user feedback areas, etc. weather, search results, user feedback areas, etc.
@@ -128,7 +140,7 @@
</note> </note>
<para> <para>
See also See also
<link linkend="language.function.include">{include}</link> <link linkend="language.function.include"><varname>{include}</varname></link>
</para> </para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -3,14 +3,14 @@
<sect1 id="language.function.ldelim"> <sect1 id="language.function.ldelim">
<title>{ldelim},{rdelim}</title> <title>{ldelim},{rdelim}</title>
<para> <para>
{ldelim} and {rdelim} are used for <varname>{ldelim}</varname> and <varname>{rdelim}</varname> are used for
<link linkend="language.escaping">escaping</link> <link linkend="language.escaping">escaping</link>
template delimiters, by default template delimiters, by default
"{" and "}". You can also use <link <emphasis role="bold">{</emphasis> and <emphasis role="bold">}</emphasis>.
linkend="language.function.literal">{literal}{/literal}</link> to escape You can also use <link linkend="language.function.literal"><varname>{literal}{/literal}</varname></link>
blocks of text eg Javascript or css. to escape blocks of text eg Javascript or CSS.
See also <link See also the complimentary <link
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>. linkend="language.variables.smarty.ldelim"><parameter>{$smarty.ldelim}</parameter></link>.
</para> </para>
<example> <example>
<title>{ldelim}, {rdelim}</title> <title>{ldelim}, {rdelim}</title>
@@ -29,7 +29,7 @@
{funcname} is how functions look in Smarty! {funcname} is how functions look in Smarty!
]]> ]]>
</screen> </screen>
<para>Another example with some javascript</para> <para>Another example with some Javascript</para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<script language="JavaScript"> <script language="JavaScript">
@@ -53,9 +53,9 @@ function foo() {
</screen> </screen>
</example> </example>
<example> <example>
<title>another Javascript example</title> <title>Another Javascript example</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<script language="JavaScript" type="text/javascript"> <script language="JavaScript" type="text/javascript">
@@ -67,11 +67,10 @@ function foo() {
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>See also <para>See also
<link linkend="language.function.literal">{literal}</link> <link linkend="language.function.literal"><varname>{literal}</varname></link>
and and <link linkend="language.escaping">escaping Smarty parsing</link>.
<link linkend="language.escaping">Escaping Smarty Parsing</link>
</para> </para>
</sect1> </sect1>

View File

@@ -3,17 +3,17 @@
<sect1 id="language.function.literal"> <sect1 id="language.function.literal">
<title>{literal}</title> <title>{literal}</title>
<para> <para>
{literal} tags allow a block of data to be taken literally. This is typically <varname>{literal}</varname> tags allow a block of data to be taken literally. This is typically
used around javascript or stylesheet blocks where curly braces would used around Javascript or stylesheet blocks where {curly braces} would
interfere with the template interfere with the template
<link linkend="variable.left.delimiter">delimiter</link> <link linkend="variable.left.delimiter">delimiter</link>
syntax. Anything within syntax. Anything within
{literal}{/literal} tags is not interpreted, but displayed as-is. If you <varname>{literal}{/literal}</varname> tags is not interpreted, but displayed as-is.
need template tags embedded in your {literal} block, consider using <link If you need template tags embedded in a <varname>{literal}</varname> block, consider using
linkend="language.function.ldelim">{ldelim}{rdelim}</link> to escape the <link linkend="language.function.ldelim"><varname>{ldelim}{rdelim}</varname></link> to escape the
individual delimiters instead. individual delimiters instead.
</para> </para>
<example> <example>
<title>{literal} tags</title> <title>{literal} tags</title>
<programlisting> <programlisting>
@@ -36,7 +36,7 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<example> <example>
<title>Javascript function example</title> <title>Javascript function example</title>
<programlisting> <programlisting>
@@ -54,7 +54,7 @@ function myJsFunction(name, ip){
</example> </example>
<example> <example>
<title>Some css in a template</title> <title>Some css style in a template</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* included this style .. as an experiment *} {* included this style .. as an experiment *}
@@ -68,16 +68,16 @@ function myJsFunction(name, ip){
} }
{/literal} {/literal}
</style> </style>
<div class="madIdea">With smarty you can embed css in the template</div> <div class="madIdea">With smarty you can embed CSS in the template</div>
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para> <para>
See also See also
<link linkend="language.function.ldelim">{ldelim} {rdelim}</link> <link linkend="language.function.ldelim"><varname>{ldelim} {rdelim}</varname></link>
and and the
<link linkend="language.escaping">Escaping Smarty Parsing</link>. <link linkend="language.escaping">escaping Smarty parsing</link> page.
</para> </para>
</sect1> </sect1>

View File

@@ -3,63 +3,60 @@
<sect1 id="language.function.php"> <sect1 id="language.function.php">
<title>{php}</title> <title>{php}</title>
<para> <para>
The {php} tags allow PHP code to be embedded directly into the template. They The <varname>{php}</varname> tags allow PHP code to be embedded directly into the template. They
will not be escaped, regardless of the <link will not be escaped, regardless of the <link
linkend="variable.php.handling">$php_handling</link> setting. This linkend="variable.php.handling"><parameter>$php_handling</parameter></link> setting. This
is for advanced users only, not normally needed and not recommended. is for advanced users only, not normally needed and not recommended.
</para> </para>
<example> <note>
<title>{php} tags</title>
<programlisting>
<![CDATA[
{php}
// including a php script directly
// from the template.
include('/path/to/display_weather.php');
{/php}
]]>
</programlisting>
</example>
<note>
<title>Technical Note</title> <title>Technical Note</title>
<para> <para>
To access PHP variables in {php} blocks you may need to use the PHP To access PHP variables in <varname>{php}</varname> blocks you will need to use the PHP
<ulink url="&url.php-manual;global">global</ulink> <ulink url="&url.php-manual;global">global</ulink>
keyword. keyword.
</para> </para>
</note> </note>
<example>
<title>Example php in {php} tags</title>
<programlisting>
<![CDATA[
{php}
// including a php script directly from the template.
include('/path/to/display_weather.php');
{/php}
]]>
</programlisting>
</example>
<example> <example>
<title>{php} tags with global and assigning a variable</title> <title>{php} tags with global and assigning a variable</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
{* this template includes a {php} block that assign's the variable $varX *}
{php} {php}
global $foo, $bar; global $foo, $bar;
if($foo == $bar){ if($foo == $bar){
echo 'This will come out in the template'; echo 'This will be sent to browser';
} }
$this->assign('varX','Strawberry'); // assign a variable to Smarty
$this->assign('varX','Toffee');
{/php} {/php}
<strong>{$varX}</strong> is my fav ice cream {* output the variable *}
<strong>{$varX}</strong> is my fav ice cream :-)
]]> ]]>
</programlisting> </programlisting>
<para>The following seriously NOT recommended as its in the template scope</para>
<programlisting>
<![CDATA[
{php}
print_r($some_array);
{/php}
]]>
</programlisting>
</example> </example>
<para> <para>
See also See also
<link linkend="variable.php.handling">$php_handling</link>, <link linkend="variable.php.handling"><parameter>$php_handling</parameter></link>,
<link linkend="language.function.include.php">{include_php}</link>, <link linkend="language.function.include.php"><varname>{include_php}</varname></link>,
<link linkend="language.function.include">{include}</link>, <link linkend="language.function.include"><varname>{include}</varname></link>,
<link linkend="language.function.insert">{insert}</link> and <link linkend="language.function.insert"><varname>{insert}</varname></link>
<link linkend="tips.componentized.templates">Componentized Templates</link>. and
<link linkend="tips.componentized.templates">componentized templates</link>.
</para> </para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -798,8 +798,9 @@ the section was shown.
</programlisting> </programlisting>
</example> </example>
<para> <para>
See also <link linkend="language.function.foreach">{foreach}</link> See also <link linkend="language.function.foreach"><varname>{foreach}</varname></link>
and <link linkend="language.variables.smarty.loops">$smarty.section</link>. and
<link linkend="language.variables.smarty.loops"><parameter>$smarty.section</parameter></link>.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>

View File

@@ -10,18 +10,16 @@
unmanageable templates. unmanageable templates.
</para> </para>
<para> <para>
Anything within {strip}{/strip} tags are stripped of the Anything within <varname>{strip}{/strip}</varname> tags are stripped of the
extra spaces or carriage returns at the beginnings and ends of the extra spaces or carriage returns at the beginnings and ends of the
lines before they are displayed. This way you can keep your lines before they are displayed. This way you can keep your
templates readable, and not worry about extra white space causing templates readable, and not worry about extra white space causing
problems. problems.
</para> </para>
<note> <note>
<title>Technical Note</title>
<para> <para>
{strip}{/strip} does not affect the contents of template variables, <varname>{strip}{/strip}</varname> does not affect the contents of template variables,
see the see the <link linkend="language.modifier.strip">strip modifier</link> instead.
<link linkend="language.modifier.strip">strip modifier</link> instead.
</para> </para>
</note> </note>
<example> <example>
@@ -58,8 +56,8 @@
they will be run together, and may not be desired results. they will be run together, and may not be desired results.
</para> </para>
<para> <para>
See also See also the
<link linkend="language.modifier.strip">strip modifier</link> <link linkend="language.modifier.strip"><varname>strip</varname></link> modifier.
</para> </para>
</sect1> </sect1>