mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
* some wz
* no tab * add Cdata section
This commit is contained in:
@@ -1,87 +1,87 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.capture">
|
||||
<title>capture</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>default</emphasis></entry>
|
||||
<entry>The name of the captured block</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The variable name where to assign the captured output to</entry>
|
||||
</row>
|
||||
</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 $smarty.capture.foo 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>
|
||||
Smarty 1.4.0 - 1.4.4 placed the captured content into the
|
||||
variable named $return. As of 1.4.5, this behavior was changed to use
|
||||
the name attribute, so update your templates accordingly.
|
||||
</para>
|
||||
</note>
|
||||
<caution>
|
||||
<para>
|
||||
Be careful when capturing <command>insert</command> output. If
|
||||
you have caching turned on and you have <command>insert</command>
|
||||
commands that you expect to run within cached content, do not
|
||||
capture this content.
|
||||
</para>
|
||||
</caution>
|
||||
<para>
|
||||
<example>
|
||||
<title>capturing template content</title>
|
||||
<programlisting>
|
||||
<sect1 id="language.function.capture">
|
||||
<title>capture</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>default</emphasis></entry>
|
||||
<entry>The name of the captured block</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The variable name where to assign the captured output to</entry>
|
||||
</row>
|
||||
</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 $smarty.capture.foo 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>
|
||||
Smarty 1.4.0 - 1.4.4 placed the captured content into the
|
||||
variable named $return. As of 1.4.5, this behavior was changed to use
|
||||
the name attribute, so update your templates accordingly.
|
||||
</para>
|
||||
</note>
|
||||
<caution>
|
||||
<para>
|
||||
Be careful when capturing <command>insert</command> output. If
|
||||
you have caching turned on and you have <command>insert</command>
|
||||
commands that you expect to run within cached content, do not
|
||||
capture this content.
|
||||
</para>
|
||||
</caution>
|
||||
<para>
|
||||
<example>
|
||||
<title>capturing template content</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* we don't want to print a table row unless content is displayed *}
|
||||
{capture name=banner}
|
||||
{include file="get_banner.tpl"}
|
||||
{/capture}
|
||||
{if $smarty.capture.banner ne ""}
|
||||
<tr>
|
||||
<td>
|
||||
{$smarty.capture.banner}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{$smarty.capture.banner}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,107 +1,122 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.include">
|
||||
<title>include</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the template file to include</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that the output of
|
||||
include will be assigned to</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>[var ...]</entry>
|
||||
<entry>[var type]</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>variable to pass local to template</entry>
|
||||
</row>
|
||||
</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
|
||||
<emphasis>include</emphasis> will be assigned to instead of
|
||||
displayed.
|
||||
</para>
|
||||
<example>
|
||||
<title>function include</title>
|
||||
<programlisting>
|
||||
{include file="header.tpl"}
|
||||
<sect1 id="language.function.include">
|
||||
<title>include</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the template file to include</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the variable that the output of
|
||||
include will be assigned to</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>[var ...]</entry>
|
||||
<entry>[var type]</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>variable to pass local to template</entry>
|
||||
</row>
|
||||
</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
|
||||
<emphasis>include</emphasis> will be assigned to instead of
|
||||
displayed.
|
||||
</para>
|
||||
<example>
|
||||
<title>function include</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{include file="header.tpl"}
|
||||
|
||||
{* body of template goes here *}
|
||||
{* body of template goes here *}
|
||||
|
||||
{include file="footer.tpl"}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
You can also pass variables to included templates as attributes.
|
||||
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>
|
||||
<title>function include passing variables</title>
|
||||
<programlisting>
|
||||
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||
{include file="footer.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
You can also pass variables to included templates as attributes.
|
||||
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>
|
||||
<title>function include passing variables</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||
|
||||
{* body of template goes here *}
|
||||
{* body of template goes here *}
|
||||
|
||||
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}</programlisting>
|
||||
</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>
|
||||
<title>function include template resource examples</title>
|
||||
<programlisting>
|
||||
{* absolute filepath *}
|
||||
{include file="/usr/local/include/templates/header.tpl"}
|
||||
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</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>
|
||||
<title>function include template resource examples</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* absolute filepath *}
|
||||
{include file="/usr/local/include/templates/header.tpl"}
|
||||
|
||||
{* absolute filepath (same thing) *}
|
||||
{include file="file:/usr/local/include/templates/header.tpl"}
|
||||
{* absolute filepath (same thing) *}
|
||||
{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"}
|
||||
{* windows absolute filepath (MUST use "file:" prefix) *}
|
||||
{include file="file:C:/www/pub/templates/header.tpl"}
|
||||
|
||||
{* include from template resource named "db" *}
|
||||
{include file="db:header.tpl"}</programlisting>
|
||||
</example>
|
||||
<para>See also <link linkend="language.function.include.php">{include_php}</link>, <link linkend="language.function.php">{php}</link> <link linkend="template.resources">Template Resources</link> and <link linkend="tips.componentized.templates">Componentized Templates</link></para>
|
||||
{* include from template resource named "db" *}
|
||||
{include file="db:header.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also
|
||||
<link linkend="language.function.include.php">{include_php}</link>,
|
||||
<link linkend="language.function.php">{php}</link>,
|
||||
<link linkend="template.resources">Template Resources</link> and
|
||||
<link linkend="tips.componentized.templates">Componentized Templates</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,124 +1,124 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.insert">
|
||||
<title>insert</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the insert function (insert_name)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the template variable the output will
|
||||
be assigned to</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>script</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the php script that is included before
|
||||
the insert function is called</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>[var ...]</entry>
|
||||
<entry>[var type]</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>variable to pass to insert function</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Insert tags work much like include 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,
|
||||
flash, etc. so we can't just use a static link here, and we
|
||||
don't want this contents cached with the page. In comes the
|
||||
insert tag: the template knows #banner_location_id# and
|
||||
#site_id# values (gathered from a config file), and needs to
|
||||
call a function to get the banner contents.
|
||||
</para>
|
||||
<example>
|
||||
<title>function insert</title>
|
||||
<programlisting>
|
||||
{* example of fetching a banner *}
|
||||
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
In this example, we are using the name "getBanner" and passing the
|
||||
parameters #banner_location_id# and #site_id#. Smarty will look
|
||||
for a function named insert_getBanner() in your PHP application, passing
|
||||
the values of #banner_location_id# and #site_id# as the first argument
|
||||
in an associative array. All insert function names in
|
||||
your application must be prepended with "insert_" to remedy possible
|
||||
function name-space conflicts. Your insert_getBanner() function should
|
||||
do something with the passed values and return the results. These results
|
||||
are then displayed in the template in place of the insert tag.
|
||||
In this example, Smarty would call this function:
|
||||
insert_getBanner(array("lid" => "12345","sid" => "67890"));
|
||||
and display the returned results in place of the insert tag.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the "assign" attribute, the output of the insert tag
|
||||
will be assigned to this template variable instead of being output
|
||||
to the template. NOTE: assigning the output to a template variable
|
||||
isn't too useful with caching enabled.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the "script" attribute, this php script will be
|
||||
included (only once) before the insert function is executed. This
|
||||
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
|
||||
either absolute, or relative to $trusted_dir. When security is
|
||||
enabled, the script must reside in $trusted_dir.
|
||||
</para>
|
||||
<para>
|
||||
The Smarty object is passed as the second argument. This way you
|
||||
can reference and modify information in the Smarty object from
|
||||
within the insert function.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is possible to have portions of the template not
|
||||
cached. If you have <link linkend="caching">caching</link>
|
||||
turned on, insert tags will not be cached. They will run
|
||||
dynamically every time the page is created, even within cached
|
||||
pages. This works good for things like banners, polls, live
|
||||
weather, search results, user feedback areas, etc.
|
||||
</para>
|
||||
</note>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
<sect1 id="language.function.insert">
|
||||
<title>insert</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
<colspec colname="type" align="center" />
|
||||
<colspec colname="required" align="center" />
|
||||
<colspec colname="default" align="center" />
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute Name</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>string</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the insert function (insert_name)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the template variable the output will
|
||||
be assigned to</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>script</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>The name of the php script that is included before
|
||||
the insert function is called</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>[var ...]</entry>
|
||||
<entry>[var type]</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>variable to pass to insert function</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Insert tags work much like include 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,
|
||||
flash, etc. so we can't just use a static link here, and we
|
||||
don't want this contents cached with the page. In comes the
|
||||
insert tag: the template knows #banner_location_id# and
|
||||
#site_id# values (gathered from a config file), and needs to
|
||||
call a function to get the banner contents.
|
||||
</para>
|
||||
<example>
|
||||
<title>function insert</title>
|
||||
<programlisting>
|
||||
{* example of fetching a banner *}
|
||||
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
In this example, we are using the name "getBanner" and passing the
|
||||
parameters #banner_location_id# and #site_id#. Smarty will look
|
||||
for a function named insert_getBanner() in your PHP application, passing
|
||||
the values of #banner_location_id# and #site_id# as the first argument
|
||||
in an associative array. All insert function names in
|
||||
your application must be prepended with "insert_" to remedy possible
|
||||
function name-space conflicts. Your insert_getBanner() function should
|
||||
do something with the passed values and return the results. These results
|
||||
are then displayed in the template in place of the insert tag.
|
||||
In this example, Smarty would call this function:
|
||||
insert_getBanner(array("lid" => "12345","sid" => "67890"));
|
||||
and display the returned results in place of the insert tag.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the "assign" attribute, the output of the insert tag
|
||||
will be assigned to this template variable instead of being output
|
||||
to the template. NOTE: assigning the output to a template variable
|
||||
isn't too useful with caching enabled.
|
||||
</para>
|
||||
<para>
|
||||
If you supply the "script" attribute, this php script will be
|
||||
included (only once) before the insert function is executed. This
|
||||
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
|
||||
either absolute, or relative to $trusted_dir. When security is
|
||||
enabled, the script must reside in $trusted_dir.
|
||||
</para>
|
||||
<para>
|
||||
The Smarty object is passed as the second argument. This way you
|
||||
can reference and modify information in the Smarty object from
|
||||
within the insert function.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
It is possible to have portions of the template not
|
||||
cached. If you have <link linkend="caching">caching</link>
|
||||
turned on, insert tags will not be cached. They will run
|
||||
dynamically every time the page is created, even within cached
|
||||
pages. This works good for things like banners, polls, live
|
||||
weather, search results, user feedback areas, etc.
|
||||
</para>
|
||||
</note>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
|
@@ -1,42 +1,45 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.literal">
|
||||
<title>literal</title>
|
||||
<para>
|
||||
Literal tags allow a block of data to be taken literally. This is typically
|
||||
used around javascript or stylesheet blocks where curly braces would
|
||||
interfere with the template delimiter syntax. Anything within
|
||||
{literal}{/literal} tags is not interpreted, but displayed as-is. If you
|
||||
need template tags embedded in your literal block, consider using <link
|
||||
linkend="language.function.ldelim">{ldelim}{rdelim}</link> to escape the
|
||||
individual delimiters instead.
|
||||
</para>
|
||||
<example>
|
||||
<title>literal tags</title>
|
||||
<programlisting>
|
||||
<sect1 id="language.function.literal">
|
||||
<title>literal</title>
|
||||
<para>
|
||||
Literal tags allow a block of data to be taken literally. This is typically
|
||||
used around javascript or stylesheet blocks where curly braces would
|
||||
interfere with the template delimiter syntax. Anything within
|
||||
{literal}{/literal} tags is not interpreted, but displayed as-is. If you
|
||||
need template tags embedded in your literal block, consider using <link
|
||||
linkend="language.function.ldelim">{ldelim}{rdelim}</link> to escape the
|
||||
individual delimiters instead.
|
||||
</para>
|
||||
<example>
|
||||
<title>literal tags</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
|
||||
<!--
|
||||
function isblank(field) {
|
||||
if (field.value == '')
|
||||
{ return false; }
|
||||
else
|
||||
{
|
||||
document.loginform.submit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// -->
|
||||
<!--
|
||||
function isblank(field) {
|
||||
if (field.value == '')
|
||||
{ return false; }
|
||||
else
|
||||
{
|
||||
document.loginform.submit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// -->
|
||||
|
||||
</script>
|
||||
</script>
|
||||
{/literal}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>See also <link linkend="language.escaping">Escaping Smarty Parsing</link> </para>
|
||||
</sect1>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also
|
||||
<link linkend="language.escaping">Escaping Smarty Parsing</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,23 +1,31 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.php">
|
||||
<title>php</title>
|
||||
<para>
|
||||
php tags allow php to be embedded directly into the template. They
|
||||
will not be escaped, regardless of the <link
|
||||
linkend="variable.php.handling">$php_handling</link> setting. This
|
||||
is for advanced users only, not normally needed.
|
||||
</para>
|
||||
<example>
|
||||
<title>php tags</title>
|
||||
<programlisting>
|
||||
{php}
|
||||
// including a php script directly
|
||||
// from the template.
|
||||
include("/path/to/display_weather.php");
|
||||
{/php}</programlisting>
|
||||
</example>
|
||||
<para>See also <link linkend="language.function.include.php">{include_php}</link>, <link linkend="language.function.include">{include}</link> and <link linkend="tips.componentized.templates">Componentized Templates</link></para>
|
||||
<sect1 id="language.function.php">
|
||||
<title>php</title>
|
||||
<para>
|
||||
php tags allow php to be embedded directly into the template. They
|
||||
will not be escaped, regardless of the <link
|
||||
linkend="variable.php.handling">$php_handling</link> setting. This
|
||||
is for advanced users only, not normally needed.
|
||||
</para>
|
||||
<example>
|
||||
<title>php tags</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{php}
|
||||
// including a php script directly
|
||||
// from the template.
|
||||
include("/path/to/display_weather.php");
|
||||
{/php}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
See also
|
||||
<link linkend="language.function.include.php">{include_php}</link>,
|
||||
<link linkend="language.function.include">{include}</link> and
|
||||
<link linkend="tips.componentized.templates">Componentized Templates</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,59 +1,62 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.strip">
|
||||
<title>strip</title>
|
||||
<para>
|
||||
Many times web designers run into the issue where white space and
|
||||
carriage returns affect the output of the rendered HTML (browser
|
||||
"features"), so you must run all your tags together in the template
|
||||
to get the desired results. This usually ends up in unreadable or
|
||||
unmanageable templates.
|
||||
</para>
|
||||
<para>
|
||||
Anything within {strip}{/strip} tags in Smarty are stripped 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
|
||||
templates readable, and not worry about extra white space causing
|
||||
problems.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
{strip}{/strip} does not affect the contents of template variables.
|
||||
See the <link linkend="language.modifier.strip">strip modifier
|
||||
function</link>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>strip tags</title>
|
||||
<programlisting>
|
||||
<sect1 id="language.function.strip">
|
||||
<title>strip</title>
|
||||
<para>
|
||||
Many times web designers run into the issue where white space and
|
||||
carriage returns affect the output of the rendered HTML (browser
|
||||
"features"), so you must run all your tags together in the template
|
||||
to get the desired results. This usually ends up in unreadable or
|
||||
unmanageable templates.
|
||||
</para>
|
||||
<para>
|
||||
Anything within {strip}{/strip} tags in Smarty are stripped 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
|
||||
templates readable, and not worry about extra white space causing
|
||||
problems.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
{strip}{/strip} does not affect the contents of template variables.
|
||||
See the <link linkend="language.modifier.strip">strip modifier
|
||||
function</link>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>strip tags</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* the following will be all run into one line upon output *}
|
||||
{strip}
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$url}">
|
||||
<font color="red">This is a test</font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$url}">
|
||||
<font color="red">This is a test</font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/strip}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The above example will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<table border=0><tr><td><A HREF="http://my.example.com"><font color="red">This is a test</font></A></td></tr></table>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Notice that in the above example, all the lines begin and end
|
||||
with HTML tags. Be aware that all the lines are run together.
|
||||
If you have plain text at the beginning or end of any line,
|
||||
they will be run together, and may not be desired results.
|
||||
</para>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Notice that in the above example, all the lines begin and end
|
||||
with HTML tags. Be aware that all the lines are run together.
|
||||
If you have plain text at the beginning or end of any line,
|
||||
they will be run together, and may not be desired results.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
Reference in New Issue
Block a user