%a - abbreviated weekday name according to the current locale
</para></listitem>
<listitem><para>
%A - full weekday name according to the current locale
</para></listitem>
<listitem><para>
%b - abbreviated month name according to the current locale
</para></listitem>
<listitem><para>
%B - full month name according to the current locale
</para></listitem>
<listitem><para>
%c - preferred date and time representation for the current locale
</para></listitem>
<listitem><para>
%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)
</para></listitem>
<listitem><para>
%d - day of the month as a decimal number (range 00 to 31)
</para></listitem>
<listitem><para>
%D - same as %m/%d/%y
</para></listitem>
<listitem><para>
%e - day of the month as a decimal number, a single digit is preceded by a space (range 1 to 31)
</para></listitem>
<listitem><para>
%g - Week-based year within century [00,99]
</para></listitem>
<listitem><para>
%G - Week-based year, including the century [0000,9999]
</para></listitem>
<listitem><para>
%h - same as %b
</para></listitem>
<listitem><para>
%H - hour as a decimal number using a 24-hour clock (range 00 to 23)
</para></listitem>
<listitem><para>
%I - hour as a decimal number using a 12-hour clock (range 01 to 12)
</para></listitem>
<listitem><para>
%j - day of the year as a decimal number (range 001 to 366)
</para></listitem>
<listitem><para>
%k - Hour (24-hour clock) single digits are preceded by a blank. (range 0 to 23)
</para></listitem>
<listitem><para>
%l - hour as a decimal number using a 12-hour clock, single digits preceeded by a space (range 1 to 12)
</para></listitem>
<listitem><para>
%m - month as a decimal number (range 01 to 12)
</para></listitem>
<listitem><para>
%M - minute as a decimal number
</para></listitem>
<listitem><para>
%n - newline character
</para></listitem>
<listitem><para>
%p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale
</para></listitem>
<listitem><para>
%r - time in a.m. and p.m. notation
</para></listitem>
<listitem><para>
%R - time in 24 hour notation
</para></listitem>
<listitem><para>
%S - second as a decimal number
</para></listitem>
<listitem><para>
%t - tab character
</para></listitem>
<listitem><para>
%T - current time, equal to %H:%M:%S
</para></listitem>
<listitem><para>
%u - weekday as a decimal number [1,7], with 1 representing Monday
</para></listitem>
<listitem><para>
%U - week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week
</para></listitem>
<listitem><para>
%V - The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week.
</para></listitem>
<listitem><para>
%w - day of the week as a decimal, Sunday being 0
</para></listitem>
<listitem><para>
%W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week
</para></listitem>
<listitem><para>
%x - preferred date representation for the current locale without the time
</para></listitem>
<listitem><para>
%X - preferred time representation for the current locale without the date
</para></listitem>
<listitem><para>
%y - year as a decimal number without a century (range 00 to 99)
</para></listitem>
<listitem><para>
%Y - year as a decimal number including the century
</para></listitem>
<listitem><para>
%Z - time zone or name or abbreviation
</para></listitem>
<listitem><para>
%% - a literal `%' character
</para></listitem>
</itemizedlist>
<note>
<title>Programmers note</title>
<para>
date_format is essentially a wrapper to PHP's strftime()
function. You may have more or less conversion specifiers available depending
on your system's strftime() function where PHP was compiled. Check your
system's manpage for a full list of valid specifiers.
</para>
</note>
</para>
</sect1>
<sect1id="language.modifier.default">
<title>default</title>
<informaltableframe="all">
<tgroupcols="5">
<colspeccolname="param"align="center"/>
<colspeccolname="type"align="center"/>
<colspeccolname="required"align="center"/>
<colspeccolname="default"align="center"/>
<colspeccolname="desc"/>
<thead>
<row>
<entry>Parameter Position</entry>
<entry>Type</entry>
<entry>Required</entry>
<entry>Default</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>empty</emphasis></entry>
<entry>This is the default value to output if the
variable is empty.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
This is used to set a default value for a variable. If the variable
is empty or unset, the given default value is printed instead.
Default takes one argument.
</para>
<example>
<title>default</title>
<programlisting>
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
This strips out markup tags, basically anything between < and >.
</para>
<example>
<title>strip_tags</title>
<programlisting>
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "Blind Woman Gets <font face=\"helvetica\">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|strip_tags}
OUTPUT:
Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.</programlisting>
</example>
</sect1>
<sect1id="language.modifier.truncate">
<title>truncate</title>
<informaltableframe="all">
<tgroupcols="5">
<colspeccolname="param"align="center"/>
<colspeccolname="type"align="center"/>
<colspeccolname="required"align="center"/>
<colspeccolname="default"align="center"/>
<colspeccolname="desc"/>
<thead>
<row>
<entry>Parameter Position</entry>
<entry>Type</entry>
<entry>Required</entry>
<entry>Default</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>integer</entry>
<entry>No</entry>
<entry>80</entry>
<entry>This determines how many characters to truncate
to.</entry>
</row>
<row>
<entry>2</entry>
<entry>string</entry>
<entry>No</entry>
<entry>...</entry>
<entry>This is the text to append if truncation occurs.</entry>
</row>
<row>
<entry>3</entry>
<entry>boolean</entry>
<entry>No</entry>
<entry>false</entry>
<entry>This determines whether or not to truncate at a
word boundary (false), or at the exact character (true).</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
This truncates a variable to a character length, 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.
</para>
<example>
<title>truncate</title>
<programlisting>
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}
OUTPUT:
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...</programlisting>
</example>
</sect1>
<sect1id="language.modifier.upper">
<title>upper</title>
<para>
This is used to uppercase a variable.
</para>
<example>
<title>upper</title>
<programlisting>
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|upper}
OUTPUT:
If Strike isn't Settled Quickly it may Last a While.
IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.</programlisting>
</example>
</sect1>
<sect1id="language.modifier.wordwrap">
<title>wordwrap</title>
<informaltableframe="all">
<tgroupcols="5">
<colspeccolname="param"align="center"/>
<colspeccolname="type"align="center"/>
<colspeccolname="required"align="center"/>
<colspeccolname="default"align="center"/>
<colspeccolname="desc"/>
<thead>
<row>
<entry>Parameter Position</entry>
<entry>Type</entry>
<entry>Required</entry>
<entry>Default</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>integer</entry>
<entry>No</entry>
<entry>80</entry>
<entry>This determines how many columns to wrap
to.</entry>
</row>
<row>
<entry>2</entry>
<entry>string</entry>
<entry>No</entry>
<entry>\n</entry>
<entry>This is the string used to wrap words with.</entry>
</row>
<row>
<entry>3</entry>
<entry>boolean</entry>
<entry>No</entry>
<entry>false</entry>
<entry>This determines whether or not to wrap at a
word boundary (false), or at the exact character (true).</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
This 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.
</para>
<example>
<title>wordwrap</title>
<programlisting>
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years.");
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|wordwrap:30}
{$articleTitle|wordwrap:20}
{$articleTitle|wordwrap:30:"<br>\n"}
{$articleTitle|wordwrap:30:"\n":true}
OUTPUT:
Blind woman gets new kidney from dad she hasn't seen in years.