mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
Tidying up some markup
This commit is contained in:
@@ -3,20 +3,20 @@
|
||||
<chapter id="language.builtin.functions">
|
||||
<title>Built-in Functions</title>
|
||||
<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
|
||||
<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.
|
||||
</para>
|
||||
<para>
|
||||
A few on these functions have an <emphasis role="bold">assign</emphasis>
|
||||
attribute which collects
|
||||
the result the function to a named variable within a template instead of being output;
|
||||
much like the <link linkend="language.function.assign">{assign}</link> function.
|
||||
A few on these functions have an <parameter>assign</parameter>
|
||||
attribute which collects the result the function to a named
|
||||
variable within a template instead of being output;
|
||||
much like the <link linkend="language.function.assign">
|
||||
<varname>{assign}</varname></link> function.
|
||||
</para>
|
||||
|
||||
|
||||
&designers.language-builtin-functions.language-function-capture;
|
||||
&designers.language-builtin-functions.language-function-config-load;
|
||||
&designers.language-builtin-functions.language-function-foreach;
|
||||
@@ -29,7 +29,7 @@
|
||||
&designers.language-builtin-functions.language-function-php;
|
||||
&designers.language-builtin-functions.language-function-section;
|
||||
&designers.language-builtin-functions.language-function-strip;
|
||||
|
||||
|
||||
</chapter>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -194,13 +194,13 @@ $smarty->assign('contact',$db->getRow($sql));
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where an example template would be
|
||||
Where a template could be as follows. Note the use of the truncate modifier.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<select name="type_id">
|
||||
<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>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@@ -3,17 +3,20 @@
|
||||
<chapter id="language.modifiers">
|
||||
<title>Variable Modifiers</title>
|
||||
<para>
|
||||
Variable modifiers can be applied to
|
||||
<link linkend="language.syntax.variables">variables</link>,
|
||||
<link linkend="language.custom.functions">custom functions</link> or strings. To
|
||||
apply a modifier, specify the value followed by a <literal>|</literal>
|
||||
Variable modifiers can be applied to
|
||||
<link linkend="language.syntax.variables">variables</link>,
|
||||
<link linkend="language.custom.functions">custom functions</link> or strings.
|
||||
To apply a modifier, specify the value followed by a <literal>|</literal>
|
||||
(pipe) and the modifier name. A modifier may accept additional parameters
|
||||
that affect its behavior. These parameters follow the modifer name and are
|
||||
separated by a <literal>:</literal> (colon). Additionally
|
||||
all php-functions can be used as modifiers implicitly; more below.
|
||||
separated by a <literal>:</literal> (colon). Also,
|
||||
<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>
|
||||
<example>
|
||||
<title>modifier examples</title>
|
||||
<title>Modifier examples</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* apply modifier to a variable *}
|
||||
@@ -53,43 +56,61 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
|
||||
<listitem><para>
|
||||
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 to work on an entire array as a value, you must prepend the
|
||||
modifier name with an <literal>@</literal> symbol like so:
|
||||
<literal>{$articleTitle|@count}</literal> (this will print out the number of
|
||||
elements in the $articleTitle array.)
|
||||
</para>
|
||||
<para>
|
||||
modifier name with a <literal>@</literal> symbol.
|
||||
<note>
|
||||
<title>Example</title>
|
||||
<para><literal>{$articleTitle|@count}</literal> - will print out the number of
|
||||
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
|
||||
linkend="variable.plugins.dir">$plugins_dir</link>
|
||||
or can be registered explicitely with <link
|
||||
linkend="api.register.modifier">register_modifier()</link>;
|
||||
this is useful for sharing a function in a php script and smarty templates.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
All php-functions can be used as modifiers implicitly. (The
|
||||
<literal>@count</literal> example above actually uses php's
|
||||
count() function and not a smarty-modifier). Using php-functions
|
||||
as modifiers has two little pitfalls: First; sometimes the order
|
||||
of the function-parameters is not the desirable one
|
||||
(<literal>{"%2.f"|sprintf:$float}</literal> actually works, but
|
||||
asks for the more intuitive. For example:<literal>{$float|string_format:"%2.f"}</literal>
|
||||
that is provided by the Smarty distribution). Second; with <link
|
||||
linkend="variable.security">$security</link> enabled all
|
||||
php-functions that are to be used as modifiers have to be
|
||||
declared trusted in the <link linkend="variable.security.settings">
|
||||
$security_settings['MODIFIER_FUNCS']</link> array.
|
||||
</para>
|
||||
linkend="variable.plugins.dir"><parameter>$plugins_dir</parameter></link>
|
||||
or can be registered explicitely with the <link
|
||||
linkend="api.register.modifier"><varname>register_modifier()</varname></link>
|
||||
function. The later is useful for sharing a function between
|
||||
php scripts and smarty templates.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
All php-functions can be used as modifiers implicitly, as demonstrated in the
|
||||
example above.
|
||||
However, using php-functions as modifiers has two little pitfalls:
|
||||
<itemizedlist>
|
||||
<listitem><para>First - sometimes the order of the function-parameters is
|
||||
not the desirable one. Formatting <literal>$foo</literal> with
|
||||
<literal>{"%2.f"|sprintf:$foo}</literal> actually
|
||||
works, but asks for the more intuitive, like
|
||||
<literal>{$foo|string_format:"%2.f"}</literal> that is provided by
|
||||
the Smarty distribution.
|
||||
</para></listitem>
|
||||
<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>
|
||||
See also
|
||||
<link linkend="api.register.modifier">register_modifier()</link>,
|
||||
<link linkend="api.register.function">register_function()</link>,
|
||||
<link linkend="plugins">extending Smarty with plugins</link>
|
||||
<link linkend="api.register.modifier"><varname>register_modifier()</varname></link>,
|
||||
<link linkend="language.combining.modifiers">combining modifiers</link>.
|
||||
and
|
||||
<link linkend="plugins.modifiers">modifiers</link>,
|
||||
<link linkend="plugins">extending smarty with plugins</link>
|
||||
</para>
|
||||
|
||||
&designers.language-modifiers.language-modifier-capitalize;
|
||||
@@ -113,7 +134,7 @@
|
||||
&designers.language-modifiers.language-modifier-truncate;
|
||||
&designers.language-modifiers.language-modifier-upper;
|
||||
&designers.language-modifiers.language-modifier-wordwrap;
|
||||
|
||||
|
||||
</chapter>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -4,6 +4,8 @@
|
||||
<title>capitalize</title>
|
||||
<para>
|
||||
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>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
@@ -26,13 +28,13 @@
|
||||
<entry>1</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry>false</entry>
|
||||
<entry>&false;</entry>
|
||||
<entry>This determines whether or not words with
|
||||
digits will be uppercased</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</informaltable>
|
||||
<example>
|
||||
<title>capitalize</title>
|
||||
<programlisting role="php">
|
||||
@@ -45,7 +47,7 @@ $smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Where template is:
|
||||
Where the template is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -55,7 +57,7 @@ $smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -65,9 +67,11 @@ Next X-Men Film, X3, Delayed.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>See also <link linkend="language.modifier.lower">lower</link>
|
||||
<para>See also
|
||||
<link linkend="language.modifier.lower"><varname>lower</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.upper">upper</link> </para>
|
||||
<link linkend="language.modifier.upper"><varname>upper</varname></link>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -37,7 +37,7 @@
|
||||
<title>cat</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
<?php
|
||||
|
||||
$smarty->assign('articleTitle', "Psychics predict world didn't end");
|
||||
|
||||
@@ -49,14 +49,14 @@ $smarty->assign('articleTitle', "Psychics predict world didn't end");
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$articleTitle|cat:" yesterday."}
|
||||
{$articleTitle|cat:' yesterday.'}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
Psychics predict world didn't end yesterday.
|
||||
]]>
|
||||
</screen>
|
||||
|
@@ -26,7 +26,7 @@
|
||||
<entry>1</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry>false</entry>
|
||||
<entry>&false;</entry>
|
||||
<entry>This determines whether or not to include
|
||||
whitespace characters in the count.</entry>
|
||||
</row>
|
||||
@@ -56,7 +56,7 @@ $smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -68,9 +68,9 @@ Cold Wave Linked to Temperatures.
|
||||
</example>
|
||||
<para>
|
||||
See also
|
||||
<link linkend="language.modifier.count.words">count_words</link>,
|
||||
<link linkend="language.modifier.count.sentences">count_sentences</link> and
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link>.
|
||||
<link linkend="language.modifier.count.words"><varname>count_words</varname></link>,
|
||||
<link linkend="language.modifier.count.sentences"><varname>count_sentences</varname></link> and
|
||||
<link linkend="language.modifier.count.paragraphs"><varname>count_paragraphs</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -29,21 +29,23 @@ $smarty->assign('articleTitle',
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.
|
||||
|
||||
|
||||
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
|
||||
2
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.count.characters">count_characters</link>,
|
||||
<link linkend="language.modifier.count.sentences">count_sentences</link> and
|
||||
<link linkend="language.modifier.count.words">count_words</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.count.characters"><varname>count_characters</varname></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>
|
||||
</sect1>
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
$smarty->assign('articleTitle',
|
||||
'Two Soviet Ships Collide - One Dies.
|
||||
Enraged Cow Injures Farmer with Axe.'
|
||||
@@ -29,7 +29,7 @@ $smarty->assign('articleTitle',
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -39,9 +39,11 @@ Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.count.characters">count_characters</link>,
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and
|
||||
<link linkend="language.modifier.count.words">count_words</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.count.characters"><varname>count_characters</varname></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>
|
||||
</sect1>
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||
|
||||
?>
|
||||
@@ -36,10 +36,12 @@ Dealers Will Hear Car Talk at Noon.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.count.characters">count_characters</link>,
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> and
|
||||
<link linkend="language.modifier.count.sentences">count_sentences</link>.
|
||||
</para>
|
||||
See also
|
||||
<link linkend="language.modifier.count.characters"><varname>count_characters</varname></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>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -4,17 +4,18 @@
|
||||
<title>date_format</title>
|
||||
<para>
|
||||
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
|
||||
<ulink url="&url.php-manual;function.time">timestamps</ulink>, mysql timestamps
|
||||
or any string made up of month day year, parsable by
|
||||
<ulink url="&url.php-manual;strtotime">strtotime()</ulink>.
|
||||
Designers can then use date_format to have complete control of the
|
||||
or any string made up of month day year, parsable by php's
|
||||
<ulink url="&url.php-manual;strtotime"><varname>strtotime()</varname></ulink>.
|
||||
Designers can then use <varname>date_format</varname> to have complete control of the
|
||||
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.
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -53,20 +54,32 @@
|
||||
<para>
|
||||
<note>
|
||||
<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
|
||||
below) interpreted as a unix timestamp.
|
||||
</para>
|
||||
<para>
|
||||
Before Smarty-2.6.10 numeric strings that where also parsable by
|
||||
strtotime() in php (like "YYYYMMDD") where sometimes - depending
|
||||
on the underlying implementation of strtotime() - interpreted as
|
||||
date strings and not as timestamps.
|
||||
<varname>strtotime()</varname> in php (like <literal>YYYYMMDD</literal>)
|
||||
where sometimes (depending on the underlying implementation of
|
||||
<varname>strtotime()</varname>) interpreted as
|
||||
date strings and NOT as timestamps.
|
||||
</para>
|
||||
<para>
|
||||
The only exception are mysql timestamps: They are also numeric
|
||||
only and 14 characters long ("YYYYMMDDHHMMSS"). Mysql timestamps
|
||||
have precedence over unix timestamps.
|
||||
only and 14 characters long (<literal>YYYYMMDDHHMMSS</literal>),
|
||||
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>
|
||||
</note>
|
||||
</para>
|
||||
@@ -78,14 +91,15 @@
|
||||
|
||||
$config['date'] = '%I:%M %p';
|
||||
$config['time'] = '%H:%M:%S';
|
||||
$smarty->assign('config',$config);
|
||||
$smarty->assign('config', $config);
|
||||
$smarty->assign('yesterday', strtotime('-1 day'));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<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>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -98,21 +112,22 @@ $smarty->assign('yesterday', strtotime('-1 day'));
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
This above will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Feb 6, 2001
|
||||
02/06/01
|
||||
Jan 1, 2022
|
||||
01/01/22
|
||||
02:33 pm
|
||||
Feb 5, 2001
|
||||
Monday, February 5, 2001
|
||||
Dec 31, 2021
|
||||
Monday, December 1, 2021
|
||||
14:33:00
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
<command>date_format</command> conversion specifiers:
|
||||
|
||||
<command>date_format</command> conversion specifiers:
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
%a - abbreviated weekday name according to the current locale
|
||||
@@ -237,23 +252,13 @@ Monday, February 5, 2001
|
||||
%% - a literal `%' character
|
||||
</para></listitem>
|
||||
</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>
|
||||
See also <link linkend="language.variables.smarty.now">$smarty.now</link>,
|
||||
<ulink url="&url.php-manual;strftime">php function strftime()</ulink>,
|
||||
<link linkend="language.function.html.select.date">{html_select_date}</link>
|
||||
and <link linkend="tips.dates">date tips</link>.
|
||||
See also <link linkend="language.variables.smarty.now"><parameter>$smarty.now</parameter></link>,
|
||||
<ulink url="&url.php-manual;strftime"><varname>strftime()</varname></ulink>,
|
||||
<link linkend="language.function.html.select.date"><varname>{html_select_date}</varname></link>
|
||||
and the <link linkend="tips.dates">date tips</link> page.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -5,17 +5,19 @@
|
||||
<para>
|
||||
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.
|
||||
Default takes one argument.
|
||||
Default takes the one argument.
|
||||
</para>
|
||||
<para>
|
||||
<note>
|
||||
<para>
|
||||
With error_reporting(E_ALL), undeclared variables will always throw an error within the template. This function
|
||||
is useful for replacing null or zero length strings.
|
||||
With <ulink url="&url.php-manual;error_reporting">
|
||||
<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>
|
||||
</note>
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -52,7 +54,7 @@
|
||||
<?php
|
||||
|
||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||
$smarty->assign('email','');
|
||||
$smarty->assign('email', '');
|
||||
|
||||
?>
|
||||
]]>
|
||||
@@ -68,7 +70,7 @@ $smarty->assign('email','');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -79,8 +81,10 @@ No email address available
|
||||
</screen>
|
||||
</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>.
|
||||
See also the
|
||||
<link linkend="tips.default.var.handling">default variable handling</link>
|
||||
and the
|
||||
<link linkend="tips.blank.var.handling">blank variable handling</link> pages.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,11 +3,13 @@
|
||||
<sect1 id="language.modifier.escape">
|
||||
<title>escape</title>
|
||||
<para>
|
||||
This is used to encode/escape a variable to html url single quotes, hex escape, hexentity, javascript and mail escape.
|
||||
By default its html
|
||||
escaped.
|
||||
This is used to encode/escape a variable to <literal>html</literal>,
|
||||
<literal>url</literal>, <literal>single quotes</literal>,
|
||||
<literal>hex</literal>, <literal>hexentity</literal>,
|
||||
<literal>javascript</literal> and <literal>mail</literal>.
|
||||
By default its <literal>html</literal> escaped.
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="6">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -31,7 +33,12 @@
|
||||
<entry>1</entry>
|
||||
<entry>string</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>This is the escape format to use.</entry>
|
||||
</row>
|
||||
@@ -39,8 +46,11 @@
|
||||
<entry>2</entry>
|
||||
<entry>string</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>
|
||||
<entry><literal>ISO-8859-1</literal>, <literal>UTF-8</literal>,
|
||||
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>The character set encoding passed to htmlentities() et. al.</entry>
|
||||
</row>
|
||||
@@ -53,11 +63,12 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
$smarty->assign('articleTitle',
|
||||
"'Stiff Opposition Expected to Casketless Funeral Plan'"
|
||||
);
|
||||
$smarty->assign('EmailAddress','smarty@example.com');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -78,7 +89,7 @@ $smarty->assign('EmailAddress','smarty@example.com');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -93,29 +104,37 @@ smarty [AT] example [DOT] com
|
||||
mail [AT] example [DOT] com
|
||||
]]>
|
||||
</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>
|
||||
<![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>
|
||||
]]>
|
||||
</screen>
|
||||
<para>And this is very useful for emails but see also
|
||||
<link linkend="language.function.mailto">{mailto}</link></para>
|
||||
<para>This snippet is useful for emails, but see also
|
||||
<link linkend="language.function.mailto">
|
||||
<varname>{mailto}</varname></link></para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
{* email address mangled *}
|
||||
<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>
|
||||
]]>
|
||||
</screen>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
|
||||
|
||||
|
||||
<para>
|
||||
See also <link linkend="language.escaping">Escaping Smarty Parsing</link>,
|
||||
<link linkend="language.function.mailto">{mailto}</link>
|
||||
and <link linkend="tips.obfuscating.email">Obfuscating E-mail Addresses</link>.
|
||||
See also
|
||||
<link linkend="language.escaping">escaping smarty parsing</link>,
|
||||
<link linkend="language.function.mailto"><varname>{mailto}</varname></link>
|
||||
and the
|
||||
<link linkend="tips.obfuscating.email">obfuscating email addresses</link> page.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,12 +3,12 @@
|
||||
<sect1 id="language.modifier.indent">
|
||||
<title>indent</title>
|
||||
<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
|
||||
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>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -50,14 +50,12 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
$smarty->assign('articleTitle',
|
||||
'NJ judge to rule on nude beach.
|
||||
Sun or rain expected today, dark tonight.
|
||||
Statistics show that teen pregnancy drops off significantly after 25.'
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -76,7 +74,7 @@ Statistics show that teen pregnancy drops off significantly after 25.'
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
this will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -99,9 +97,11 @@ Statistics show that teen pregnancy drops off significantly after 25.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.strip">strip</link>,
|
||||
<link linkend="language.modifier.wordwrap">wordwrap</link>
|
||||
and <link linkend="language.modifier.spacify">spacify</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.strip"><varname>strip</varname></link>,
|
||||
<link linkend="language.modifier.wordwrap"><varname>wordwrap</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.spacify"><varname>spacify</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -4,23 +4,24 @@
|
||||
<title>lower</title>
|
||||
<para>
|
||||
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>
|
||||
<example>
|
||||
<title>lower</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
$smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
|
||||
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Where template is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$articleTitle}
|
||||
{$articleTitle|lower}
|
||||
@@ -37,8 +38,10 @@ two convicts evade noose, jury hung.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.upper">upper</link> and
|
||||
<link linkend="language.modifier.capitalize">Capitalize</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.upper"><varname>upper</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.capitalize"><varname>capitalize</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,9 +3,10 @@
|
||||
<sect1 id="language.modifier.nl2br">
|
||||
<title>nl2br</title>
|
||||
<para>
|
||||
All linebreaks will be converted to <br /> tags in the given
|
||||
variable. This is equivalent to the PHP
|
||||
<ulink url="&url.php-manual;nl2br">nl2br()</ulink> function.
|
||||
All <literal>"\n"</literal> line breaks will be converted to html
|
||||
<literal><br /></literal> tags in the given variable.
|
||||
This is equivalent to the PHP's <ulink url="&url.php-manual;nl2br">
|
||||
<varname>nl2br()</varname></ulink> function.
|
||||
</para>
|
||||
<example>
|
||||
<title>nl2br</title>
|
||||
@@ -29,7 +30,7 @@ $smarty->assign('articleTitle',
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -38,9 +39,11 @@ Sun or rain expected<br />today, dark tonight
|
||||
</screen>
|
||||
</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>.
|
||||
See also
|
||||
<link linkend="language.modifier.wordwrap"><varname>word_wrap</varname></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>
|
||||
</sect1>
|
||||
|
||||
|
@@ -4,10 +4,10 @@
|
||||
<title>regex_replace</title>
|
||||
<para>
|
||||
A regular expression search and replace on a variable. Use the
|
||||
syntax for <ulink
|
||||
url="&url.php-manual;preg_replace">preg_replace()</ulink> from the PHP manual.
|
||||
<ulink url="&url.php-manual;preg_replace">
|
||||
<varname>preg_replace()</varname></ulink> syntax from the PHP manual.
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -55,7 +55,7 @@ $smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Where index.tpl is:
|
||||
Where template is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -66,7 +66,7 @@ $smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This should output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -77,8 +77,10 @@ Infertility unlikely to be passed on, experts say.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.replace">replace</link>
|
||||
and <link linkend="language.modifier.escape">escape</link>.
|
||||
See also <link linkend="language.modifier.replace">
|
||||
<varname>replace</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.escape"><varname>escape</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,10 +3,11 @@
|
||||
<sect1 id="language.modifier.replace">
|
||||
<title>replace</title>
|
||||
<para>
|
||||
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.
|
||||
A simple search and replace on a variable. This is equivalent to the PHP's
|
||||
<ulink url="&url.php-manual;str_replace">
|
||||
<varname>str_replace()</varname></ulink> function.
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -64,7 +65,7 @@ $smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This should output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -75,8 +76,10 @@ Child's Stool Great for Use in Garden.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.regex.replace">regex_replace</link>
|
||||
and <link linkend="language.modifier.escape">escape</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.regex.replace"><varname>regex_replace</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.escape"><varname>escape</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,8 +3,9 @@
|
||||
<sect1 id="language.modifier.spacify">
|
||||
<title>spacify</title>
|
||||
<para>
|
||||
spacify is a way to insert a space between every character of a variable.
|
||||
You can optionally pass a different character (or string) to insert.
|
||||
<varname>spacify</varname> is a way to insert a space between every
|
||||
character of a variable.
|
||||
You can optionally pass a different character or string to insert.
|
||||
</para>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
@@ -57,7 +58,7 @@ $smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This should output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -68,8 +69,10 @@ S^^o^^m^^e^^t^^h^^i^^n^^g^^ .... snip .... ^^e^^r^^t^^s^^ ^^S^^a^^y^^.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.wordwrap">wordwrap</link>
|
||||
and <link linkend="language.modifier.nl2br">nl2br</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.wordwrap"><varname>wordwrap</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.nl2br"><varname>nl2br</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -4,10 +4,11 @@
|
||||
<title>string_format</title>
|
||||
<para>
|
||||
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.
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -58,7 +59,7 @@ $smarty->assign('number', 23.5787446);
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This should output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -68,8 +69,10 @@ $smarty->assign('number', 23.5787446);
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<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>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,9 +3,10 @@
|
||||
<sect1 id="language.modifier.strip.tags">
|
||||
<title>strip_tags</title>
|
||||
<para>
|
||||
This strips out markup tags, basically anything between < and >.
|
||||
This strips out markup tags, basically anything between
|
||||
<literal><</literal> and <literal>></literal>.
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -27,8 +28,8 @@
|
||||
<entry>1</entry>
|
||||
<entry>bool</entry>
|
||||
<entry>No</entry>
|
||||
<entry>true</entry>
|
||||
<entry>This determines wether the tags are replaced by ' ' or by ''</entry>
|
||||
<entry>&true;</entry>
|
||||
<entry>This determines whether the tags are replaced by ' ' or ''</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
@@ -49,17 +50,17 @@ Kidney</font> from Dad she Hasn't Seen in <b>years</b>."
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where template is:
|
||||
Where template is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$articleTitle}
|
||||
{$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
|
||||
{$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
|
||||
{$articleTitle|strip_tags:false}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -69,6 +70,12 @@ Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
|
||||
]]>
|
||||
</screen>
|
||||
</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>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -4,13 +4,13 @@
|
||||
<title>strip</title>
|
||||
<para>
|
||||
This replaces all repeated spaces, newlines and tabs with a single
|
||||
space, or with a supplied string.
|
||||
space, or with the supplied string.
|
||||
</para>
|
||||
<note>
|
||||
<title>Note</title>
|
||||
<para>
|
||||
If you want to strip blocks of template text, use the <link
|
||||
linkend="language.function.strip">{strip}</link> function.
|
||||
If you want to strip blocks of template text, use the built-in <link
|
||||
linkend="language.function.strip"><varname>{strip}</varname></link> function.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
@@ -18,16 +18,13 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where template is:
|
||||
Where template is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -37,7 +34,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -48,10 +45,12 @@ Grandmother of eight makes hole in one.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
|
||||
<para>
|
||||
See also <link linkend="language.function.strip">{strip}</link> and
|
||||
<link linkend="language.modifier.truncate">truncate</link>.
|
||||
See also
|
||||
<link linkend="language.function.strip"><varname>{strip}</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.truncate"><varname>truncate</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -3,15 +3,15 @@
|
||||
<sect1 id="language.modifier.truncate">
|
||||
<title>truncate</title>
|
||||
<para>
|
||||
This truncates a variable to a character length, default is 80. As
|
||||
an optional second parameter, you can specify a string of text
|
||||
This truncates a variable to a character length, the default is 80.
|
||||
As an optional second parameter, you can specify a string of text
|
||||
to display at the end if the variable was truncated. The
|
||||
characters in the string are included with the original truncation length.
|
||||
By default, truncate will attempt to cut off at a word boundary. If
|
||||
you want to cut off at the exact character length, pass the optional
|
||||
third parameter of true.
|
||||
By default, <varname>truncate</varname> will attempt to cut off at a
|
||||
word boundary. If you want to cut off at the exact character length,
|
||||
pass the optional third parameter of &true;.
|
||||
</para>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -49,18 +49,19 @@
|
||||
<entry>3</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry>false</entry>
|
||||
<entry>&false;</entry>
|
||||
<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>
|
||||
<entry>4</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry>false</entry>
|
||||
<entry>&false;</entry>
|
||||
<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
|
||||
setting is true, then word boundaries are ignored.</entry>
|
||||
string with &false;, or in the middle of the string with &true;.
|
||||
Note that if this setting is &true;, then word boundaries are ignored.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
@@ -71,9 +72,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@@ -4,21 +4,20 @@
|
||||
<title>upper</title>
|
||||
<para>
|
||||
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>
|
||||
<example>
|
||||
<title>upper</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where template is:
|
||||
Where template is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -27,7 +26,7 @@ $smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a W
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -37,8 +36,10 @@ IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.lower">lower</link> and
|
||||
<link linkend="language.modifier.capitalize">capitalize</link>.
|
||||
See also
|
||||
<link linkend="language.modifier.lower"><varname>lower</varname></link>
|
||||
and
|
||||
<link linkend="language.modifier.capitalize"><varname>capitalize</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
@@ -3,15 +3,18 @@
|
||||
<sect1 id="language.modifier.wordwrap">
|
||||
<title>wordwrap</title>
|
||||
<para>
|
||||
<command>wordwrap</command> wraps a string to a column width, default is 80. As
|
||||
an optional second parameter, you can specify a string of text
|
||||
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
|
||||
you want to cut off at the exact character length, pass the optional
|
||||
third parameter of true. This is equivalent to the PHP <ulink
|
||||
url="&url.php-manual;wordwrap">wordwrap()</ulink> function.
|
||||
Wraps a string to a column width,
|
||||
the default is 80. As an optional second parameter,
|
||||
you can specify a string of text
|
||||
to wrap the text to the next line, the default is a carriage return
|
||||
<literal>"\n"</literal>.
|
||||
By default, <varname>wordwrap</varname> will attempt to wrap at a word
|
||||
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>
|
||||
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -48,9 +51,9 @@
|
||||
<entry>3</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry>false</entry>
|
||||
<entry>&false;</entry>
|
||||
<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>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
@@ -61,7 +64,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
||||
$smarty->assign('articleTitle',
|
||||
"Blind woman gets new kidney from dad she hasn't seen in years."
|
||||
);
|
||||
@@ -70,23 +73,23 @@ $smarty->assign('articleTitle',
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where template is
|
||||
Where template is
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
{$articleTitle}
|
||||
|
||||
{$articleTitle|wordwrap:30}
|
||||
|
||||
|
||||
{$articleTitle|wordwrap:20}
|
||||
|
||||
|
||||
{$articleTitle|wordwrap:30:"<br />\n"}
|
||||
|
||||
|
||||
{$articleTitle|wordwrap:30:"\n":true}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -112,9 +115,10 @@ years.
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
See also <link linkend="language.modifier.nl2br">nl2br</link>
|
||||
See also
|
||||
<link linkend="language.modifier.nl2br"><varname>nl2br</varname></link>
|
||||
and
|
||||
<link linkend="language.function.textformat">{textformat}</link>.
|
||||
<link linkend="language.function.textformat"><varname>{textformat}</varname></link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
Reference in New Issue
Block a user