Tidying up some markup

This commit is contained in:
pete_morgan
2006-09-26 19:28:45 +00:00
parent 20742cea79
commit 046eff51f8
24 changed files with 329 additions and 243 deletions

View File

@@ -3,20 +3,20 @@
<chapter id="language.builtin.functions"> <chapter id="language.builtin.functions">
<title>Built-in Functions</title> <title>Built-in Functions</title>
<para> <para>
Smarty comes with several built-in functions. These built-in functions Smarty comes with several built-in functions. These built-in functions
are the integral part of the smarty template engine. You cannot create your own are the integral part of the smarty template engine. You cannot create your own
<link linkend="language.custom.functions">custom functions</link> <link linkend="language.custom.functions">custom functions</link>
with the same name; and you should not need to with the same name; and you should not need to
modify the built-in functions. modify the built-in functions.
</para> </para>
<para> <para>
A few on these functions have an <emphasis role="bold">assign</emphasis> A few on these functions have an <parameter>assign</parameter>
attribute which collects attribute which collects the result the function to a named
the result the function to a named variable within a template instead of being output; variable within a template instead of being output;
much like the <link linkend="language.function.assign">{assign}</link> function. much like the <link linkend="language.function.assign">
<varname>{assign}</varname></link> function.
</para> </para>
&designers.language-builtin-functions.language-function-capture; &designers.language-builtin-functions.language-function-capture;
&designers.language-builtin-functions.language-function-config-load; &designers.language-builtin-functions.language-function-config-load;
&designers.language-builtin-functions.language-function-foreach; &designers.language-builtin-functions.language-function-foreach;
@@ -29,7 +29,7 @@
&designers.language-builtin-functions.language-function-php; &designers.language-builtin-functions.language-function-php;
&designers.language-builtin-functions.language-function-section; &designers.language-builtin-functions.language-function-section;
&designers.language-builtin-functions.language-function-strip; &designers.language-builtin-functions.language-function-strip;
</chapter> </chapter>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:

View File

@@ -194,13 +194,13 @@ $smarty->assign('contact',$db->getRow($sql));
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where an example template would be Where a template could be as follows. Note the use of the truncate modifier.
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
<select name="type_id"> <select name="type_id">
<option value='null'>-- none --</option> <option value='null'>-- none --</option>
{html_options options=$contact_types selected=$contact.type_id} {html_options options=$contact_types|truncate:20 selected=$contact.type_id}
</select> </select>
]]> ]]>
</programlisting> </programlisting>

View File

@@ -3,17 +3,20 @@
<chapter id="language.modifiers"> <chapter id="language.modifiers">
<title>Variable Modifiers</title> <title>Variable Modifiers</title>
<para> <para>
Variable modifiers can be applied to Variable modifiers can be applied to
<link linkend="language.syntax.variables">variables</link>, <link linkend="language.syntax.variables">variables</link>,
<link linkend="language.custom.functions">custom functions</link> or strings. To <link linkend="language.custom.functions">custom functions</link> or strings.
apply a modifier, specify the value followed by a <literal>|</literal> To apply a modifier, specify the value followed by a <literal>|</literal>
(pipe) and the modifier name. A modifier may accept additional parameters (pipe) and the modifier name. A modifier may accept additional parameters
that affect its behavior. These parameters follow the modifer name and are that affect its behavior. These parameters follow the modifer name and are
separated by a <literal>:</literal> (colon). Additionally separated by a <literal>:</literal> (colon). Also,
all php-functions can be used as modifiers implicitly; more below. <emphasis>all php-functions can be used as modifiers implicitly</emphasis>
(more below) and modifiers can be
<link linkend="language.combining.modifiers">combined</link>.
.
</para> </para>
<example> <example>
<title>modifier examples</title> <title>Modifier examples</title>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{* apply modifier to a variable *} {* apply modifier to a variable *}
@@ -53,43 +56,61 @@
]]> ]]>
</programlisting> </programlisting>
</example> </example>
<para> <itemizedlist>
<listitem><para>
If you apply a modifier to an array variable instead of a single value variable, If you apply a modifier to an array variable instead of a single value variable,
the modifier will be applied to every value in that array. If you really want the modifier will be applied to every value in that array. If you really want
the modifier to work on an entire array as a value, you must prepend the the modifier to work on an entire array as a value, you must prepend the
modifier name with an <literal>@</literal> symbol like so: modifier name with a <literal>@</literal> symbol.
<literal>{$articleTitle|@count}</literal> (this will print out the number of <note>
elements in the $articleTitle array.) <title>Example</title>
</para> <para><literal>{$articleTitle|@count}</literal> - will print out the number of
<para> elements in the <parameter>$articleTitle</parameter> array using the php
<ulink url="&url.php-manual;count"><varname>count()</varname></ulink>
function as a modifier.
</para></note>
</para> </listitem>
<listitem><para>
Modifiers are autoloaded from the <link Modifiers are autoloaded from the <link
linkend="variable.plugins.dir">$plugins_dir</link> linkend="variable.plugins.dir"><parameter>$plugins_dir</parameter></link>
or can be registered explicitely with <link or can be registered explicitely with the <link
linkend="api.register.modifier">register_modifier()</link>; linkend="api.register.modifier"><varname>register_modifier()</varname></link>
this is useful for sharing a function in a php script and smarty templates. function. The later is useful for sharing a function between
</para> php scripts and smarty templates.
</para></listitem>
<para>
All php-functions can be used as modifiers implicitly. (The <listitem><para>
<literal>@count</literal> example above actually uses php's All php-functions can be used as modifiers implicitly, as demonstrated in the
count() function and not a smarty-modifier). Using php-functions example above.
as modifiers has two little pitfalls: First; sometimes the order However, using php-functions as modifiers has two little pitfalls:
of the function-parameters is not the desirable one <itemizedlist>
(<literal>{"%2.f"|sprintf:$float}</literal> actually works, but <listitem><para>First - sometimes the order of the function-parameters is
asks for the more intuitive. For example:<literal>{$float|string_format:"%2.f"}</literal> not the desirable one. Formatting <literal>$foo</literal> with
that is provided by the Smarty distribution). Second; with <link <literal>{"%2.f"|sprintf:$foo}</literal> actually
linkend="variable.security">$security</link> enabled all works, but asks for the more intuitive, like
php-functions that are to be used as modifiers have to be <literal>{$foo|string_format:"%2.f"}</literal> that is provided by
declared trusted in the <link linkend="variable.security.settings"> the Smarty distribution.
$security_settings['MODIFIER_FUNCS']</link> array. </para></listitem>
</para> <listitem><para>
Secondly - if <link linkend="variable.security">
<parameter>$security</parameter></link> is enabled, all php-functions that
are to be used as modifiers have to be declared trusted in the
<literal>MODIFIER_FUNCS</literal> element of the
<link linkend="variable.security.settings">
<parameter>$security_settings</parameter></link> array.
</para></listitem>
</itemizedlist>
</para></listitem>
</itemizedlist>
<para> <para>
See also See also
<link linkend="api.register.modifier">register_modifier()</link>, <link linkend="api.register.modifier"><varname>register_modifier()</varname></link>,
<link linkend="api.register.function">register_function()</link>, <link linkend="language.combining.modifiers">combining modifiers</link>.
<link linkend="plugins">extending Smarty with plugins</link>
and and
<link linkend="plugins.modifiers">modifiers</link>, <link linkend="plugins">extending smarty with plugins</link>
</para> </para>
&designers.language-modifiers.language-modifier-capitalize; &designers.language-modifiers.language-modifier-capitalize;
@@ -113,7 +134,7 @@
&designers.language-modifiers.language-modifier-truncate; &designers.language-modifiers.language-modifier-truncate;
&designers.language-modifiers.language-modifier-upper; &designers.language-modifiers.language-modifier-upper;
&designers.language-modifiers.language-modifier-wordwrap; &designers.language-modifiers.language-modifier-wordwrap;
</chapter> </chapter>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -4,6 +4,8 @@
<title>capitalize</title> <title>capitalize</title>
<para> <para>
This is used to capitalize the first letter of all words in a variable. This is used to capitalize the first letter of all words in a variable.
This is similar to the PHP <ulink url="&url.php-manual;ucfirst">
<varname>ucfirst()</varname></ulink> function.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
@@ -26,13 +28,13 @@
<entry>1</entry> <entry>1</entry>
<entry>boolean</entry> <entry>boolean</entry>
<entry>No</entry> <entry>No</entry>
<entry>false</entry> <entry>&false;</entry>
<entry>This determines whether or not words with <entry>This determines whether or not words with
digits will be uppercased</entry> digits will be uppercased</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
</informaltable> </informaltable>
<example> <example>
<title>capitalize</title> <title>capitalize</title>
<programlisting role="php"> <programlisting role="php">
@@ -45,7 +47,7 @@ $smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Where template is: Where the template is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -55,7 +57,7 @@ $smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -65,9 +67,11 @@ Next X-Men Film, X3, Delayed.
]]> ]]>
</screen> </screen>
</example> </example>
<para>See also <link linkend="language.modifier.lower">lower</link> <para>See also
<link linkend="language.modifier.lower"><varname>lower</varname></link>
and and
<link linkend="language.modifier.upper">upper</link> </para> <link linkend="language.modifier.upper"><varname>upper</varname></link>
</para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:

View File

@@ -37,7 +37,7 @@
<title>cat</title> <title>cat</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', "Psychics predict world didn't end"); $smarty->assign('articleTitle', "Psychics predict world didn't end");
@@ -49,14 +49,14 @@ $smarty->assign('articleTitle', "Psychics predict world didn't end");
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{$articleTitle|cat:" yesterday."} {$articleTitle|cat:' yesterday.'}
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
Psychics predict world didn't end yesterday. Psychics predict world didn't end yesterday.
]]> ]]>
</screen> </screen>

View File

@@ -26,7 +26,7 @@
<entry>1</entry> <entry>1</entry>
<entry>boolean</entry> <entry>boolean</entry>
<entry>No</entry> <entry>No</entry>
<entry>false</entry> <entry>&false;</entry>
<entry>This determines whether or not to include <entry>This determines whether or not to include
whitespace characters in the count.</entry> whitespace characters in the count.</entry>
</row> </row>
@@ -56,7 +56,7 @@ $smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -68,9 +68,9 @@ Cold Wave Linked to Temperatures.
</example> </example>
<para> <para>
See also See also
<link linkend="language.modifier.count.words">count_words</link>, <link linkend="language.modifier.count.words"><varname>count_words</varname></link>,
<link linkend="language.modifier.count.sentences">count_sentences</link> and <link linkend="language.modifier.count.sentences"><varname>count_sentences</varname></link> and
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link>. <link linkend="language.modifier.count.paragraphs"><varname>count_paragraphs</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -29,21 +29,23 @@ $smarty->assign('articleTitle',
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
War Dims Hope for Peace. Child's Death Ruins Couple's Holiday. War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation. Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
2 2
]]> ]]>
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.count.characters">count_characters</link>, See also
<link linkend="language.modifier.count.sentences">count_sentences</link> and <link linkend="language.modifier.count.characters"><varname>count_characters</varname></link>,
<link linkend="language.modifier.count.words">count_words</link>. <link linkend="language.modifier.count.sentences"><varname>count_sentences</varname></link>
and
<link linkend="language.modifier.count.words"><varname>count_words</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -10,7 +10,7 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', $smarty->assign('articleTitle',
'Two Soviet Ships Collide - One Dies. 'Two Soviet Ships Collide - One Dies.
Enraged Cow Injures Farmer with Axe.' Enraged Cow Injures Farmer with Axe.'
@@ -29,7 +29,7 @@ $smarty->assign('articleTitle',
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -39,9 +39,11 @@ Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.count.characters">count_characters</link>, See also
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and <link linkend="language.modifier.count.characters"><varname>count_characters</varname></link>,
<link linkend="language.modifier.count.words">count_words</link>. <link linkend="language.modifier.count.paragraphs"><varname>count_paragraphs</varname></link>
and
<link linkend="language.modifier.count.words"><varname>count_words</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -10,7 +10,7 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.'); $smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
?> ?>
@@ -36,10 +36,12 @@ Dealers Will Hear Car Talk at Noon.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.count.characters">count_characters</link>, See also
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and <link linkend="language.modifier.count.characters"><varname>count_characters</varname></link>,
<link linkend="language.modifier.count.sentences">count_sentences</link>. <link linkend="language.modifier.count.paragraphs"><varname>count_paragraphs</varname></link>
</para> and
<link linkend="language.modifier.count.sentences"><varname>count_sentences</varname></link>.
</para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -4,17 +4,18 @@
<title>date_format</title> <title>date_format</title>
<para> <para>
This formats a date and time into the given This formats a date and time into the given
<ulink url="&url.php-manual;strftime">strftime()</ulink> format. <ulink url="&url.php-manual;strftime"><varname>strftime()</varname></ulink> format.
Dates can be passed to Smarty as unix Dates can be passed to Smarty as unix
<ulink url="&url.php-manual;function.time">timestamps</ulink>, mysql timestamps <ulink url="&url.php-manual;function.time">timestamps</ulink>, mysql timestamps
or any string made up of month day year, parsable by or any string made up of month day year, parsable by php's
<ulink url="&url.php-manual;strtotime">strtotime()</ulink>. <ulink url="&url.php-manual;strtotime"><varname>strtotime()</varname></ulink>.
Designers can then use date_format to have complete control of the Designers can then use <varname>date_format</varname> to have complete control of the
formatting of the date. If the date passed to formatting of the date. If the date passed to
<command>date_format</command> is empty and a second parameter is passed, <varname>date_format</varname> is empty and a second parameter is passed,
that will be used as the date to format. that will be used as the date to format.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -53,20 +54,32 @@
<para> <para>
<note> <note>
<para> <para>
Since Smarty-2.6.10 numeric values passed to date_format are Since Smarty-2.6.10 numeric values passed to <varname>date_format</varname> are
<emphasis>always</emphasis> (except for mysql timestamps, see <emphasis>always</emphasis> (except for mysql timestamps, see
below) interpreted as a unix timestamp. below) interpreted as a unix timestamp.
</para> </para>
<para> <para>
Before Smarty-2.6.10 numeric strings that where also parsable by Before Smarty-2.6.10 numeric strings that where also parsable by
strtotime() in php (like "YYYYMMDD") where sometimes - depending <varname>strtotime()</varname> in php (like <literal>YYYYMMDD</literal>)
on the underlying implementation of strtotime() - interpreted as where sometimes (depending on the underlying implementation of
date strings and not as timestamps. <varname>strtotime()</varname>) interpreted as
date strings and NOT as timestamps.
</para> </para>
<para> <para>
The only exception are mysql timestamps: They are also numeric The only exception are mysql timestamps: They are also numeric
only and 14 characters long ("YYYYMMDDHHMMSS"). Mysql timestamps only and 14 characters long (<literal>YYYYMMDDHHMMSS</literal>),
have precedence over unix timestamps. mysql timestamps have precedence over unix timestamps.
</para>
</note>
<note>
<title>Programmers note</title>
<para>
<varname>date_format</varname> is essentially a wrapper to PHP's
<ulink url="&url.php-manual;strftime"><varname>strftime()</varname></ulink> function.
You may have more or less conversion specifiers available depending
on your system's <ulink url="&url.php-manual;strftime"><varname>strftime()</varname></ulink>
function where PHP was compiled. Check your
system's manpage for a full list of valid specifiers.
</para> </para>
</note> </note>
</para> </para>
@@ -78,14 +91,15 @@
$config['date'] = '%I:%M %p'; $config['date'] = '%I:%M %p';
$config['time'] = '%H:%M:%S'; $config['time'] = '%H:%M:%S';
$smarty->assign('config',$config); $smarty->assign('config', $config);
$smarty->assign('yesterday', strtotime('-1 day')); $smarty->assign('yesterday', strtotime('-1 day'));
?> ?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Where template is (uses <link linkend="language.variables.smarty.now">$smarty.now</link>): This template uses <link linkend="language.variables.smarty.now">
<parameter>$smarty.now</parameter></link> to get the current time:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -98,21 +112,22 @@ $smarty->assign('yesterday', strtotime('-1 day'));
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: This above will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
Feb 6, 2001 Jan 1, 2022
02/06/01 01/01/22
02:33 pm 02:33 pm
Feb 5, 2001 Dec 31, 2021
Monday, February 5, 2001 Monday, December 1, 2021
14:33:00 14:33:00
]]> ]]>
</screen> </screen>
</example> </example>
<para> <para>
<command>date_format</command> conversion specifiers:
<command>date_format</command> conversion specifiers:
<itemizedlist> <itemizedlist>
<listitem><para> <listitem><para>
%a - abbreviated weekday name according to the current locale %a - abbreviated weekday name according to the current locale
@@ -237,23 +252,13 @@ Monday, February 5, 2001
%% - a literal `%' character %% - a literal `%' character
</para></listitem> </para></listitem>
</itemizedlist> </itemizedlist>
<note>
<title>Programmers note</title>
<para>
<command>date_format</command> is essentially a wrapper to PHP's
<ulink url="&url.php-manual;strftime">strftime()</ulink> function.
You may have more or less conversion specifiers available depending
on your system's <ulink url="&url.php-manual;strftime">strftime()</ulink>
function where PHP was compiled. Check your
system's manpage for a full list of valid specifiers.
</para>
</note>
</para> </para>
<para> <para>
See also <link linkend="language.variables.smarty.now">$smarty.now</link>, See also <link linkend="language.variables.smarty.now"><parameter>$smarty.now</parameter></link>,
<ulink url="&url.php-manual;strftime">php function strftime()</ulink>, <ulink url="&url.php-manual;strftime"><varname>strftime()</varname></ulink>,
<link linkend="language.function.html.select.date">{html_select_date}</link> <link linkend="language.function.html.select.date"><varname>{html_select_date}</varname></link>
and <link linkend="tips.dates">date tips</link>. and the <link linkend="tips.dates">date tips</link> page.
</para> </para>
</sect1> </sect1>

View File

@@ -5,17 +5,19 @@
<para> <para>
This is used to set a default value for a variable. If the variable This is used to set a default value for a variable. If the variable
is unset or an empty string, the given default value is printed instead. is unset or an empty string, the given default value is printed instead.
Default takes one argument. Default takes the one argument.
</para> </para>
<para> <para>
<note> <note>
<para> <para>
With error_reporting(E_ALL), undeclared variables will always throw an error within the template. This function With <ulink url="&url.php-manual;error_reporting">
is useful for replacing null or zero length strings. <varname>error_reporting(E_ALL)</varname></ulink>,
undeclared variables will always throw an error within the template.
This function is useful for replacing null or zero length strings.
</para> </para>
</note> </note>
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -52,7 +54,7 @@
<?php <?php
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.'); $smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
$smarty->assign('email',''); $smarty->assign('email', '');
?> ?>
]]> ]]>
@@ -68,7 +70,7 @@ $smarty->assign('email','');
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -79,8 +81,10 @@ No email address available
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="tips.default.var.handling">Default Variable Handling</link> See also the
and <link linkend="tips.blank.var.handling">Blank Variable Handling</link>. <link linkend="tips.default.var.handling">default variable handling</link>
and the
<link linkend="tips.blank.var.handling">blank variable handling</link> pages.
</para> </para>
</sect1> </sect1>

View File

@@ -3,11 +3,13 @@
<sect1 id="language.modifier.escape"> <sect1 id="language.modifier.escape">
<title>escape</title> <title>escape</title>
<para> <para>
This is used to encode/escape a variable to html url single quotes, hex escape, hexentity, javascript and mail escape. This is used to encode/escape a variable to <literal>html</literal>,
By default its html <literal>url</literal>, <literal>single quotes</literal>,
escaped. <literal>hex</literal>, <literal>hexentity</literal>,
<literal>javascript</literal> and <literal>mail</literal>.
By default its <literal>html</literal> escaped.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="6"> <tgroup cols="6">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -31,7 +33,12 @@
<entry>1</entry> <entry>1</entry>
<entry>string</entry> <entry>string</entry>
<entry>No</entry> <entry>No</entry>
<entry><literal>html</literal>,<literal>htmlall</literal>,<literal>url</literal>,<literal>urlpathinfo</literal>,<literal>quotes</literal>,<literal>hex</literal>,<literal>hexentity</literal>,<literal>javascript</literal>,<literal>mail</literal></entry> <entry><literal>html</literal>, <literal>htmlall</literal>,
<literal>url</literal>,
<literal>urlpathinfo</literal>, <literal>quotes</literal>,
<literal>hex</literal>, <literal>hexentity</literal>,
<literal>javascript</literal>, <literal>mail</literal>
</entry>
<entry><literal>html</literal></entry> <entry><literal>html</literal></entry>
<entry>This is the escape format to use.</entry> <entry>This is the escape format to use.</entry>
</row> </row>
@@ -39,8 +46,11 @@
<entry>2</entry> <entry>2</entry>
<entry>string</entry> <entry>string</entry>
<entry>No</entry> <entry>No</entry>
<entry><literal>ISO-8859-1</literal>, <literal>UTF-8</literal>, ... any character set supported by <ulink url="&url.php-manual;htmlentities">htmlentities()</ulink> <entry><literal>ISO-8859-1</literal>, <literal>UTF-8</literal>,
</entry> and any character set supported by
<ulink url="&url.php-manual;htmlentities">
<varname>htmlentities()</varname></ulink>
</entry>
<entry><literal>ISO-8859-1</literal></entry> <entry><literal>ISO-8859-1</literal></entry>
<entry>The character set encoding passed to htmlentities() et. al.</entry> <entry>The character set encoding passed to htmlentities() et. al.</entry>
</row> </row>
@@ -53,11 +63,12 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', $smarty->assign('articleTitle',
"'Stiff Opposition Expected to Casketless Funeral Plan'" "'Stiff Opposition Expected to Casketless Funeral Plan'"
); );
$smarty->assign('EmailAddress','smarty@example.com'); $smarty->assign('EmailAddress','smarty@example.com');
?> ?>
]]> ]]>
</programlisting> </programlisting>
@@ -78,7 +89,7 @@ $smarty->assign('EmailAddress','smarty@example.com');
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -93,29 +104,37 @@ smarty [AT] example [DOT] com
mail [AT] example [DOT] com mail [AT] example [DOT] com
]]> ]]>
</screen> </screen>
<para>Note that native PHP functions can be used as modifiers so this will work</para> </example>
<example>
<title>Other examples</title>
<para>PHP functions can be used as modifiers,
<link linkend="variable.security">
<varname>$security</varname></link> permitting.
</para>
<screen> <screen>
<![CDATA[ <![CDATA[
{* rewind get var registers the current location *} {* the "rewind" paramater registers the current location *}
<a href="{$SCRIPT_NAME}?page=foo&rewind={$smarty.server.REQUEST_URI|urlencode}">click here</a> <a href="{$SCRIPT_NAME}?page=foo&rewind={$smarty.server.REQUEST_URI|urlencode}">click here</a>
]]> ]]>
</screen> </screen>
<para>And this is very useful for emails but see also <para>This snippet is useful for emails, but see also
<link linkend="language.function.mailto">{mailto}</link></para> <link linkend="language.function.mailto">
<varname>{mailto}</varname></link></para>
<screen> <screen>
<![CDATA[ <![CDATA[
{* email address mangled *} {* email address mangled *}
<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a> <a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>
]]> ]]>
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.escaping">Escaping Smarty Parsing</link>, See also
<link linkend="language.function.mailto">{mailto}</link> <link linkend="language.escaping">escaping smarty parsing</link>,
and <link linkend="tips.obfuscating.email">Obfuscating E-mail Addresses</link>. <link linkend="language.function.mailto"><varname>{mailto}</varname></link>
and the
<link linkend="tips.obfuscating.email">obfuscating email addresses</link> page.
</para> </para>
</sect1> </sect1>

View File

@@ -3,12 +3,12 @@
<sect1 id="language.modifier.indent"> <sect1 id="language.modifier.indent">
<title>indent</title> <title>indent</title>
<para> <para>
This indents a string at each line, default is 4. As This indents a string on each line, default is 4. As
an optional parameter, you can specify the number of characters to an optional parameter, you can specify the number of characters to
indent. As an optional second parameter, you can specify the indent. As an optional second parameter, you can specify the
character to use to indent with. (Use "\t" for tabs.) character to use to indent with eg use <literal>"\t"</literal> for a tab.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -50,14 +50,12 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', $smarty->assign('articleTitle',
'NJ judge to rule on nude beach. 'NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight. Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.' Statistics show that teen pregnancy drops off significantly after 25.'
); );
?> ?>
]]> ]]>
</programlisting> </programlisting>
@@ -76,7 +74,7 @@ Statistics show that teen pregnancy drops off significantly after 25.'
]]> ]]>
</programlisting> </programlisting>
<para> <para>
this will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -99,9 +97,11 @@ Statistics show that teen pregnancy drops off significantly after 25.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.strip">strip</link>, See also
<link linkend="language.modifier.wordwrap">wordwrap</link> <link linkend="language.modifier.strip"><varname>strip</varname></link>,
and <link linkend="language.modifier.spacify">spacify</link>. <link linkend="language.modifier.wordwrap"><varname>wordwrap</varname></link>
and
<link linkend="language.modifier.spacify"><varname>spacify</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -4,23 +4,24 @@
<title>lower</title> <title>lower</title>
<para> <para>
This is used to lowercase a variable. This is equivalent to the PHP This is used to lowercase a variable. This is equivalent to the PHP
<ulink url="&url.php-manual;strtolower">strtolower()</ulink> function. <ulink url="&url.php-manual;strtolower">
<varname>strtolower()</varname></ulink> function.
</para> </para>
<example> <example>
<title>lower</title> <title>lower</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.'); $smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
?> ?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Where template is: Where template is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{$articleTitle} {$articleTitle}
{$articleTitle|lower} {$articleTitle|lower}
@@ -37,8 +38,10 @@ two convicts evade noose, jury hung.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.upper">upper</link> and See also
<link linkend="language.modifier.capitalize">Capitalize</link>. <link linkend="language.modifier.upper"><varname>upper</varname></link>
and
<link linkend="language.modifier.capitalize"><varname>capitalize</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -3,9 +3,10 @@
<sect1 id="language.modifier.nl2br"> <sect1 id="language.modifier.nl2br">
<title>nl2br</title> <title>nl2br</title>
<para> <para>
All linebreaks will be converted to &lt;br /&gt; tags in the given All <literal>"\n"</literal> line breaks will be converted to html
variable. This is equivalent to the PHP <literal>&lt;br /&gt;</literal> tags in the given variable.
<ulink url="&url.php-manual;nl2br">nl2br()</ulink> function. This is equivalent to the PHP's <ulink url="&url.php-manual;nl2br">
<varname>nl2br()</varname></ulink> function.
</para> </para>
<example> <example>
<title>nl2br</title> <title>nl2br</title>
@@ -29,7 +30,7 @@ $smarty->assign('articleTitle',
]]> ]]>
</programlisting> </programlisting>
<para> <para>
will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -38,9 +39,11 @@ Sun or rain expected<br />today, dark tonight
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.wordwrap">word_wrap</link>, See also
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> <link linkend="language.modifier.wordwrap"><varname>word_wrap</varname></link>,
and <link linkend="language.modifier.count.sentences">count_sentences</link>. <link linkend="language.modifier.count.paragraphs"><varname>count_paragraphs</varname></link>
and
<link linkend="language.modifier.count.sentences"><varname>count_sentences</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -4,10 +4,10 @@
<title>regex_replace</title> <title>regex_replace</title>
<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 <ulink <ulink url="&url.php-manual;preg_replace">
url="&url.php-manual;preg_replace">preg_replace()</ulink> from the PHP manual. <varname>preg_replace()</varname></ulink> syntax from the PHP manual.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -55,7 +55,7 @@ $smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts
]]> ]]>
</programlisting> </programlisting>
<para> <para>
Where index.tpl is: Where template is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -66,7 +66,7 @@ $smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This should output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -77,8 +77,10 @@ Infertility unlikely to be passed on, experts say.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.replace">replace</link> See also <link linkend="language.modifier.replace">
and <link linkend="language.modifier.escape">escape</link>. <varname>replace</varname></link>
and
<link linkend="language.modifier.escape"><varname>escape</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -3,10 +3,11 @@
<sect1 id="language.modifier.replace"> <sect1 id="language.modifier.replace">
<title>replace</title> <title>replace</title>
<para> <para>
A simple search and replace on a variable. This is equivalent to the PHP A simple search and replace on a variable. This is equivalent to the PHP's
<ulink url="&url.php-manual;str_replace">str_replace()</ulink> function. <ulink url="&url.php-manual;str_replace">
<varname>str_replace()</varname></ulink> function.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -64,7 +65,7 @@ $smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This should output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -75,8 +76,10 @@ Child's Stool Great for Use in Garden.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.regex.replace">regex_replace</link> See also
and <link linkend="language.modifier.escape">escape</link>. <link linkend="language.modifier.regex.replace"><varname>regex_replace</varname></link>
and
<link linkend="language.modifier.escape"><varname>escape</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -3,8 +3,9 @@
<sect1 id="language.modifier.spacify"> <sect1 id="language.modifier.spacify">
<title>spacify</title> <title>spacify</title>
<para> <para>
spacify is a way to insert a space between every character of a variable. <varname>spacify</varname> is a way to insert a space between every
You can optionally pass a different character (or string) to insert. character of a variable.
You can optionally pass a different character or string to insert.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
@@ -57,7 +58,7 @@ $smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This should output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -68,8 +69,10 @@ S^^o^^m^^e^^t^^h^^i^^n^^g^^ .... snip .... ^^e^^r^^t^^s^^ ^^S^^a^^y^^.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.wordwrap">wordwrap</link> See also
and <link linkend="language.modifier.nl2br">nl2br</link>. <link linkend="language.modifier.wordwrap"><varname>wordwrap</varname></link>
and
<link linkend="language.modifier.nl2br"><varname>nl2br</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -4,10 +4,11 @@
<title>string_format</title> <title>string_format</title>
<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 <ulink url="&url.php-manual;sprintf">sprintf()</ulink> Use the syntax for
<ulink url="&url.php-manual;sprintf"><varname>sprintf()</varname></ulink>
for the formatting. for the formatting.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -58,7 +59,7 @@ $smarty->assign('number', 23.5787446);
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This should output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -68,8 +69,10 @@ $smarty->assign('number', 23.5787446);
]]> ]]>
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.date.format">date_format</link>. See also
<link linkend="language.modifier.date.format"><varname>date_format</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -3,9 +3,10 @@
<sect1 id="language.modifier.strip.tags"> <sect1 id="language.modifier.strip.tags">
<title>strip_tags</title> <title>strip_tags</title>
<para> <para>
This strips out markup tags, basically anything between &lt; and &gt;. This strips out markup tags, basically anything between
<literal>&lt;</literal> and <literal>&gt;</literal>.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -27,8 +28,8 @@
<entry>1</entry> <entry>1</entry>
<entry>bool</entry> <entry>bool</entry>
<entry>No</entry> <entry>No</entry>
<entry>true</entry> <entry>&true;</entry>
<entry>This determines wether the tags are replaced by ' ' or by ''</entry> <entry>This determines whether the tags are replaced by ' ' or ''</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
@@ -49,17 +50,17 @@ Kidney</font> from Dad she Hasn't Seen in <b>years</b>."
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where template is: Where template is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{$articleTitle} {$articleTitle}
{$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *} {$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
{$articleTitle|strip_tags:false} {$articleTitle|strip_tags:false}
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -69,6 +70,12 @@ Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
]]> ]]>
</screen> </screen>
</example> </example>
<para>
See also
<link linkend="language.modifier.replace"><varname>replace</varname></link>
and
<link linkend="language.modifier.regex.replace"><varname>regex_replace</varname></link>.
</para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:

View File

@@ -4,13 +4,13 @@
<title>strip</title> <title>strip</title>
<para> <para>
This replaces all repeated spaces, newlines and tabs with a single This replaces all repeated spaces, newlines and tabs with a single
space, or with a supplied string. space, or with the supplied string.
</para> </para>
<note> <note>
<title>Note</title> <title>Note</title>
<para> <para>
If you want to strip blocks of template text, use the <link If you want to strip blocks of template text, use the built-in <link
linkend="language.function.strip">{strip}</link> function. linkend="language.function.strip"><varname>{strip}</varname></link> function.
</para> </para>
</note> </note>
<example> <example>
@@ -18,16 +18,13 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty = new Smarty;
$smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one."); $smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
$smarty->display('index.tpl'); $smarty->display('index.tpl');
?> ?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where template is: Where template is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -37,7 +34,7 @@ $smarty->display('index.tpl');
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -48,10 +45,12 @@ Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.
]]> ]]>
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.function.strip">{strip}</link> and See also
<link linkend="language.modifier.truncate">truncate</link>. <link linkend="language.function.strip"><varname>{strip}</varname></link>
and
<link linkend="language.modifier.truncate"><varname>truncate</varname></link>.
</para> </para>
</sect1> </sect1>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file

View File

@@ -3,15 +3,15 @@
<sect1 id="language.modifier.truncate"> <sect1 id="language.modifier.truncate">
<title>truncate</title> <title>truncate</title>
<para> <para>
This truncates a variable to a character length, default is 80. As This truncates a variable to a character length, the default is 80.
an optional second parameter, you can specify a string of text As an optional second parameter, you can specify a string of text
to display at the end if the variable was truncated. The to display at the end if the variable was truncated. The
characters in the string are included with the original truncation length. characters in the string are included with the original truncation length.
By default, truncate will attempt to cut off at a word boundary. If By default, <varname>truncate</varname> will attempt to cut off at a
you want to cut off at the exact character length, pass the optional word boundary. If you want to cut off at the exact character length,
third parameter of true. pass the optional third parameter of &true;.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -49,18 +49,19 @@
<entry>3</entry> <entry>3</entry>
<entry>boolean</entry> <entry>boolean</entry>
<entry>No</entry> <entry>No</entry>
<entry>false</entry> <entry>&false;</entry>
<entry>This determines whether or not to truncate at a <entry>This determines whether or not to truncate at a
word boundary (false), or at the exact character (true).</entry> word boundary with &false;, or at the exact character with &true;.</entry>
</row> </row>
<row> <row>
<entry>4</entry> <entry>4</entry>
<entry>boolean</entry> <entry>boolean</entry>
<entry>No</entry> <entry>No</entry>
<entry>false</entry> <entry>&false;</entry>
<entry>This determines whether the truncation happens at the end of the <entry>This determines whether the truncation happens at the end of the
string (false), or in the middle of the string (true). Note that if this string with &false;, or in the middle of the string with &true;.
setting is true, then word boundaries are ignored.</entry> Note that if this setting is &true;, then word boundaries are ignored.
</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
@@ -71,9 +72,7 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'); $smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
?> ?>
]]> ]]>
</programlisting> </programlisting>

View File

@@ -4,21 +4,20 @@
<title>upper</title> <title>upper</title>
<para> <para>
This is used to uppercase a variable. This is equivalent to the PHP This is used to uppercase a variable. This is equivalent to the PHP
<ulink url="&url.php-manual;strtoupper">strtoupper()</ulink> function. <ulink url="&url.php-manual;strtoupper">
<varname>strtoupper()</varname></ulink> function.
</para> </para>
<example> <example>
<title>upper</title> <title>upper</title>
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While."); $smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
?> ?>
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where template is: Where template is:
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
@@ -27,7 +26,7 @@ $smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a W
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -37,8 +36,10 @@ IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.lower">lower</link> and See also
<link linkend="language.modifier.capitalize">capitalize</link>. <link linkend="language.modifier.lower"><varname>lower</varname></link>
and
<link linkend="language.modifier.capitalize"><varname>capitalize</varname></link>.
</para> </para>
</sect1> </sect1>

View File

@@ -3,15 +3,18 @@
<sect1 id="language.modifier.wordwrap"> <sect1 id="language.modifier.wordwrap">
<title>wordwrap</title> <title>wordwrap</title>
<para> <para>
<command>wordwrap</command> wraps a string to a column width, default is 80. As Wraps a string to a column width,
an optional second parameter, you can specify a string of text the default is 80. As an optional second parameter,
to wrap the text to the next line (default is carriage return \n). you can specify a string of text
By default, {wordwrap} will attempt to wrap at a word boundary. If to wrap the text to the next line, the default is a carriage return
you want to cut off at the exact character length, pass the optional <literal>"\n"</literal>.
third parameter of true. This is equivalent to the PHP <ulink By default, <varname>wordwrap</varname> will attempt to wrap at a word
url="&url.php-manual;wordwrap">wordwrap()</ulink> function. boundary. If you want to cut off at the exact character length, pass
the optional third parameter as &true;. This is equivalent to the PHP
<ulink url="&url.php-manual;wordwrap"><varname>wordwrap()</varname></ulink>
function.
</para> </para>
<informaltable frame="all"> <informaltable frame="all">
<tgroup cols="5"> <tgroup cols="5">
<colspec colname="param" align="center" /> <colspec colname="param" align="center" />
@@ -48,9 +51,9 @@
<entry>3</entry> <entry>3</entry>
<entry>boolean</entry> <entry>boolean</entry>
<entry>No</entry> <entry>No</entry>
<entry>false</entry> <entry>&false;</entry>
<entry>This determines whether or not to wrap at a <entry>This determines whether or not to wrap at a
word boundary (false), or at the exact character (true).</entry> word boundary (&false;), or at the exact character (&true;).</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
@@ -61,7 +64,7 @@
<programlisting role="php"> <programlisting role="php">
<![CDATA[ <![CDATA[
<?php <?php
$smarty->assign('articleTitle', $smarty->assign('articleTitle',
"Blind woman gets new kidney from dad she hasn't seen in years." "Blind woman gets new kidney from dad she hasn't seen in years."
); );
@@ -70,23 +73,23 @@ $smarty->assign('articleTitle',
]]> ]]>
</programlisting> </programlisting>
<para> <para>
where template is Where template is
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
{$articleTitle} {$articleTitle}
{$articleTitle|wordwrap:30} {$articleTitle|wordwrap:30}
{$articleTitle|wordwrap:20} {$articleTitle|wordwrap:20}
{$articleTitle|wordwrap:30:"<br />\n"} {$articleTitle|wordwrap:30:"<br />\n"}
{$articleTitle|wordwrap:30:"\n":true} {$articleTitle|wordwrap:30:"\n":true}
]]> ]]>
</programlisting> </programlisting>
<para> <para>
This will output: Will output:
</para> </para>
<screen> <screen>
<![CDATA[ <![CDATA[
@@ -112,9 +115,10 @@ years.
</screen> </screen>
</example> </example>
<para> <para>
See also <link linkend="language.modifier.nl2br">nl2br</link> See also
<link linkend="language.modifier.nl2br"><varname>nl2br</varname></link>
and and
<link linkend="language.function.textformat">{textformat}</link>. <link linkend="language.function.textformat"><varname>{textformat}</varname></link>.
</para> </para>
</sect1> </sect1>