cvs: smarty /docs/en/designers/language-builtin-functions language-function-capture.xml language-function-config-load.xml language-function-foreach.xml language-function-if.xml language-function-include-php.xml language-function-include.xml language-function-insert.xml language-function-php.xml language-function-section.xml language-function-strip.xml
"Peter 'Mash' Morgan" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvspete_morgan1126636908@cvsserver> |
pete_morgan Tue Sep 13 14:41:48 2005 EDT
Modified files:
/smarty/docs/en/designers/language-builtin-functions
language-function-capture.xml
language-function-config-load.xml
language-function-foreach.xml
language-function-if.xml
language-function-include-php.xml
language-function-include.xml
language-function-insert.xml
language-function-php.xml
language-function-section.xml
language-function-strip.xml
Log:
Moved description to top of page and some tweaks
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
pete_morgan-20050913144148.txt
(text/plain, 22.6 KB)
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-capture.xml?r1=1.8&r2=1.9&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-capture.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-capture.xml:1.8 smarty/docs/en/designers/language-builtin-functions/language-function-capture.xml:1.9
--- smarty/docs/en/designers/language-builtin-functions/language-function-capture.xml:1.8 Fri May 27 12:25:01 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-capture.xml Tue Sep 13 14:41:43 2005
@@ -1,7 +1,21 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<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
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml?r1=1.10&r2=1.11&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml:1.10 smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml:1.11
--- smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml:1.10 Sat Sep 10 09:03:09 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-config-load.xml Tue Sep 13 14:41:43 2005
@@ -1,7 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
<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 @@
</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>,
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-foreach.xml?r1=1.7&r2=1.8&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-foreach.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-foreach.xml:1.7 smarty/docs/en/designers/language-builtin-functions/language-function-foreach.xml:1.8
--- smarty/docs/en/designers/language-builtin-functions/language-function-foreach.xml:1.7 Fri May 27 12:25:01 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-foreach.xml Tue Sep 13 14:41:44 2005
@@ -1,7 +1,29 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<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">
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-if.xml?r1=1.6&r2=1.7&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-if.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-if.xml:1.6 smarty/docs/en/designers/language-builtin-functions/language-function-if.xml:1.7
--- smarty/docs/en/designers/language-builtin-functions/language-function-if.xml:1.6 Sat Sep 10 09:21:14 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-if.xml Tue Sep 13 14:41:44 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<sect1 id="language.function.if">
<title>{if},{elseif},{else}</title>
<para>
@@ -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>
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-include-php.xml?r1=1.8&r2=1.9&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-include-php.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-include-php.xml:1.8 smarty/docs/en/designers/language-builtin-functions/language-function-include-php.xml:1.9
--- smarty/docs/en/designers/language-builtin-functions/language-function-include-php.xml:1.8 Thu Jun 23 14:40:52 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-include-php.xml Tue Sep 13 14:41:44 2005
@@ -1,7 +1,22 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<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>,
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-include.xml?r1=1.8&r2=1.9&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-include.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-include.xml:1.8 smarty/docs/en/designers/language-builtin-functions/language-function-include.xml:1.9
--- smarty/docs/en/designers/language-builtin-functions/language-function-include.xml:1.8 Sun Jun 5 15:46:19 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-include.xml Tue Sep 13 14:41:44 2005
@@ -1,7 +1,20 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<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>
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-insert.xml?r1=1.5&r2=1.6&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-insert.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-insert.xml:1.5 smarty/docs/en/designers/language-builtin-functions/language-function-insert.xml:1.6
--- smarty/docs/en/designers/language-builtin-functions/language-function-insert.xml:1.5 Fri May 27 12:25:01 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-insert.xml Tue Sep 13 14:41:44 2005
@@ -1,7 +1,15 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.5 $ -->
+<!-- $Revision: 1.6 $ -->
<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,
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-php.xml?r1=1.6&r2=1.7&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-php.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-php.xml:1.6 smarty/docs/en/designers/language-builtin-functions/language-function-php.xml:1.7
--- smarty/docs/en/designers/language-builtin-functions/language-function-php.xml:1.6 Fri May 27 12:25:01 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-php.xml Tue Sep 13 14:41:44 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<sect1 id="language.function.php">
<title>{php}</title>
<para>
@@ -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>,
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-section.xml?r1=1.13&r2=1.14&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-section.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-section.xml:1.13 smarty/docs/en/designers/language-builtin-functions/language-function-section.xml:1.14
--- smarty/docs/en/designers/language-builtin-functions/language-function-section.xml:1.13 Fri Jun 24 05:02:01 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-section.xml Tue Sep 13 14:41:44 2005
@@ -1,7 +1,24 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.13 $ -->
+<!-- $Revision: 1.14 $ -->
<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>
http://cvs.php.net/diff.php/smarty/docs/en/designers/language-builtin-functions/language-function-strip.xml?r1=1.7&r2=1.8&ty=u
Index: smarty/docs/en/designers/language-builtin-functions/language-function-strip.xml
diff -u smarty/docs/en/designers/language-builtin-functions/language-function-strip.xml:1.7 smarty/docs/en/designers/language-builtin-functions/language-function-strip.xml:1.8
--- smarty/docs/en/designers/language-builtin-functions/language-function-strip.xml:1.7 Sat Sep 10 09:04:04 2005
+++ smarty/docs/en/designers/language-builtin-functions/language-function-strip.xml Tue Sep 13 14:41:44 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<sect1 id="language.function.strip">
<title>{strip}</title>
<para>
@@ -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>