another patch by Peter. some WS.

This commit is contained in:
nlopess
2005-05-21 12:41:15 +00:00
parent 918ce294ad
commit 4b80984d6a
24 changed files with 289 additions and 186 deletions

View File

@@ -9,7 +9,8 @@
<para> <para>
There may be times when you want to print a default value for an empty There may be times when you want to print a default value for an empty
variable instead of printing nothing, such as printing "&amp;nbsp;" so that variable instead of printing nothing, such as printing "&amp;nbsp;" so that
table backgrounds work properly. Many would use an <link linkend="language.function.if">{if}</link> statement to table backgrounds work properly. Many would use an
<link linkend="language.function.if">{if}</link> statement to
handle this, but there is a shorthand way with Smarty, using the handle this, but there is a shorthand way with Smarty, using the
<emphasis>default</emphasis> variable modifier. <emphasis>default</emphasis> variable modifier.
</para> </para>
@@ -32,7 +33,10 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>See also <link linkend="language.modifier.default">default</link> and <link linkend="tips.default.var.handling">Default Variable Handling</link></para> <para>
See also <link linkend="language.modifier.default">default</link>
and <link linkend="tips.default.var.handling">Default Variable Handling</link>.
</para>
</sect1> </sect1>
<sect1 id="tips.default.var.handling"> <sect1 id="tips.default.var.handling">
@@ -55,8 +59,12 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>See also <link linkend="language.modifier.default">default</link> and <link linkend="tips.blank.var.handling">Blank Variable Handling</link></para> <para>
See also <link linkend="language.modifier.default">default</link> and
<link linkend="tips.blank.var.handling">Blank Variable Handling</link>.
</para>
</sect1> </sect1>
<sect1 id="tips.passing.vars"> <sect1 id="tips.passing.vars">
<title>Passing variable title to header template</title> <title>Passing variable title to header template</title>
<para> <para>
@@ -125,7 +133,8 @@ footer.tpl
<note> <note>
<para> <para>
As of Smarty 1.4.0, you can pass dates to Smarty as unix As of Smarty 1.4.0, you can pass dates to Smarty as unix
timestamps, mysql timestamps, or any date parsable by <ulink url="&url.php-manual;strtotime">strtotime()</ulink>. timestamps, mysql timestamps, or any date parsable by
<ulink url="&url.php-manual;strtotime">strtotime()</ulink>.
</para> </para>
</note> </note>
<example> <example>
@@ -165,7 +174,8 @@ Jan 4, 2001
</programlisting> </programlisting>
</example> </example>
<para> <para>
When using <link linkend="language.function.html.select.date">{html_select_date}</link> in a template, The programmer will most When using <link linkend="language.function.html.select.date">{html_select_date}</link>
in a template, The programmer will most
likely want to convert the output from the form back into timestamp likely want to convert the output from the form back into timestamp
format. Here is a function to help you with that. format. Here is a function to help you with that.
</para> </para>
@@ -269,7 +279,8 @@ function insert_header($params)
Traditionally, programming templates into your applications goes as Traditionally, programming templates into your applications goes as
follows: First, you accumulate your variables within your PHP follows: First, you accumulate your variables within your PHP
application, (maybe with database queries.) Then, you instantiate your application, (maybe with database queries.) Then, you instantiate your
Smarty object, <link linkend="api.assign">assign</link> the variables and <link linkend="api.display">display</link> the template. So lets Smarty object, <link linkend="api.assign">assign</link> the variables and
<link linkend="api.display">display</link> the template. So lets
say for example we have a stock ticker on our template. We would say for example we have a stock ticker on our template. We would
collect the stock data in our application, then assign these variables collect the stock data in our application, then assign these variables
in the template and display it. Now wouldn't it be nice if you could in the template and display it. Now wouldn't it be nice if you could
@@ -317,8 +328,13 @@ Stock Name: {$ticker.name} Stock Price: {$ticker.price}
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>See also <link linkend="language.function.include.php">{include_php}</link>, <link linkend="language.function.include">{include}</link> and <link linkend="language.function.php">{php}</link></para> <para>
See also <link linkend="language.function.include.php">{include_php}</link>,
<link linkend="language.function.include">{include}</link> and
<link linkend="language.function.php">{php}</link>.
</para>
</sect1> </sect1>
<sect1 id="tips.obfuscating.email"> <sect1 id="tips.obfuscating.email">
<title>Obfuscating E-mail Addresses</title> <title>Obfuscating E-mail Addresses</title>
<para> <para>
@@ -346,9 +362,12 @@ Send inquiries to
e-mail collector to decode these values, but not likely. e-mail collector to decode these values, but not likely.
</para> </para>
</note> </note>
<para>See also <link linkend="language.modifier.escape">escape</link></para> <para>
See also <link linkend="language.modifier.escape">escape</link>.
</para>
</sect1> </sect1>
</chapter> </chapter>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml

View File

@@ -28,15 +28,22 @@
</programlisting> </programlisting>
</example> </example>
<para> <para>
Both built-in functions and custom functions have the same syntax in Both <link linkend="language.builtin.functions">built-in functions</link>
the templates. Built-in functions are the inner workings of Smarty, and <link linkend="language.custom.functions">custom functions</link>
such as <link linkend="language.function.if"><command>if</command></link>, <link linkend="language.function.section"><command>section</command></link> and have the same syntax in the templates. Built-in functions are the
<link linkend="language.function.strip"><command>strip</command></link>. They cannot be modified. Custom functions are inner workings of Smarty, such as
additional functions implemented via plugins. They can be modified to <link linkend="language.function.if"><command>if</command></link>,
your liking, or you can add new ones. <link linkend="language.function.html.options"><command>html_options</command></link> and <link linkend="language.function.section"><command>section</command></link> and
<link linkend="language.function.html.select.date"><command>html_select_date</command></link> are examples of custom functions. <link linkend="language.function.strip"><command>strip</command></link>.
They cannot be modified. Custom functions are
additional functions implemented via <link linkend="plugins">plugins</link>.
They can be modified to your liking, or you can add new ones.
<link linkend="language.function.html.options"><command>html_options</command></link> and
<link linkend="language.function.html.select.date"><command>html_select_date</command></link>
are examples of custom functions.
</para> </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:
mode: sgml mode: sgml

View File

@@ -28,8 +28,11 @@ PRACTICAL EXAMPLES:
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>See also <link linkend="language.modifier.escape">escape</link></para> <para>
See also <link linkend="language.modifier.escape">escape</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:
mode: sgml mode: sgml

View File

@@ -8,7 +8,8 @@
that are indexed numerically or non-numerically. You can also reference that are indexed numerically or non-numerically. You can also reference
object properties and methods. Config file variables are an exception to the object properties and methods. Config file variables are an exception to the
dollar sign syntax. They can be referenced with surrounding hashmarks, or dollar sign syntax. They can be referenced with surrounding hashmarks, or
with the special $smarty.config variable. with the special
<link linkend="language.variables.smarty.config">$smarty.config</link> variable.
</para> </para>
<example> <example>
<title>Variables</title> <title>Variables</title>
@@ -23,6 +24,7 @@
{#foo#} <-- display the config file variable "foo" {#foo#} <-- display the config file variable "foo"
{$smarty.config.foo} <-- synonym for {#foo#} {$smarty.config.foo} <-- synonym for {#foo#}
{$foo[bar]} <-- syntax only valid in a section loop, see {section} {$foo[bar]} <-- syntax only valid in a section loop, see {section}
{assign var=foo value="baa"}{$foo} <-- displays "baa", see {assign}
Many other combinations are allowed Many other combinations are allowed
@@ -36,9 +38,12 @@ Many other combinations are allowed
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para>See also <link linkend="language.variables.smarty">$smarty reserved variables</link> <para>
and <link linkend="language.config.variables">Config Variables</link></para> See also <link linkend="language.variables.smarty">$smarty reserved variables</link>
and <link linkend="language.config.variables">Config Variables</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:
mode: sgml mode: sgml

View File

@@ -41,10 +41,11 @@
variable instead of displaying it. Any content between {capture variable instead of displaying it. Any content between {capture
name="foo"} and {/capture} is collected into the variable specified name="foo"} and {/capture} is collected into the variable specified
in the name attribute. The captured content can be used in the in the name attribute. The captured content can be used in the
template from the special variable $smarty.capture.foo where foo is template from the special variable <link
the value passed in the name attribute. If you do not supply a name linkend="language.variables.smarty.capture">$smarty.capture.foo</link>
attribute, then "default" will be used. All {capture} commands must where foo is the value passed in the name attribute. If you do not
be paired with {/capture}. You can nest capture commands. supply a name attribute, then "default" will be used. All {capture}
commands must be paired with {/capture}. You can nest capture commands.
</para> </para>
<note> <note>
<title>Technical Note</title> <title>Technical Note</title>
@@ -56,10 +57,11 @@
</note> </note>
<caution> <caution>
<para> <para>
Be careful when capturing <command>insert</command> output. If Be careful when capturing <link
you have caching turned on and you have <command>insert</command> linkend="language.function.insert"><command>insert</command></link>
commands that you expect to run within cached content, do not output. If you have caching turned on and you have
capture this content. <command>insert</command> commands that you expect to run
within cached content, do not capture this content.
</para> </para>
</caution> </caution>
<para> <para>
@@ -82,7 +84,11 @@
</programlisting> </programlisting>
</example> </example>
</para> </para>
<para>
See also <link linkend="language.function.assign">assign </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:
mode: sgml mode: sgml

View File

@@ -59,13 +59,16 @@
</note> </note>
<para> <para>
include_php tags are used to include a php script in your template. include_php tags are used to include a php script in your template.
If security is enabled, then the php script must be located in the If <link linkend="variable.security">security is enabled</link>,
$trusted_dir path. The include_php tag must have the attribute then the php script must be located in the <link
linkend="variable.trusted.dir">$trusted_dir</link> path.
The include_php tag must have the attribute
"file", which contains the path to the included php file, either "file", which contains the path to the included php file, either
relative to $trusted_dir, or an absolute path. relative to $trusted_dir, or an absolute path.
</para> </para>
<para> <para>
include_php is a nice way to handle componentized templates, and include_php is a nice way to handle <link
linkend="tips.componentized.templates">componentized templates</link>, and
keep PHP code separate from the template files. Lets say you have a keep PHP code separate from the template files. Lets say you have a
template that shows your site navigation, which is pulled template that shows your site navigation, which is pulled
dynamically from a database. You can keep your PHP logic that grabs dynamically from a database. You can keep your PHP logic that grabs

View File

@@ -53,10 +53,11 @@
</tgroup> </tgroup>
</informaltable> </informaltable>
<para> <para>
Insert tags work much like include tags, except that insert tags Insert tags work much like <link
are not cached when you have template <link linkend="language.function.include">include</link> tags,
linkend="caching">caching</link> enabled. They will be except that insert tags are not cached when you have
executed on every invocation of the template. template <link linkend="caching">caching</link> enabled. They
will be executed on every invocation of the template.
</para> </para>
<para> <para>
Let's say you have a template with a banner slot at the top of Let's say you have a template with a banner slot at the top of
@@ -71,7 +72,8 @@
<title>function insert</title> <title>function insert</title>
<programlisting> <programlisting>
{* example of fetching a banner *} {* example of fetching a banner *}
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}</programlisting> {insert name="getBanner" lid=#banner_location_id# sid=#site_id#}
</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 "getBanner" and passing the
@@ -98,8 +100,9 @@
included (only once) before the insert function is executed. This included (only once) before the insert 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. The path can be
either absolute, or relative to $trusted_dir. When security is either absolute, or relative to $trusted_dir. When <link
enabled, the script must reside in $trusted_dir. linkend="variable.security">security is enabled</link>, the script
must reside in <link linkend="variable.trusted.dir">$trusted_dir</link>.
</para> </para>
<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

View File

@@ -284,7 +284,8 @@
<title>Technical Note</title> <title>Technical Note</title>
<para> <para>
If the step and start section properties are not If the step and start section properties are not
modified, then this works the same as the iteration section modified, then this works the same as the <link
linkend="section.property.iteration">iteration</link> section
property, except it starts on 0 instead of 1. property, except it starts on 0 instead of 1.
</para> </para>
</note> </note>
@@ -386,9 +387,10 @@
<note> <note>
<para> <para>
This is not affected by the section properties start, step and This is not affected by the section properties start, step and
max, unlike the index property. Iteration also starts with 1 max, unlike the <link linkend="section.property.index">index</link>
instead of 0 like index. rownum is an alias to iteration, they work property. Iteration also starts with 1 instead of 0 like index. <link
identical. linkend="section.property.rownum">rownum</link> is an alias to iteration,
they work identical.
</para> </para>
</note> </note>
<example> <example>
@@ -503,7 +505,8 @@
<title>rownum</title> <title>rownum</title>
<para> <para>
rownum is used to display the current loop iteration, rownum is used to display the current loop iteration,
starting with one. It is an alias to iteration, they work starting with one. It is an alias to <link
linkend="section.property.iteration">iteration</link>, they work
identically. identically.
</para> </para>
<example> <example>
@@ -627,8 +630,13 @@
]]> ]]>
</screen> </screen>
</example> </example>
<para>
See also <link linkend="language.function.foreach">foreach</link>
and <link linkend="language.variables.smarty.loops">$smarty.section</link>.
</para>
</sect2> </sect2>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml

View File

@@ -33,8 +33,8 @@ index.tpl:
<screen> <screen>
<![CDATA[ <![CDATA[
Smokers are Productive, but Death Cuts Efficiency. Smokers are Productive, but Death Cuts Efficiency.
S M O K E R S A R E P R O D U C T I V E , B U T D E A T H C U T S E F F I C I E N C Y . S M O K E R S A R ....snip.... H C U T S E F F I C I E N C Y .
s m o k e r s a r e p r o d u c t i v e , b u t d e a t h c u t s... s m o k e r s a r ....snip.... b u t d e a t h c u t s...
s m o k e r s a r e p r o d u c t i v e , b u t . . . s m o k e r s a r e p r o d u c t i v e , b u t . . .
s m o k e r s a r e p. . . s m o k e r s a r e p. . .
]]> ]]>

View File

@@ -67,12 +67,13 @@ Cold Wave Linked to Temperatures.
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.count.paragraphs">count_paragraphs</link>, <para>
<link linkend="language.modifier.count.sentences">count_sentences</link> and See also <link linkend="language.modifier.count.paragraphs">count_paragraphs</link>,
<link linkend="language.modifier.count.words">count_words</link> <link linkend="language.modifier.count.sentences">count_sentences</link> and
<link linkend="language.modifier.count.words">count_words</link>.
</para> </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:
mode: sgml mode: sgml
@@ -92,4 +93,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -38,12 +38,13 @@ Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.count.characters">count_characters</link>, <para>
<link linkend="language.modifier.count.sentences">count_sentences</link> and See also <link linkend="language.modifier.count.characters">count_characters</link>,
<link linkend="language.modifier.count.words">count_words</link> <link linkend="language.modifier.count.sentences">count_sentences</link> and
<link linkend="language.modifier.count.words">count_words</link>.
</para> </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:
mode: sgml mode: sgml

View File

@@ -37,12 +37,13 @@ Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.count.characters">count_characters</link>, <para>
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and See also <link linkend="language.modifier.count.characters">count_characters</link>,
<link linkend="language.modifier.count.words">count_words</link> <link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and
<link linkend="language.modifier.count.words">count_words</link>.
</para> </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:
mode: sgml mode: sgml
@@ -62,4 +63,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -37,13 +37,13 @@ Dealers Will Hear Car Talk at Noon.
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.count.characters">count_characters</link>, <para>
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and See also <link linkend="language.modifier.count.characters">count_characters</link>,
<link linkend="language.modifier.count.sentences">count_sentences</link> <link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and
<link linkend="language.modifier.count.sentences">count_sentences</link>.
</para> </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:
mode: sgml mode: sgml
@@ -63,4 +63,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -211,8 +211,13 @@ Monday, February 5, 2001
</para> </para>
</note> </note>
</para> </para>
<para>See also <link linkend="language.variables.smarty.now">$smarty.now</link>, <link linkend="language.function.html.select.date">{html_select_date}</link> and <link linkend="tips.dates">date tips</link></para> <para>
</sect1> See also <link linkend="language.variables.smarty.now">$smarty.now</link>,
<link linkend="language.function.html.select.date">{html_select_date}</link>
and <link linkend="tips.dates">date tips</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -232,4 +237,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -67,9 +67,12 @@ no title
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="tips.default.var.handling">Default Variable Handling</link> and <link linkend="tips.blank.var.handling">Blank Variable Handling</link></para> <para>
See also <link linkend="tips.default.var.handling">Default Variable Handling</link>
</sect1> and <link linkend="tips.blank.var.handling">Blank Variable Handling</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -89,4 +92,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -81,7 +81,8 @@ $smarty->display('index.tpl');
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.escaping">Escaping Smarty Parsing</link> and <link linkend="tips.obfuscating.email">Obfuscating E-mail Addresses</link>. See also <link linkend="language.escaping">Escaping Smarty Parsing</link>
and <link linkend="tips.obfuscating.email">Obfuscating E-mail Addresses</link>.
</para> </para>
</sect1> </sect1>

View File

@@ -95,7 +95,12 @@ Statistics show that teen pregnancy drops off significantly after 25.
]]> ]]>
</screen> </screen>
</example> </example>
</sect1> <para>
See also <link linkend="language.modifier.strip">strip</link>
and <link linkend="language.modifier.spacify">spacify</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -115,4 +120,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -4,7 +4,8 @@
<title>nl2br</title> <title>nl2br</title>
<para> <para>
All linebreaks will be converted to &lt;br /&gt; tags in the given All linebreaks will be converted to &lt;br /&gt; tags in the given
variable. This is equivalent to the PHP <ulink url="&url.php-manual;nl2br">nl2br()</ulink> function. variable. This is equivalent to the PHP
<ulink url="&url.php-manual;nl2br">nl2br()</ulink> function.
</para> </para>
<example> <example>
<title>nl2br</title> <title>nl2br</title>
@@ -36,8 +37,13 @@ Sun or rain expected<br />today, dark tonight
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.wordwrap">word_wrap</link>, <link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and <link linkend="language.modifier.count.sentences">count_sentences</link></para> <para>
</sect1> See also <link linkend="language.modifier.wordwrap">word_wrap</link>,
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link>
and <link linkend="language.modifier.count.sentences">count_sentences</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -57,4 +63,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -38,7 +38,8 @@
</informaltable> </informaltable>
<para> <para>
A regular expression search and replace on a variable. Use the A regular expression search and replace on a variable. Use the
syntax for preg_replace() from the PHP manual. syntax for <ulink
url="&url.php-manual;preg_replace">preg_replace()</ulink> from the PHP manual.
</para> </para>
<example> <example>
<title>regex_replace</title> <title>regex_replace</title>
@@ -75,7 +76,12 @@ Infertility unlikely to be passed on, experts say.
]]> ]]>
</screen> </screen>
</example> </example>
</sect1> <para>
See also <link linkend="language.modifier.replace">replace</link>
and <link linkend="language.modifier.escape">escape</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -95,4 +101,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -37,7 +37,8 @@
</tgroup> </tgroup>
</informaltable> </informaltable>
<para> <para>
A simple search and replace on a variable. A simple search and replace on a variable. This is equivalent to the PHP
<ulink url="&url.php-manual;str_replace">str_replace()</ulink> function.
</para> </para>
<example> <example>
<title>replace</title> <title>replace</title>
@@ -73,7 +74,12 @@ Child's Stool Great for Use in Garden.
]]> ]]>
</screen> </screen>
</example> </example>
</sect1> <para>
See also <link linkend="language.modifier.regex.replace">regex_replace</link>
and <link linkend="language.modifier.escape">escape</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -93,4 +99,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -61,12 +61,17 @@ $smarty->display('index.tpl');
<screen> <screen>
<![CDATA[ <![CDATA[
Something Went Wrong in Jet Crash, Experts Say. Something Went Wrong in Jet Crash, Experts Say.
S o m e t h i n g W e n t W r o n g i n J e t C r a s h , E x p e r t s S a y . S o m e t h i n g W .... snip .... s h , E x p e r t s S a y .
S^^o^^m^^e^^t^^h^^i^^n^^g^^ ^^W^^e^^n^^t^^ ^^W^^r^^o^^n^^g^^ ^^i^^n^^ ^^J^^e^^t^^ ^^C^^r^^a^^s^^h^^,^^ ^^E^^x^^p^^e^^r^^t^^s^^ ^^S^^a^^y^^. S^^o^^m^^e^^t^^h^^i^^n^^g^^ .... snip .... ^^e^^r^^t^^s^^ ^^S^^a^^y^^.
]]> ]]>
</screen> </screen>
</example> </example>
</sect1> <para>
See also <link linkend="language.modifier.wordwrap">wordwrap</link>
and <link linkend="language.modifier.nl2br">nl2br</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -86,4 +91,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -31,7 +31,8 @@
</informaltable> </informaltable>
<para> <para>
This is a way to format strings, such as decimal numbers and such. This is a way to format strings, such as decimal numbers and such.
Use the syntax for sprintf for the formatting. Use the syntax for <ulink url="&url.php-manual;sprintf">sprintf</ulink>
for the formatting.
</para> </para>
<example> <example>
<title>string_format</title> <title>string_format</title>
@@ -67,7 +68,11 @@ $smarty->display('index.tpl');
]]> ]]>
</screen> </screen>
</example> </example>
</sect1> <para>
See also <link linkend="language.modifier.date.format">date_format</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -87,4 +92,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -51,7 +51,8 @@
to wrap the text to the next line (default is carriage return \n). to wrap the text to the next line (default is carriage return \n).
By default, wordwrap will attempt to wrap at a word boundary. If By default, wordwrap will attempt to wrap at a word boundary. If
you want to cut off at the exact character length, pass the optional you want to cut off at the exact character length, pass the optional
third parameter of true. third parameter of true. This is equivalent to the PHP <ulink
url="&url.php-manual;wordwrap">wordwrap()</ulink> function.
</para> </para>
<example> <example>
<title>wordwrap</title> <title>wordwrap</title>
@@ -108,8 +109,11 @@ years.
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.nl2br">nl2br</link></para> <para>
</sect1> See also <link linkend="language.modifier.nl2br">nl2br</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -129,4 +133,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->

View File

@@ -1,45 +1,43 @@
<?xml version="1.0" encoding="iso-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ --> <!-- $Revision$ -->
<sect1 id="language.assigned.variables"> <sect1 id="language.assigned.variables">
<title>Variables assigned from PHP</title> <title>Variables assigned from PHP</title>
<para> <para>
Variables that are assigned from PHP are referenced by preceding them with Variables that are assigned from PHP are referenced by preceding them with
a dollar sign <literal>$</literal>. Variables assigned from within the a dollar sign <literal>$</literal>. Variables assigned from within the
template with the <link linkend="language.function.assign">assign</link> template with the <link linkend="language.function.assign">assign</link>
function are also displayed this way. function are also displayed this way.
</para> </para>
<example> <example>
<title>assigned variables</title>
<title>assigned variables</title> <programlisting>
<programlisting>
<![CDATA[ <![CDATA[
Hello {$firstname}, glad to see you could make it. Hello {$firstname}, glad to see you could make it.
<br /> <br />
Your last login was on {$lastLoginDate}. Your last login was on {$lastLoginDate}.
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: This will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
Hello Doug, glad to see you could make it. Hello Doug, glad to see you could make it.
<br /> <br />
Your last login was on January 11th, 2001. Your last login was on January 11th, 2001.
]]> ]]>
</screen> </screen>
</example> </example>
<sect2 id="language.variables.assoc.arrays">
<sect2 id="language.variables.assoc.arrays"> <title>Associative arrays</title>
<title>Associative arrays</title> <para>
<para> You can also reference associative array variables that are
You can also reference associative array variables that are assigned from PHP by specifying the key after the '.' (period)
assigned from PHP by specifying the key after the '.' (period) symbol.
symbol. </para>
</para> <example>
<example> <title>accessing associative array variables</title>
<title>accessing associative array variables</title> <programlisting role="php">
<programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty = new Smarty; $smarty = new Smarty;
@@ -51,11 +49,11 @@ $smarty->assign('Contacts',
$smarty->display('index.tpl'); $smarty->display('index.tpl');
?> ?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where the content of index.tpl is: where the content of index.tpl is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{$Contacts.fax}<br /> {$Contacts.fax}<br />
{$Contacts.email}<br /> {$Contacts.email}<br />
@@ -63,29 +61,29 @@ $smarty->display('index.tpl');
{$Contacts.phone.home}<br /> {$Contacts.phone.home}<br />
{$Contacts.phone.cell}<br /> {$Contacts.phone.cell}<br />
]]> ]]>
</programlisting> </programlisting>
<para> <para>
this will output: this will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
555-222-9876<br /> 555-222-9876<br />
zaphod@slartibartfast.com<br /> zaphod@slartibartfast.com<br />
555-444-3333<br /> 555-444-3333<br />
555-111-1234<br /> 555-111-1234<br />
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
<sect2 id="language.variables.array.indexes"> <sect2 id="language.variables.array.indexes">
<title>Array indexes</title> <title>Array indexes</title>
<para> <para>
You can reference arrays by their index, much like native PHP You can reference arrays by their index, much like native PHP
syntax. syntax.
</para> </para>
<example> <example>
<title>accessing arrays by index</title> <title>accessing arrays by index</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
@@ -99,11 +97,11 @@ $smarty->display('index.tpl');
?> ?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where index.tpl is: where index.tpl is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{$Contacts[0]}<br /> {$Contacts[0]}<br />
{$Contacts[1]}<br /> {$Contacts[1]}<br />
@@ -111,46 +109,48 @@ $smarty->display('index.tpl');
{$Contacts[2][0]}<br /> {$Contacts[2][0]}<br />
{$Contacts[2][1]}<br /> {$Contacts[2][1]}<br />
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: This will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
555-222-9876<br /> 555-222-9876<br />
zaphod@slartibartfast.com<br /> zaphod@slartibartfast.com<br />
555-444-3333<br /> 555-444-3333<br />
555-111-1234<br /> 555-111-1234<br />
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
<sect2 id="language.variables.objects"> <sect2 id="language.variables.objects">
<title>Objects</title> <title>Objects</title>
<para> <para>
Properties of objects assigned from PHP can be referenced Properties of <link linkend="advanced.features.objects">objects</link>
by specifying the property name after the '-&gt;' symbol. assigned from PHP can be referenced by specifying the property
</para> name after the '-&gt;' symbol.
<example> </para>
<title>accessing object properties</title> <example>
<programlisting> <title>accessing object properties</title>
<programlisting>
<![CDATA[ <![CDATA[
name: {$person->name}<br /> name: {$person->name}<br />
email: {$person->email}<br /> email: {$person->email}<br />
]]> ]]>
</programlisting> </programlisting>
<para> <para>
this will output: this will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
name: Zaphod Beeblebrox<br /> name: Zaphod Beeblebrox<br />
email: zaphod@slartibartfast.com<br /> email: zaphod@slartibartfast.com<br />
]]> ]]>
</screen> </screen>
</example> </example>
</sect2> </sect2>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
@@ -170,4 +170,4 @@ End:
vim600: syn=xml fen fdm=syntax fdl=2 si vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml vim: et tw=78 syn=sgml
vi: ts=1 sw=1 vi: ts=1 sw=1
--> -->