mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
edit examples, make more verbose
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
Template comments are surrounded by asterisks, and that is surrounded
|
||||
by the delimiter tags like so: {* this is a comment *}
|
||||
Smarty comments are not displayed in the final output of the template.
|
||||
They are used mainly for making the templates more understandable.
|
||||
They are used for making internal notes in the templates.
|
||||
</para>
|
||||
<example>
|
||||
<title>Comments</title>
|
||||
@@ -116,13 +116,12 @@
|
||||
<chapter id="language.variables">
|
||||
<title>Variables</title>
|
||||
<para>
|
||||
Smarty has several different types of variables, all of which are
|
||||
explained in more detail below. The type of the variable depends on what
|
||||
symbol it is prefixed with (or enclosed within).
|
||||
Smarty has several different types of variables. The type of the variable
|
||||
depends on what symbol it is prefixed with (or enclosed within).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Variable in Smarty can be either displayed directly or used as arguments
|
||||
Variables in Smarty can be either displayed directly or used as arguments
|
||||
for function attributes and modifiers, inside conditional expressions,
|
||||
etc. To print a variable, simply enclose it in the delimiters so that it
|
||||
is the only thing contained between them. Examples:
|
||||
@@ -137,8 +136,10 @@
|
||||
<sect1 id="language.assigned.variables">
|
||||
<title>Variables assigned from PHP</title>
|
||||
<para>
|
||||
Variables that are assigned from PHP are referenced by preceding
|
||||
them with a dollar sign <literal>$</literal>.
|
||||
Variables that are assigned from PHP are referenced by preceding them with
|
||||
a dollar sign <literal>$</literal>. Variables assigned from within the
|
||||
template with the <link linkend="language.function.assign">assign</link>
|
||||
function are also displayed this way.
|
||||
</para>
|
||||
<example>
|
||||
|
||||
@@ -165,6 +166,18 @@ Your last login was on January 11th, 2001.</programlisting>
|
||||
<example>
|
||||
<title>accessing associative array variables</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('fax' => '555-222-9876',
|
||||
'email' => 'zaphod@slartibartfast.com',
|
||||
'phone' => array('home' => '555-444-3333',
|
||||
'cell' => '555-111-1234')));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$Contacts.fax}<br>
|
||||
{$Contacts.email}<br>
|
||||
{* you can print arrays of arrays as well *}
|
||||
@@ -176,8 +189,7 @@ OUTPUT:
|
||||
555-222-9876<br>
|
||||
zaphod@slartibartfast.com<br>
|
||||
555-444-3333<br>
|
||||
555-111-1234<br>
|
||||
</programlisting>
|
||||
555-111-1234<br></programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.array.indexes">
|
||||
@@ -189,11 +201,30 @@ zaphod@slartibartfast.com<br>
|
||||
<example>
|
||||
<title>accessing arrays by index</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('555-222-9876',
|
||||
'zaphod@slartibartfast.com',
|
||||
array('555-444-3333',
|
||||
'555-111-1234')));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$Contacts[0]}<br>
|
||||
{$Contacts[1]}<br>
|
||||
{* you can print arrays of arrays as well *}
|
||||
{$Contacts[0][0]}<br>
|
||||
{$Contacts[0][1]}<br></programlisting>
|
||||
{$Contacts[2][0]}<br>
|
||||
{$Contacts[2][1]}<br>
|
||||
|
||||
OUTPUT:
|
||||
|
||||
555-222-9876<br>
|
||||
zaphod@slartibartfast.com<br>
|
||||
555-444-3333<br>
|
||||
555-111-1234<br></programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.objects">
|
||||
@@ -226,6 +257,17 @@ email: zaphod@slartibartfast.com<br></programlisting>
|
||||
|
||||
<title>config variables</title>
|
||||
<programlisting>
|
||||
foo.conf:
|
||||
|
||||
pageTitle = "This is mine"
|
||||
bodyBgColor = "#eeeeee"
|
||||
tableBorderSize = "3"
|
||||
tableBgColor = "#bbbbbb"
|
||||
rowBgColor = "#cccccc"
|
||||
|
||||
index.tpl:
|
||||
|
||||
{config_load file="foo.conf"}
|
||||
<html>
|
||||
<title>{#pageTitle#}</title>
|
||||
<body bgcolor="{#bodyBgColor#}">
|
||||
@@ -237,6 +279,21 @@ email: zaphod@slartibartfast.com<br></programlisting>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
OUTPUT:
|
||||
|
||||
<html>
|
||||
<title>This is mine</title>
|
||||
<body bgcolor="#eeeeee">
|
||||
<table border="3" bgcolor="#bbbbbb">
|
||||
<tr bgcolor="#cccccc">
|
||||
<td>First</td>
|
||||
<td>Last</td>
|
||||
<td>Address</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html></programlisting>
|
||||
</example>
|
||||
<para>
|
||||
@@ -265,10 +322,10 @@ email: zaphod@slartibartfast.com<br></programlisting>
|
||||
|
||||
<title>displaying request variables</title>
|
||||
<programlisting>
|
||||
{* display the variable "page" given in the URL, or from a form using the GET method *}
|
||||
{* display value of page from URL (GET) http://www.domain.com/index.php?page=foo *}
|
||||
{$smarty.get.page}
|
||||
|
||||
{* display the variable "page" from a form using the POST method *}
|
||||
{* display the variable "page" from a form a form (POST) *}
|
||||
{$smarty.post.page}
|
||||
|
||||
{* display the value of the cookie "username" *}
|
||||
@@ -370,6 +427,14 @@ Topic: {$topic|truncate:40:"..."}</programlisting>
|
||||
<example>
|
||||
<title>capitalize</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Police begin campaign to rundown jaywalkers.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|capitalize}
|
||||
|
||||
@@ -387,13 +452,20 @@ Police Begin Campaign To Rundown Jaywalkers.</programlisting>
|
||||
<example>
|
||||
<title>count_characters</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|count_characters}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
Cold Wave Linked to Temperatures
|
||||
Cold Wave Linked to Temperatures.
|
||||
32</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
@@ -405,6 +477,13 @@ Cold Wave Linked to Temperatures
|
||||
<example>
|
||||
<title>count_paragraphs</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|count_paragraphs}
|
||||
@@ -425,6 +504,13 @@ Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
|
||||
<example>
|
||||
<title>count_sentences</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|count_sentences}
|
||||
@@ -443,6 +529,13 @@ Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
|
||||
<example>
|
||||
<title>count_words</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|count_words}
|
||||
@@ -501,14 +594,29 @@ Dealers Will Hear Car Talk at Noon.
|
||||
<example>
|
||||
<title>date_format</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('yesterday', strtotime('-1 day'));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
|
||||
{$smarty.now|date_format}
|
||||
{$smarty.now|date_format:"%A, %B %e, %Y"}
|
||||
{$smarty.now|date_format:"%H:%M:%S"}
|
||||
{$yesterday|date_format}
|
||||
{$yesterday|date_format:"%A, %B %e, %Y"}
|
||||
{$yesterday|date_format:"%H:%M:%S"}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
Feb 6, 2001
|
||||
Tuesday, February 6, 2001
|
||||
14:33:00
|
||||
Feb 5, 2001
|
||||
Monday, February 5, 2001
|
||||
14:33:00</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
@@ -637,11 +745,20 @@ system's manpage for a full list of valid specifiers.</programlisting>
|
||||
<example>
|
||||
<title>default</title>
|
||||
<programlisting>
|
||||
{* this will display "no title" (without the quotes) if $articleTitle is empty *}
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle|default:"no title"}
|
||||
{$myTitle|default:"no title"}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
Dealers Will Hear Car Talk at Noon.
|
||||
no title</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
@@ -688,6 +805,14 @@ no title</programlisting>
|
||||
<example>
|
||||
<title>escape</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "'Stiff Opposition Expected to Casketless Funeral Plan'");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|escape}
|
||||
{$articleTitle|escape:"html"} {* escapes & " ' < > *}
|
||||
@@ -755,6 +880,14 @@ href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">&#x62;&#x6f;&#x62;&a
|
||||
<example>
|
||||
<title>indent</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'NJ judge to rule on nude beach.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
|
||||
{$articleTitle|indent}
|
||||
@@ -790,6 +923,14 @@ Statistics show that teen pregnancy drops off significantly after 25.
|
||||
<example>
|
||||
<title>lower</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|lower}
|
||||
|
||||
@@ -842,6 +983,14 @@ two convicts evade noose, jury hung.</programlisting>
|
||||
<example>
|
||||
<title>regex_replace</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{* replace each carriage return, tab & new line with a space *}
|
||||
|
||||
{$articleTitle}
|
||||
@@ -850,8 +999,8 @@ two convicts evade noose, jury hung.</programlisting>
|
||||
OUTPUT:
|
||||
|
||||
Infertility unlikely to
|
||||
be passed on, experts say
|
||||
Infertility unlikely to be passed on, experts say</programlisting>
|
||||
be passed on, experts say.
|
||||
Infertility unlikely to be passed on, experts say.</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.modifier.replace">
|
||||
@@ -896,6 +1045,14 @@ Infertility unlikely to be passed on, experts say</programlisting>
|
||||
<example>
|
||||
<title>replace</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|replace:"Garden":"Vineyard"}
|
||||
{$articleTitle|replace:" ":" "}
|
||||
@@ -944,6 +1101,14 @@ Child's Stool Great for Use in Garden.</programlisting>
|
||||
<example>
|
||||
<title>spacify</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|spacify}
|
||||
{$articleTitle|spacify:"^^"}
|
||||
@@ -991,6 +1156,14 @@ S^^o^^m^^e^^t^^h^^i^^n^^g^^ ^^W^^e^^n^^t^^ ^^W^^r^^o^^n^^g^^ ^^i^^n^^ ^^J^^e^^t^
|
||||
<example>
|
||||
<title>string_format</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('number', 23.5787446);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$number}
|
||||
{$number|string_format:"%.2f"}
|
||||
{$number|string_format:"%d"}
|
||||
@@ -1018,6 +1191,14 @@ OUTPUT:
|
||||
<example>
|
||||
<title>strip</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|strip}
|
||||
{$articleTitle|strip:"&nbsp;"}
|
||||
@@ -1025,9 +1206,9 @@ OUTPUT:
|
||||
OUTPUT:
|
||||
|
||||
Grandmother of
|
||||
eight makes hole in one
|
||||
Grandmother of eight makes hole in one
|
||||
Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one</programlisting>
|
||||
eight makes hole in one.
|
||||
Grandmother of eight makes hole in one.
|
||||
Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="language.modifier.strip.tags">
|
||||
@@ -1038,6 +1219,14 @@ Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&
|
||||
<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}
|
||||
|
||||
@@ -1104,6 +1293,14 @@ Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.</programlisting>
|
||||
<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}
|
||||
@@ -1131,6 +1328,14 @@ Two Sisters Reunite after E...</programlisting>
|
||||
<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}
|
||||
|
||||
@@ -1196,6 +1401,14 @@ IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.</programlisting>
|
||||
<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}
|
||||
@@ -1241,6 +1454,14 @@ s.</programlisting>
|
||||
<example>
|
||||
<title>combining modifiers</title>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Smokers are Productive, but Death Cuts Efficiency.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|upper|spacify}
|
||||
{$articleTitle|lower|spacify|truncate}
|
||||
|
@@ -180,22 +180,20 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
|
||||
<sect1 id="variable.compile.check">
|
||||
<title>$compile_check</title>
|
||||
<para>
|
||||
Upon each invocation of the PHP application, Smarty tests to
|
||||
see if the current template has changed (later time stamp)
|
||||
since the last time it was compiled. If it has changed, it
|
||||
recompiles that template. As of 1.4.0, if the template has not
|
||||
been compiled, it will compile regardless of this setting. By
|
||||
default this variable is set to true. Once an application is
|
||||
put into production (templates won't be changing), the
|
||||
compile_check step is no longer needed. Be sure to set
|
||||
$compile_check to "false" to improve performance! Note that if
|
||||
you change this to "false" and a template file is changed, you
|
||||
will *not* see the change since the template will not get
|
||||
recompiled. If caching is enabled and compile_check is enabled,
|
||||
then the cache files will get regenerated if an involved
|
||||
template file was updated. See <link
|
||||
linkend="variable.force.compile">$force_compile</link> or <link
|
||||
linkend="api.clear.compiled.tpl">clear_compiled_tpl</link>.
|
||||
Upon each invocation of the PHP application, Smarty tests to see if the
|
||||
current template has changed (different time stamp) since the last time
|
||||
it was compiled. If it has changed, it recompiles that template. If the
|
||||
template has not been compiled, it will compile regardless of this
|
||||
setting. By default this variable is set to true. Once an application is
|
||||
put into production (templates won't be changing), the compile_check
|
||||
step is no longer needed. Be sure to set $compile_check to "false" for
|
||||
maximal performance. Note that if you change this to "false" and a
|
||||
template file is changed, you will *not* see the change since the
|
||||
template will not get recompiled. If caching is enabled and
|
||||
compile_check is enabled, then the cache files will get regenerated if
|
||||
an involved template file or config file was updated. See <link
|
||||
linkend="variable.force.compile">$force_compile</link> or <link
|
||||
linkend="api.clear.compiled.tpl">clear_compiled_tpl</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="variable.force.compile">
|
||||
@@ -302,6 +300,41 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
|
||||
cached content without <command>insert</command> tags.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="variable.config.overwrite">
|
||||
<title>$config_overwrite</title>
|
||||
<para>
|
||||
If set to true, variables read in from config files will overwrite each
|
||||
other. Otherwise, the variables will be pushed onto an array. This is
|
||||
helpful if you want to store arrays of data in config files, just list
|
||||
each element multiple times. true by default.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="variable.config.booleanize">
|
||||
<title>$config_booleanize</title>
|
||||
<para>
|
||||
If set to true, config file values of on/true/yes and off/false/no get
|
||||
converted to boolean values automatically. This way you can use the
|
||||
values in the template like so: {if #foobar#} ... {/if}. If foobar was
|
||||
on, true or yes, the {if} statement will execute. true by default.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="variable.config.read.hidden">
|
||||
<title>$config_read_hidden</title>
|
||||
<para>
|
||||
If set to true, hidden sections (section names beginning with a period)
|
||||
in config files can be read from templates. Typically you would leave
|
||||
this false, that way you can store sensitive data in the config files
|
||||
such as database parameters and not worry about the template loading
|
||||
them. false by default.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="variable.config.fix.newlines">
|
||||
<title>$config_fix_newlines</title>
|
||||
<para>
|
||||
If set to true, mac and dos newlines (\r and \r\n) in config files are
|
||||
converted to \n when they are parsed. true by default.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="variable.default.template.handler.func">
|
||||
<title>$default_template_handler_func</title>
|
||||
<para>
|
||||
@@ -701,6 +734,64 @@ $smarty->clear_compiled_tpl("index.tpl");
|
||||
|
||||
// clear entire compile directory
|
||||
$smarty->clear_compiled_tpl();</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="api.clear.config">
|
||||
<title>clear_config</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>clear_config</function></funcdef>
|
||||
<paramdef>string <parameter><optional>var</optional></parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
This clears all assigned config variables. If a variable name is
|
||||
supplied, only that variable is cleared.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_config</title>
|
||||
<programlisting>
|
||||
// clear all assigned config variables.
|
||||
$smarty->clear_config();
|
||||
|
||||
// clear one variable
|
||||
$smarty->clear_config('foobar');</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="api.config.load">
|
||||
<title>config_load</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>config_load</function></funcdef>
|
||||
<paramdef>string <parameter>file</parameter></paramdef>
|
||||
<paramdef>string <parameter><optional>section</optional></parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
This loads config file data and assigns it to the template. This
|
||||
works identical to the template <link
|
||||
linkend="language.function.config.load">config_load</link>
|
||||
function.
|
||||
</para>
|
||||
<note>
|
||||
<title>Technical Note</title>
|
||||
<para>
|
||||
As of Smarty 2.4.0, assigned template variables are kept across
|
||||
invocations of fetch() and display(). Config vars loaded from
|
||||
config_load() are always global scope. Config files are also
|
||||
compiled for faster execution, and respect the <link
|
||||
linkend="variable.force.compile">force_compile</link> and <link
|
||||
linkend="variable.compile.check">compile_check</link> settings.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>config_load</title>
|
||||
<programlisting>
|
||||
// load config variables and assign them
|
||||
$smarty->config_load('my.conf');
|
||||
|
||||
// load a section
|
||||
$smarty->config_load('my.conf','foobar');</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<sect1 id="api.display">
|
||||
|
Reference in New Issue
Block a user