Lots of additional cross linking by Peter.

This commit is contained in:
messju
2005-05-23 15:43:01 +00:00
parent 4b80984d6a
commit a6e4f90a69
56 changed files with 490 additions and 161 deletions

View File

@@ -4,16 +4,24 @@
<title>Debugging Console</title>
<para>
There is a debugging console included with Smarty. The console informs you
of all the included templates, assigned variables and config file variables
of all the
<link linkend="language.function.include">included</link> templates,
<link linkend="api.assign">assigned</link> variables and
<link linkend="language.config.variables">config</link>
file variables
for the current invocation of the template. A template named "debug.tpl" is
included with the distribution of Smarty which controls the formatting of
the console. Set $debugging to true in Smarty, and if needed set $debug_tpl
to the template resource path for debug.tpl (this is in SMARTY_DIR by
the console. Set
<link linkend="variable.debugging">$debugging</link> to true in Smarty, and if needed set
<link linkend="variable.debug.tpl">$debug_tpl</link>
to the template resource path for debug.tpl (this is in
<link linkend="constant.smarty.dir">SMARTY_DIR</link> by
default.) When you load the page, a javascript console window should pop up
and give you the names of all the included templates and assigned variables
for the current page. To see the available variables for a particular
templates, see the <link linkend="language.function.debug">{debug}</link>
template function. To disable the debugging console, set $debugging to
template function. To disable the debugging console, set
<link linkend="variable.debugging">$debugging</link> to
false. You can also temporarily turn on the debugging console by putting
SMARTY_DEBUG in the URL if you enable this option with <link
linkend="variable.debugging.ctrl">$debugging_ctrl</link>.
@@ -21,8 +29,11 @@
<note>
<title>Technical Note</title>
<para>
The debugging console does not work when you use the fetch()
API, only when using display(). It is a set of javascript statements added
The debugging console does not work when you use the
<link linkend="api.fetch">fetch()</link>
API, only when using
<link linkend="api.display">display()</link>.
It is a set of javascript statements added
to the very bottom of the generated template. If you do not like javascript,
you can edit the debug.tpl template to format the output however you like.
Debug data is not cached and debug.tpl info is not included in the output of
@@ -57,3 +68,5 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -40,7 +40,9 @@ pass=foobar
</programlisting>
</example>
<para>
Values of config file variables can be in quotes, but not necessary.
Values of
<link linkend="language.config.variables">config file variables</link>
can be in quotes, but not necessary.
You can use either single or double quotes. If you have a value that
spans more than one line, enclose the entire value with triple quotes
("""). You can put comments into config files by any syntax that is not
@@ -56,11 +58,16 @@ pass=foobar
section is loaded, then the global variables and the variables from that
section are also loaded. If a variable exists both as a global and in a
section, the section variable is used. If you name two variables the
same within a section, the last one will be used.
same within a section, the last one will be used. (see
<link linkend="variable.config.overwrite">$config_overwrite</link>)
</para>
<para>
Config files are loaded into templates with the built-in function
<command>config_load</command>.
<link
linkend="language.function.config.load"><command>{config_load}</command></link>
, and
<link
linkend="api.config.load"><command>config_load()</command></link>.
</para>
<para>
You can hide variables or entire sections by prepending the variable

View File

@@ -20,8 +20,7 @@
Similar to HTML entity usage, you can use <link
linkend="language.function.ldelim">{ldelim}</link>,<link
linkend="language.function.ldelim">{rdelim}</link> or <link
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>,<link
linkend="language.variables.smarty.rdelim">{$smarty.rdelim}</link>
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>
to display the current delimiters.
</para>
@@ -60,6 +59,9 @@ dosomething();
]]>
</programlisting>
</example>
<para>
See also <link linkend="language.modifier.escape">escape modifier</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -32,14 +32,14 @@
and <link linkend="language.custom.functions">custom functions</link>
have the same syntax in the templates. Built-in functions are the
inner workings of Smarty, such as
<link linkend="language.function.if"><command>if</command></link>,
<link linkend="language.function.section"><command>section</command></link> and
<link linkend="language.function.strip"><command>strip</command></link>.
<link linkend="language.function.if">{if}</link>,
<link linkend="language.function.section">{section}</link> and
<link linkend="language.function.strip">{strip}</link>.
They cannot be modified. Custom functions are
additional functions implemented via <link linkend="plugins">plugins</link>.
They can be modified to your liking, or you can add new ones.
<link linkend="language.function.html.options"><command>html_options</command></link> and
<link linkend="language.function.html.select.date"><command>html_select_date</command></link>
<link linkend="language.function.html.options">{html_options}</link> and
<link linkend="language.function.html.select.date">{html_select_date}</link>
are examples of custom functions.
</para>
</sect1>

View File

@@ -3,11 +3,15 @@
<sect1 id="language.syntax.quotes">
<title>Embedding Vars in Double Quotes</title>
<para>
Smarty will recognize assigned variables embedded in double quotes so long as
Smarty will recognize <link
linkend="api.assign">assigned</link>
<link linkend="language.syntax.variables">variables</link>
embedded in double quotes so long as
the variables contain only numbers, letters, underscores and brackets [].
With any other characters (period, object reference, etc.) the variable must
be surrounded by backticks. You cannot embed modifiers, they must always be
applied outside of quotes.
be surrounded by backticks. You cannot embed
<link linkend="language.modifiers">modifiers</link>,
they must always be applied outside of quotes.
</para>
<example>
<title>embedded quotes syntax</title>

View File

@@ -4,10 +4,14 @@
<title>Variables</title>
<para>
Template variables start with a dollar sign. They can contain numbers,
letters and underscores, much like a PHP variable. You can reference arrays
letters and underscores, much like a
<ulink url="&url.php-manual;language.variables">PHP variable</ulink>.
You can reference arrays
that are indexed numerically or non-numerically. You can also reference
object properties and methods. Config file variables are an exception to the
dollar sign syntax. They can be referenced with surrounding hashmarks, or
object properties and methods.
<link linkend="language.config.variables">Config file variables</link>
are an exception to the dollar sign syntax.
They can be referenced with surrounding #hashmarks#, or
with the special
<link linkend="language.variables.smarty.config">$smarty.config</link> variable.
</para>

View File

@@ -59,7 +59,9 @@
<para>
Be careful when capturing <link
linkend="language.function.insert"><command>insert</command></link>
output. If you have caching turned on and you have
output. If you have
<link linkend="caching">caching</link>
turned on and you have
<command>insert</command> commands that you expect to run
within cached content, do not capture this content.
</para>
@@ -85,7 +87,8 @@
</example>
</para>
<para>
See also <link linkend="language.function.assign">assign </link>.
See also <link linkend="language.function.eval">{eval}</link>
and <link linkend="language.function.assign">{assign}</link>.
</para>
</sect1>

View File

@@ -64,7 +64,9 @@
linkend="variable.trusted.dir">$trusted_dir</link> path.
The include_php tag must have the attribute
"file", which contains the path to the included php file, either
relative to $trusted_dir, or an absolute path.
relative to
<link linkend="variable.trusted.dir">$trusted_dir</link>,
or an absolute path.
</para>
<para>
include_php is a nice way to handle <link
@@ -126,6 +128,16 @@
]]>
</programlisting>
</example>
<para>
See also
<link linkend="language.function.include">{include}</link>,
<link linkend="language.function.php">{php}</link>,
<link linkend="language.function.capture">{capture}</link>,
<link linkend="template.resources">Template Resources</link> and
<link linkend="tips.componentized.templates">Componentized Templates</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -7,8 +7,8 @@
"{" or "}". You can also use <link
linkend="language.function.literal">{literal}{/literal}</link> to escape
blocks of text.
See also <link linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>
and <link linkend="language.variables.smarty.rdelim">{$smarty.rdelim}</link>
See also <link
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>.
</para>
<example>
<title>ldelim, rdelim</title>

View File

@@ -37,7 +37,7 @@
</tgroup>
</informaltable>
<para>
assign is used for assigning template variables during the execution
{assign} is used for assigning template variables during the execution
of the template.
</para>
<example>
@@ -58,6 +58,11 @@ The value of $name is Bob.
]]>
</screen>
</example>
<para>
See also <link linkend="api.assign">assign()</link>
and
<link linkend="api.get.template.vars">get_template_vars()</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -37,6 +37,9 @@
are in use. But, you see all the currently available variables
within the scope of this template.
</para>
<para>
See also <link linkend="chapter.debugging.console">Debugging console</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -63,7 +63,7 @@
If template security is turned on and you are
fetching a file from the local file system, this will only allow
files from within one of the defined secure directories.
($secure_dir)
(<link linkend="variable.secure.dir">$secure_dir</link>)
</para>
</note>
<example>
@@ -87,6 +87,9 @@
]]>
</programlisting>
</example>
<para>
See also <link linkend="api.fetch">api fetch()</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -5,7 +5,7 @@
<para>
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>
template with the <link linkend="language.function.assign">{assign}</link>
function are also displayed this way.
</para>
<example>

View File

@@ -3,7 +3,9 @@
<sect1 id="language.config.variables">
<title>Variables loaded from config files</title>
<para>
Variables that are loaded from the config files are referenced by
Variables that are loaded from the
<link linkend="config.files">config files</link>
are referenced by
enclosing them within hash marks (#), or with the smarty variable
<link
linkend="language.variables.smarty.config">$smarty.config</link>.
@@ -89,7 +91,8 @@ rowBgColor = "#cccccc"
after they are loaded in from a config file. This procedure is
explained later in this document under <link linkend="api.config.load"><command>config_load</command></link>.
</para>
<para>See also <link linkend="language.syntax.variables">Variables</link> and <link linkend="language.variables.smarty">$smarty reserved variables</link></para>
<para>See also <link linkend="language.syntax.variables">Variables</link> and <link linkend="language.variables.smarty">$smarty reserved
variables</link></para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -72,6 +72,8 @@
<title>{$smarty.const}</title>
<para>
You can access PHP constant values directly.
See also <link
linkend="smarty.constants">smarty constants</link>
</para>
<example>
<title>using {$smarty.const}</title>
@@ -95,19 +97,22 @@
<sect2 id="language.variables.smarty.config">
<title>{$smarty.config}</title>
<para>
{$smarty} variable can be used to refer to loaded config variables.
{$smarty} variable can be used to refer to loaded
<link
linkend="language.config.variables">config variables</link>.
{$smarty.config.foo} is a synonym for {#foo#}. See the section on
<link linkend="language.function.config.load">config_load</link> for an example.
<link
linkend="language.function.config.load">config_load</link> for an example.
</para>
</sect2>
<sect2 id="language.variables.smarty.loops">
<title>{$smarty.section}, {$smarty.foreach}</title>
<para>
{$smarty} variable can be used to refer to 'section' and
'foreach' loop properties. See docs for
<link linkend="language.function.section">section</link> and
<link linkend="language.function.foreach">foreach</link>.
{$smarty} variable can be used to refer to
<link linkend="language.function.section">'section'</link> and
<link linkend="language.function.foreach">'foreach'</link>
loop properties.
</para>
</sect2>
@@ -125,20 +130,20 @@
</para>
</sect2>
<sect2 id="language.variables.smarty.ldelim">
<title>{$smarty.ldelim}</title>
<title>{$smarty.ldelim}, {$smarty.rdelim}</title>
<para>
This variable is used for printing the left-delimiter value literally.
See also <link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
This variable is used for printing the left-delimiter and right-delimiter value literally.
See <link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
</para>
<para>
See also
<link linkend="language.syntax.variables">Variables</link> and
<link linkend="language.config.variables">Config Variables</link>
</para>
</sect2>
<sect2 id="language.variables.smarty.rdelim">
<title>{$smarty.rdelim}</title>
<para>
This variable is used for printing the right-delimiter value literally.
See also <link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
</para>
<para>See also <link linkend="language.syntax.variables">Variables</link> and <link linkend="language.config.variables">Config Variables</link></para>
</sect2>
</sect1>
<!-- Keep this comment at the end of the file
@@ -161,3 +166,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -85,42 +85,53 @@
</listitem>
<listitem>
<para>
Configurable template delimiter tag syntax, so you can use
Configurable template
<link linkend="variable.left.delimiter">delimiter tag</link>
syntax, so you can use
{}, {{}}, &lt;!--{}--&gt;, etc.
</para>
</listitem>
<listitem>
<para>
The if/elseif/else/endif constructs are passed to the
The <link
linkend="language.function.if">if/elseif/else/endif</link>
constructs are passed to the
PHP parser, so the {if ...} expression syntax can be as simple or as
complex as you like.
</para>
</listitem>
<listitem>
<para>
Unlimited nesting of sections, ifs, etc. allowed.
Unlimited nesting of
<link linkend="language.function.section">sections</link>,
ifs, etc. allowed.
</para>
</listitem>
<listitem>
<para>
It is possible to embed PHP code right in your template files, although
It is possible to
<link linkend="language.function.php">embed PHP code</link>
right in your template files, although
this may not be needed (nor recommended) since the engine is so
customizable.
</para>
</listitem>
<listitem>
<para>
Built-in caching support
Built-in <link linkend="caching">caching</link> support
</para>
</listitem>
<listitem>
<para>
Arbitrary template sources
Arbitrary <link
linkend="template.resources">template</link> sources
</para>
</listitem>
<listitem>
<para>
Custom cache handling functions
Custom <link
linkend="section.template.cache.handler.func">cache handling</link>
functions
</para>
</listitem>
<listitem>
@@ -241,9 +252,16 @@ $smarty = new Smarty;
<filename class="directory">templates_c</filename>, <filename
class="directory">configs</filename> and <filename
class="directory">cache</filename>. Each of these are definable by the
Smarty class properties <varname>$template_dir</varname>,
<varname>$compile_dir</varname>, <varname>$config_dir</varname>, and
<varname>$cache_dir</varname> respectively. It is highly recommended
Smarty class properties
<link linkend="variable.template.dir">
<varname>$template_dir</varname></link>,
<link linkend="variable.compile.dir">
<varname>$compile_dir</varname></link>,
<link linkend="variable.config.dir">
<varname>$config_dir</varname></link>, and
<link linkend="variable.cache.dir">
<varname>$cache_dir</varname></link> respectively.
It is highly recommended
that you setup a separate set of these directories for each application
that will use Smarty.
</para>
@@ -310,8 +328,12 @@ $smarty = new Smarty;
</example>
<para>
Smarty will need write access to the <emphasis>$compile_dir</emphasis> and
<emphasis>$cache_dir</emphasis>, so be sure the web server user can write
Smarty will need write access to the
<link linkend="variable.compile.dir">
<emphasis>$compile_dir</emphasis></link> and
<link linkend="variable.cache.dir">
<emphasis>$cache_dir</emphasis></link>,
so be sure the web server user can write
to them. This is usually user "nobody" and group "nobody". For OS X users,
the default is user "www" and group "www". If you are using Apache, you can
look in your httpd.conf file (usually in "/usr/local/apache/conf/") to see

View File

@@ -5,7 +5,8 @@
<para>
The <parameter>merge</parameter> parameter respects array keys, so if
you merge two numerically indexed arrays, they may overwrite each other
or result in non-sequential keys. This is unlike the array_merge() function
or result in non-sequential keys. This is unlike the
<ulink url="&url.php-manual;array_merge">array_merge()</ulink> function
of PHP which wipes out numerical keys and renumbers them.
</para>
</note>'>
@@ -15,10 +16,13 @@
This is in the event that you want to compile different versions of
the same template, such as having separate templates compiled
for different languages. Another use for compile_id is when you
use more than one $template_dir but only one $compile_dir. Set
a separate <parameter>compile_id</parameter> for each $template_dir, otherwise
use more than one
<link linkend="variable.template.dir">$template_dir</link>
but only one
<link linkend="variable.compile.dir">$compile_dir</link>.
Set a separate <parameter>$compile_id</parameter> for each
<link linkend="variable.template.dir">$template_dir</link>, otherwise
templates of the same name will overwrite each other. You can
also set the <link
linkend="variable.compile.id">$compile_id</link> variable once
also set the $compile_id variable once
instead of passing this to each call to this function.
</para>'>

View File

@@ -4,18 +4,22 @@
<title>Objects</title>
<para>
Smarty allows access to PHP objects through the templates. There are
two ways to access them. One way is to register objects to the template,
two ways to access them. One way is to
<link linkend="api.register.object">register objects</link> to the template,
then use access them via syntax similar to custom functions. The other way
is to assign objects to the templates and access them much like any other
is to <link linkend="api.assign">assign objects</link>
to the templates and access them much like any other
assigned variable. The first method has a much nicer template syntax. It
is also more secure, as a registered object can be restricted to certain
methods or properties. However, a registered object cannot be looped over
or assigned in arrays of objects, etc. The method you choose will be
methods or properties. However,
<emphasis role="bold">a registered object cannot be looped over
or assigned in arrays of objects</emphasis>, etc. The method you choose will be
determined by your needs, but use the first method whenever possible to
keep template syntax to a minimum.
</para>
<para>
If security is enabled, no private methods or functions can be accessed
If <link linkend="variable.security">security is enabled</link>,
no private methods or functions can be accessed
(begininning with "_"). If a method and property of the same name exist,
the method will be used.
</para>
@@ -25,7 +29,9 @@
</para>
<para>
By default, parameters passed to objects through the templates are passed
the same way custom functions get them. An associative array is passed
the same way
<link linkend="language.custom.functions">custom functions</link> get them.
An associative array is passed
as the first parameter, and the smarty object as the second. If you want
the parameters passed one at a time for each argument like traditional
object parameter passing, set the fourth registration parameter to false.

View File

@@ -3,7 +3,9 @@
<sect1 id="template.resources">
<title>Resources</title>
<para>
The templates may come from a variety of sources. When you display or fetch
The templates may come from a variety of sources. When you
<link linkend="api.display">display()</link> or
<link linkend="api.fetch">fetch()</link>
a template, or when you include a template from within another template,
you supply a resource type, followed by the appropriate path and template
name. If a resource is not explicitly given the value of <link
@@ -13,10 +15,12 @@
<sect2 id="templates.from.template.dir">
<title>Templates from $template_dir</title>
<para>
Templates from the $template_dir do not require a template
Templates from the
<link linkend="variable.template.dir">$template_dir</link> do not require a template
resource, although you can use the file: resource for consistancy.
Just supply the path to the template you want to use relative to
the $template_dir root directory.
Just supply the path to the template you want to use relative to the
<link linkend="variable.template.dir">$template_dir</link>
root directory.
</para>
<example>
<title>using templates from $template_dir</title>
@@ -38,7 +42,9 @@ $smarty->display("file:admin/menu.tpl"); // same as one above
<sect2 id="templates.from.any.dir">
<title>Templates from any directory</title>
<para>
Templates outside of the $template_dir require the file: template
Templates outside of the
<link linkend="variable.template.dir">$template_dir</link>
require the file: template
resource type, followed by the absolute path and name of the
template.
</para>
@@ -200,7 +206,8 @@ $smarty->display("db:index.tpl");
<?php
// put this function somewhere in your application
function make_template ($resource_type, $resource_name, &$template_source, &$template_timestamp, &$smarty_obj)
function make_template ($resource_type, $resource_name, &$template_source, &$template_timestamp,
&$smarty_obj)
{
if( $resource_type == 'file' ) {
if ( ! is_readable ( $resource_name )) {
@@ -244,3 +251,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -14,9 +14,11 @@
<methodparam choice="opt"><type>bool</type><parameter>merge</parameter></methodparam>
</methodsynopsis>
<para>
This is used to append values to the templates by reference.
This is used to
<link linkend="api.append">append</link> values to the templates by reference.
If you append a variable by reference then change its
value, the appended value sees the change as well. For objects,
value, the appended value sees the change as well. For
<link linkend="advanced.features.objects">objects</link>,
append_by_ref() also avoids an in-memory copy of the appended object.
See the PHP manual on variable referencing for an in-depth
explanation. If you pass the optional third parameter of true,
@@ -29,12 +31,17 @@
<![CDATA[
<?php
// appending name/value pairs
$smarty->append_by_ref("Name", $myname);
$smarty->append_by_ref("Address", $address);
$smarty->append_by_ref('Name', $myname);
$smarty->append_by_ref('Address', $address);
?>
]]>
</programlisting>
</example>
<para>
See also <link linkend="api.append">append()</link> and
<link linkend="api.assign">assign()</link>.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -36,11 +36,17 @@ $smarty->append("Name", "Fred");
$smarty->append("Address", $address);
// passing an associative array
$smarty->append(array("city" => "Lincoln", "state" => "Nebraska"));
$smarty->append(array('city' => 'Lincoln', 'state' => 'Nebraska'));
?>
]]>
</programlisting>
</example>
<para>See also
<link linkend="api.append.by.ref">append_by_ref()</link>,
<link linkend="api.assign">assign()</link>
and
<link linkend="api.get.template.vars">get_template_vars()</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -21,7 +21,8 @@
<para>
This is used to assign values to the templates by reference.
If you assign a variable by reference then change its
value, the assigned value sees the change as well. For objects,
value, the assigned value sees the change as well. For
<link linkend="advanced.features.objects">objects</link>,
assign_by_ref() also avoids an in-memory copy of the assigned object.
See the PHP manual on variable referencing for an in-depth
explanation.
@@ -39,6 +40,13 @@ $smarty->assign_by_ref('Address', $address);
]]>
</programlisting>
</example>
<para>
See also <link linkend="api.assign">assign()</link>,
<link linkend="api.clear.all.assign">clear_all_assign()</link>,
<link linkend="api.append">append()</link>
and <link linkend="language.function.assign">{assign} function</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
@@ -61,3 +69,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -31,11 +31,19 @@ $smarty->assign('Name', 'Fred');
$smarty->assign('Address', $address);
// passing an associative array
$smarty->assign(array("city" => "Lincoln", "state" => "Nebraska"));
$smarty->assign(array('city' => 'Lincoln', 'state' => 'Nebraska'));
?>
]]>
</programlisting>
</example>
<para>
See also <link linkend="api.assign.by.ref">assign_by_ref()</link>,
<link linkend="api.clear.assign">clear_assign()</link>,
<link linkend="api.append">append()</link>,
<link linkend="language.function.assign">{assign}</link>.
and
<link linkend="api.get.template.vars">get_template_vars()</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -25,6 +25,13 @@ $smarty->clear_all_assign();
]]>
</programlisting>
</example>
<para>
See also
<link linkend="api.clear.assign">clear_assign()</link>,
<link linkend="api.clear.config">clear_config()</link>,
<link linkend="api.assign">assign()</link>
and <link linkend="api.append">append()</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
@@ -47,3 +54,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -27,6 +27,12 @@ $smarty->clear_all_cache();
]]>
</programlisting>
</example>
<para>
See also
<link linkend="api.clear.cache">clear_cache()</link>
and
<link linkend="caching">caching</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -29,6 +29,13 @@ $smarty->clear_assign(array("Name", "Address", "Zip"));
]]>
</programlisting>
</example>
<para>
See also
<link linkend="api.clear.all.assign">clear_all_assign()</link>,
<link linkend="api.clear.config">clear_config()</link>,
<link linkend="api.assign">assign()</link>
and <link linkend="api.append">append()</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -40,6 +40,10 @@ $smarty->clear_cache("index.tpl", "CACHEID");
]]>
</programlisting>
</example>
<para>
See also
<link linkend="caching">caching</link>.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -12,7 +12,9 @@
<methodparam choice="opt"><type>string</type><parameter>var</parameter></methodparam>
</methodsynopsis>
<para>
This clears all assigned config variables. If a variable name is
This clears all assigned
<link linkend="language.config.variables">config variables</link>.
If a variable name is
supplied, only that variable is cleared.
</para>
<example>
@@ -29,6 +31,15 @@ $smarty->clear_config('foobar');
]]>
</programlisting>
</example>
<para>
See also
<link linkend="language.config.variables">config variables</link>,
<link linkend="config.files">config files</link>,
<link linkend="language.function.config.load">{config_load}</link>,
<link linkend="api.config.load">config_load()</link>
and
<link linkend="api.clear.assign">clear_assign()</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -13,20 +13,25 @@
<methodparam choice="opt"><type>string</type><parameter>section</parameter></methodparam>
</methodsynopsis>
<para>
This loads config <parameter>file</parameter> data and assigns it to
This loads
<link linkend="config.files">config file</link>
data and assigns it to
the template. This works identical to the template <link
linkend="language.function.config.load">config_load</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
invocations of
<link linkend="api.fetch">fetch()</link>
and <link linkend="api.display">display()</link>.
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.
linkend="variable.force.compile">$force_compile</link> and <link
linkend="variable.compile.check">$compile_check</link> settings.
</para>
</note>
<example>
@@ -43,6 +48,13 @@ $smarty->config_load('my.conf', 'foobar');
]]>
</programlisting>
</example>
<para>
See also
<link linkend="language.function.config.load">{config_load}</link>,
<link linkend="api.clear.config">clear_config()</link>,
and
<link linkend="language.config.variables">config variables</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -17,7 +17,8 @@
This displays the template. Supply a valid <link
linkend="template.resources">template resource</link>
type and path. As an optional second parameter, you can pass a
cache id. See the <link linkend="caching">caching
$cache id.
See the <link linkend="caching">caching
section</link> for more information.
</para>
&parameter.compileid;
@@ -80,7 +81,7 @@ $smarty->display("db:header.tpl");
</example>
<para>
See also <link linkend="api.fetch">fetch()</link> and
<link linkend="api.template.exists">template_exists</link>.
<link linkend="api.template.exists">template_exists()</link>.
</para>
</refsect1>
</refentry>

View File

@@ -62,8 +62,12 @@ echo $output;
</example>
</para>
<para>
See also <link linkend="api.display">display()</link> and
<link linkend="api.template.exists">template_exists</link>.
See also
<link linkend="language.function.fetch">{fetch}</link>
<link linkend="api.display">display()</link>,
<link linkend="language.function.eval">{eval}</link>,
and
<link linkend="api.template.exists">template_exists()</link>.
</para>
</refsect1>
</refentry>

View File

@@ -32,6 +32,16 @@ print_r($config_vars);
]]>
</programlisting>
</example>
<para>
See also
<link linkend="api.clear.config">clear_config()</link>,
<link linkend="language.function.config.load">{config_load}</link>
and
<link linkend="api.config.load">config_load()</link>,
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -16,7 +16,7 @@
<para>
This returns &true; if there is a valid cache for this template.
This only works if <link
linkend="variable.caching">caching</link> is set to true.
linkend="variable.caching">$caching</link> is set to true.
</para>
<example>
<title>is_cached</title>
@@ -35,11 +35,13 @@ $smarty->display("index.tpl");
</programlisting>
</example>
<para>
You can also pass a cache id as an optional second parameter
You can also pass a $cache id as an optional second parameter
in case you want multiple caches for the given template.
</para>
<para>
You can supply a compile id as an optional third parameter.
You can supply a
<link linkend="variable.compile.id">$compile id</link>
as an optional third parameter.
If you omit that parameter the persistent
<link linkend="variable.compile.id">$compile_id</link> is used.
</para>
@@ -78,7 +80,7 @@ $smarty->display("index.tpl", "FrontPage");
display in the example above. This also means calls to
<link linkend="api.clear.cache">clear_cache()</link>
and other changes of the cache-settings may have no effect after
<literal>is_cached</literal> returned true.
is_cached() returned true.
</para>
</note>
</refsect1>

View File

@@ -6,7 +6,9 @@
This is the name of the directory where template caches are
stored. By default this is "./cache", meaning that it will look
for the cache directory in the same directory as the executing
php script. You can also use your own custom cache handler
php script. You can also use your own
<link linkend="section.template.cache.handler.func">
custom cache handler</link>
function to control cache files, which will ignore this
setting.
</para>

View File

@@ -4,7 +4,8 @@
<title>$cache_handler_func</title>
<para>
You can supply a custom function to handle cache files instead
of using the built-in method using the $cache_dir. See the
of using the built-in method using the
<link linkend="variable.cache.dir">$cache_dir</link>. See the
custom <link linkend="section.template.cache.handler.func">cache
handler function section</link> for details.
</para>

View File

@@ -24,8 +24,9 @@
<para>
If you want to give certain templates their own cache lifetime, you could
do this by setting <link linkend="variable.caching">$caching</link> = 2,
then set $cache_lifetime to a unique value just before calling display()
or fetch().
then set $cache_lifetime to a unique value just before calling
<link linkend="api.display">display()</link>
or <link linkend="api.fetch">fetch()</link>.
</para>
</note>
</sect1>

View File

@@ -8,17 +8,22 @@
redundant redundant content, it is advisable to turn on caching. This
will result in significant performance gains. You can also have multiple
caches for the same template. A value of 1 or 2 enables caching. 1 tells
Smarty to use the current $cache_lifetime variable to determine if the
Smarty to use the current
<link linkend="variable.cache.lifetime">$cache_lifetime</link>
variable to determine if the
cache has expired. A value of 2 tells Smarty to use the cache_lifetime
value at the time the cache was generated. This way you can set the
cache_lifetime just before fetching the template to have granular
control over when that particular cache expires. See also <link
linkend="api.is.cached">is_cached</link>.
control over when that particular cache expires.
See also <link linkend="api.is.cached">is_cached()</link>.
</para>
<para>
If $compile_check is enabled, the cached content will be regenerated if
If <link linkend="variable.compile.check">$compile_check</link>
is enabled, the cached content will be regenerated if
any of the templates or config files that are part of this cache are
changed. If $force_compile is enabled, the cached content will always be
changed. If
<link linkend="variable.force.compile">$force_compile</link>
is enabled, the cached content will always be
regenerated.
</para>
</sect1>

View File

@@ -12,11 +12,13 @@
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
template will not get recompiled. If
<link linkend="variable.caching">caching</link>
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>.
linkend="api.clear.compiled.tpl">clear_compiled_tpl()</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -9,12 +9,17 @@
</para>
<para>
With a compile_id you can work around the limitation that you cannot
use the same compile_dir for different template_dirs. If you set a
use the same
<link linkend="variable.compile.dir">$compile_dir</link>
for different
<link linkend="variable.template.dir">$template_dirs</link>. If you set a
distinct compile_id for each template_dir then smarty can tell the
compiled templates apart by their compile_id.
</para>
<para>
If you have for example a prefilter that localizes your templates
If you have for example a
<link linkend="plugins.prefilters.postfilters">prefilter</link>
that localizes your templates
(that is: translates language dependend parts) at compile time, then
you should use the current language as compile_id and you will get a
set of compiled templates for each language you use.

View File

@@ -3,7 +3,9 @@
<sect1 id="variable.config.dir">
<title>$config_dir</title>
<para>
This is the directory used to store config files used in the
This is the directory used to store
<link linkend="config.files">config files</link>
used in the
templates. Default is "./configs", meaning that it will look
for the configs directory in the same directory as the
executing php script.

View File

@@ -4,7 +4,9 @@
<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
in
<link linkend="config.files">config files</link>
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.

View File

@@ -7,6 +7,12 @@
default, it is named debug.tpl and is located in the <link
linkend="constant.smarty.dir">SMARTY_DIR</link>.
</para>
<para>
See also
<link linkend="variable.debugging">$debugging</link>
and
<link linkend="chapter.debugging.console">Debugging console</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -6,9 +6,13 @@
This allows alternate ways to enable debugging. NONE means no
alternate methods are allowed. URL means when the keyword
SMARTY_DEBUG is found in the QUERY_STRING, debugging is enabled
for that invocation of the script. If $debugging is true, this
for that invocation of the script. If
<link linkend="variable.debugging">$debugging</link> is true, this
value is ignored.
</para>
<para>
See also <link linkend="chapter.debugging.console">Debugging console</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -9,6 +9,12 @@
included templates and assigned variables for the current
template page.
</para>
<para>
See also
<link linkend="language.function.debug">{debug}</link>,
<link linkend="variable.debug.tpl">$debug_tpl</link>,
and <link linkend="variable.debugging.ctrl">$debuging_ctrl</link>
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -4,7 +4,8 @@
<title>$error_reporting</title>
<para>
When this value is set to a non-null-value it's value is used as php's
error_reporting-level inside of <link linkend="api.display">display()</link>
<ulink url="&url.php-manual;error_reporting">error_reporting</ulink>
level inside of <link linkend="api.display">display()</link>
and <link linkend="api.fetch">fetch()</link>. When <link
linkend="chapter.debugging.console">debugging</link> is enabled this value
is ignored and the error-level is left untouched.

View File

@@ -4,9 +4,13 @@
<title>$force_compile</title>
<para>
This forces Smarty to (re)compile templates on every
invocation. This setting overrides $compile_check. By default
this is disabled. This is handy for development and debugging.
It should never be used in a production environment. If caching
invocation. This setting overrides
<link linkend="variable.compile.check">$compile_check</link>.
By default
this is disabled. This is handy for development and
<link linkend="chapter.debugging.console">debugging</link>.
It should never be used in a production environment. If
<link linkend="variable.caching">caching</link>
is enabled, the cache file(s) will be regenerated every time.
</para>
</sect1>

View File

@@ -4,8 +4,10 @@
<title>$plugins_dir</title>
<para>
This is the directory (or directories) where Smarty will look for the
plugins that it needs. Default is "plugins" under the SMARTY_DIR. If you
supply a relative path, Smarty will first look under the SMARTY_DIR, then
plugins that it needs. Default is "plugins" under the
<link linkend="constant.smarty.dir">SMARTY_DIR</link>. If you
supply a relative path, Smarty will first look under the
<link linkend="constant.smarty.dir">SMARTY_DIR</link>, then
relative to the cwd (current working directory), then relative to the PHP
include_path. If $plugins_dir is an array of directories, Smarty will
search for your plugin in each plugin directory in the order they are

View File

@@ -6,9 +6,10 @@
Specifies if Smarty should use php's $HTTP_*_VARS[]
($request_use_auto_globals=false which is the default value) or
$_*[] ($request_use_auto_globals=true). This affects templates
that make use of {$smarty.request.*}, {$smarty.get.*} etc. .
that make use of
<link linkend="language.variables.smarty">{$smarty.request.*}, {$smarty.get.*}</link> etc. .
Caution: If you set $request_use_auto_globals to true, <link
linkend="variable.request.vars.order">variable.request.vars.order
linkend="variable.request.vars.order">$request_vars_order
</link> has no effect but php's configuration value
<literal>gpc_order</literal> is used.
</para>

View File

@@ -6,6 +6,11 @@
The order in which request variables are registered, similar to
variables_order in php.ini
</para>
<para>
See also <link linkend="language.variables.smarty">$smarty.request</link>
and
<link linkend="variable.request.use.auto.globals">$request_use_auto_globals</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -4,8 +4,18 @@
<title>$secure_dir</title>
<para>
This is an array of all local directories that are considered
secure. {include} and {fetch} use this when security is enabled.
secure.
<link linkend="language.function.include">{include}</link>
and <link linkend="language.function.fetch">{fetch}</link>
use this when
<link linkend="variable.security">security is enabled</link>.
</para>
<para>
See also
<link linkend="variable.security.settings">Security settings</link>,
and <link linkend="variable.trusted.dir">$trusted_dir</link>.
</para>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -4,23 +4,51 @@
<title>$security_settings</title>
<para>
These are used to override or specify the security settings when
security is enabled. These are the possible settings:
<link linkend="variable.security">security is enabled</link>.
These are the possible settings:
</para>
<itemizedlist>
<listitem><para>PHP_HANDLING - true/false. If set to true, the
$php_handling setting is not checked for security.</para></listitem>
<listitem><para>IF_FUNCS - This is an array of the names of permitted
PHP functions in IF statements.</para></listitem>
<listitem><para>INCLUDE_ANY - true/false. If set to true, any
<listitem>
<para>
PHP_HANDLING - true/false. If set to true, the
<link linkend="variable.php.handling">$php_handling</link>
setting is not checked for security.
</para>
</listitem>
<listitem>
<para>
IF_FUNCS - This is an array of the names of permitted PHP functions in
<link linkend="language.function.if">IF</link> statements.
</para>
</listitem>
<listitem>
<para>
INCLUDE_ANY - true/false. If set to true, any
template can be included from the file system, regardless of the
$secure_dir list.</para></listitem>
<listitem><para>PHP_TAGS - true/false. If set to true, {php}{/php}
tags are permitted in the templates.</para></listitem>
<listitem><para>MODIFIER_FUNCS - This is an array of the names of permitted
PHP functions used as variable modifiers.</para></listitem>
<listitem><para>ALLOW_CONSTANTS - true/false. If set to true, constants via
{$smarty.const.name} are allowed in the templates. The defaults is set to
"false" for security.</para></listitem>
<link linkend="variable.secure.dir">$secure_dir</link> list.
</para>
</listitem>
<listitem>
<para>
PHP_TAGS - true/false. If set to true,
<link linkend="language.function.php">{php}{/php}</link>
tags are permitted in the templates.
</para>
</listitem>
<listitem>
<para>
MODIFIER_FUNCS - This is an array of the names of permitted
PHP functions used as variable modifiers.
</para>
</listitem>
<listitem>
<para>
ALLOW_CONSTANTS - true/false. If set to true, constants via
<link linkend="language.variables.smarty.const">{$smarty.const.name}</link>
are allowed in the templates. The defaults is set to
"false" for security.
</para>
</listitem>
</itemizedlist>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -8,20 +8,39 @@
(via ftp for example) and you want to reduce the risk of system
security compromises through the template language. Turning on
security enforces the following rules to the template language,
unless specifially overridden with $security_settings:
unless specifially overridden with
<link linkend="variable.security.settings">$security_settings</link>:
</para>
<itemizedlist>
<listitem><para>If $php_handling is set to SMARTY_PHP_ALLOW, this is
implicitly changed to SMARTY_PHP_PASSTHRU</para></listitem>
<listitem><para>PHP functions are not allowed in IF statements,
except those specified in the $security_settings</para></listitem>
<listitem><para>templates can only be included from directories
listed in the $secure_dir array</para></listitem>
<listitem><para>local files can only be fetched from directories
listed in the $secure_dir array using {fetch}</para></listitem>
<listitem><para>{php}{/php} tags are not allowed</para></listitem>
<listitem><para>PHP functions are not allowed as modifiers, except
those specified in the $security_settings</para></listitem>
<listitem>
<para>If <link linkend="variable.php.handling">$php_handling</link>
is set to SMARTY_PHP_ALLOW, this is
implicitly changed to SMARTY_PHP_PASSTHRU
</para></listitem>
<listitem>
<para>
PHP functions are not allowed in <link
linkend="language.function.if">{if}</link> statements,
except those specified in the
<link linkend="variable.security.settings">$security_settings</link>
</para></listitem>
<listitem><para>
templates can only be included from directories
listed in the
<link linkend="variable.secure.dir">$secure_dir</link> array
</para></listitem>
<listitem><para>
local files can only be fetched from directories listed in the
<link linkend="variable.secure.dir">$secure_dir</link>
array using <link linkend="language.function.fetch">{fetch}</link>
</para></listitem>
<listitem><para>
<link linkend="language.function.php">{php}{/php}</link> tags are not allowed
</para></listitem>
<listitem><para>
PHP functions are not allowed as modifiers, except those specified in the
<link linkend="variable.security.settings">$security_settings</link>
</para></listitem>
</itemizedlist>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -3,9 +3,11 @@
<sect1 id="variable.trusted.dir">
<title>$trusted_dir</title>
<para>
$trusted_dir is only for use when $security is enabled. This is an array
of all directories that are considered trusted. Trusted directories are
where you keep php scripts that are executed directly from the templates
$trusted_dir is only for use when
<link linkend="variable.security">$security</link> is enabled.
This is an array of all directories that are considered trusted.
Trusted directories are where you keep php scripts that are executed
directly from the templates
with <link linkend="language.function.include.php">{include_php}</link>.
</para>
</sect1>

View File

@@ -9,7 +9,9 @@
cached version of the call is available, that is displayed instead of
regenerating the output. Caching can speed things up tremendously,
especially templates with longer computation times. Since the output of
display() or fetch() is cached, one cache file could conceivably be made up
<link linkend="api.display">display()</link> or
<link linkend="api.fetch">fetch()</link> is cached,
one cache file could conceivably be made up
of several template files, config files, etc.
</para>
<para>

View File

@@ -31,7 +31,9 @@ $smarty->display('index.tpl');
<note>
<title>Technical Note</title>
<para>
The files in the $cache_dir are named similar to the template name.
The files in the
<link linkend="variable.cache.dir">$cache_dir</link>
are named similar to the template name.
Although they end in the ".php" extention, they are not really executable
php scripts. Do not edit these files!
</para>
@@ -41,7 +43,9 @@ $smarty->display('index.tpl');
linkend="variable.cache.lifetime">$cache_lifetime</link>. The default value
is 3600 seconds, or 1 hour. After that time expires, the cache is
regenerated. It is possible to give individual caches their own expiration
time by setting $caching = 2. See the documentation on <link
time by setting
<link linkend="variable.caching">$caching</link> = 2.
See the documentation on <link
linkend="variable.cache.lifetime">$cache_lifetime</link> for details.
</para>
<example>
@@ -77,7 +81,9 @@ $smarty->display('home.tpl');
every template file and config file that is involved with the cache file is
checked for modification. If any of the files have been modified since the
cache was generated, the cache is immediately regenerated. This is a slight
overhead so for optimum performance, leave $compile_check set to false.
overhead so for optimum performance, leave
<link linkend="variable.compile.check">$compile_check</link>
set to false.
</para>
<example>
<title>enabling $compile_check</title>
@@ -98,7 +104,9 @@ $smarty->display('index.tpl');
<para>
If <link linkend="variable.force.compile">$force_compile</link> is enabled,
the cache files will always be regenerated. This effectively turns off
caching. $force_compile is usually for debugging purposes only, a more
caching.
<link linkend="variable.force.compile">$force_compile</link>
is usually for debugging purposes only, a more
efficient way of disabling caching is to set <link
linkend="variable.caching">$caching</link> = false (or 0.)
</para>
@@ -131,11 +139,11 @@ $smarty->display('index.tpl');
</example>
<para>
You can keep parts of a page dynamic with the <link
linkend="language.function.insert">insert</link> template function. Let's
linkend="language.function.insert">{insert}</link> template function. Let's
say the whole page can be cached except for a banner that is displayed down
the right side of the page. By using an insert function for the banner, you
can keep this element dynamic within the cached content. See the
documentation on <link linkend="language.function.insert">insert</link> for
documentation on <link linkend="language.function.insert">{insert}</link> for
details and examples.
</para>
<para>

View File

@@ -24,13 +24,19 @@ require_once(SMARTY_DIR."Smarty.class.php");
]]>
</programlisting>
</example>
<para>
See also
<link linkend="language.variables.smarty.const">$smarty.const</link>
</para>
</sect1>
<sect1 id="constant.smarty.core.dir">
<title>SMARTY_CORE_DIR</title>
<para>
This should be the full system path to the location of the Smarty core
files. If not defined, Smarty will default this constant to the internals/
sub-directory below SMARTY_DIR. If defined, the path must end with a slash.
sub-directory below
<link linkend="constant.smarty.dir">SMARTY_DIR</link>.
If defined, the path must end with a slash.
Use this constant when manually including any of the core.* files.
</para>
<example>
@@ -45,6 +51,11 @@ require_once(SMARTY_CORE_DIR."core.get_microtime.php");
]]>
</programlisting>
</example>
<para>
See also
<link linkend="language.variables.smarty.const">$smarty.const</link>
</para>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file