mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
more linking and WS from Peter
This commit is contained in:
@@ -6,7 +6,8 @@
|
|||||||
It is sometimes desirable or even necessary to have Smarty ignore sections it
|
It is sometimes desirable or even necessary to have Smarty ignore sections it
|
||||||
would otherwise parse. A classic example is embedding Javascript or CSS code in
|
would otherwise parse. A classic example is embedding Javascript or CSS code in
|
||||||
a template. The problem arises as those languages use the { and } characters
|
a template. The problem arises as those languages use the { and } characters
|
||||||
which are also the default delimiters for Smarty.
|
which are also the default
|
||||||
|
<link linkend="language.function.ldelim">delimiters</link> for Smarty.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -50,10 +51,10 @@ $smarty->display('example.tpl');
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<script language="javascript">
|
<script language="javascript">
|
||||||
var foo = <!--{$foo}-->;
|
var foo = 'bar';
|
||||||
function dosomething() {
|
function dosomething() {
|
||||||
alert("foo is " + foo);
|
alert("foo is " + foo);
|
||||||
}
|
}
|
||||||
dosomething();
|
dosomething();
|
||||||
</script>
|
</script>
|
||||||
]]>
|
]]>
|
||||||
|
@@ -25,6 +25,10 @@
|
|||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also <link linkend="language.function.math">{math}</link> function.
|
||||||
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -3,7 +3,8 @@
|
|||||||
<sect1 id="language.syntax.attributes">
|
<sect1 id="language.syntax.attributes">
|
||||||
<title>Attributes</title>
|
<title>Attributes</title>
|
||||||
<para>
|
<para>
|
||||||
Most of the functions take attributes that specify or modify
|
Most of the <link linkend="language.syntax.functions">functions</link>
|
||||||
|
take attributes that specify or modify
|
||||||
their behavior. Attributes to Smarty functions are much like HTML
|
their behavior. Attributes to Smarty functions are much like HTML
|
||||||
attributes. Static values don't have to be enclosed in quotes, but it
|
attributes. Static values don't have to be enclosed in quotes, but it
|
||||||
is recommended for literal strings. Variables may also be used, and
|
is recommended for literal strings. Variables may also be used, and
|
||||||
@@ -22,14 +23,16 @@
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
{include file="header.tpl"}
|
{include file="header.tpl"}
|
||||||
|
|
||||||
|
{include file="header.tpl" attrib_name="attrib value"}
|
||||||
|
|
||||||
{include file=$includeFile}
|
{include file=$includeFile}
|
||||||
|
|
||||||
{include file=#includeFile#}
|
{include file=#includeFile# title="Smarty is cool"}
|
||||||
|
|
||||||
{html_select_date display_days=yes}
|
{html_select_date display_days=yes}
|
||||||
|
|
||||||
<select name="company">
|
<select name="company">
|
||||||
{html_options values=$vals selected=$selected output=$output}
|
{html_options options=$choices selected=$selected}
|
||||||
</select>
|
</select>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@@ -4,27 +4,38 @@
|
|||||||
<title>Comments</title>
|
<title>Comments</title>
|
||||||
<para>
|
<para>
|
||||||
Template comments are surrounded by asterisks, and that is surrounded
|
Template comments are surrounded by asterisks, and that is surrounded
|
||||||
by the delimiter tags like so: {* this is a comment *}
|
by the
|
||||||
Smarty comments are not displayed in the final output of the template.
|
<link linkend="variable.left.delimiter"> delimiter</link>
|
||||||
They are used for making internal notes in the templates.
|
tags like so: {* this is a comment *}
|
||||||
|
Smarty comments are NOT displayed in the final output of the template,
|
||||||
|
unlike <!-- HTML comments -->
|
||||||
|
They are useful for making internal notes in the templates.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Comments</title>
|
<title>Comments</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* Smarty *}
|
<body>
|
||||||
|
{* this multiline
|
||||||
|
comment is
|
||||||
|
not sent to browser
|
||||||
|
*}
|
||||||
|
|
||||||
{* include the header file here *}
|
{* include the header file here *}
|
||||||
{include file="header.tpl"}
|
{include file="header.tpl"}
|
||||||
|
|
||||||
|
|
||||||
|
{* Dev note: $includeFile is assigned foo.php script *}
|
||||||
|
<!-- this html comment is sent to browser -->
|
||||||
{include file=$includeFile}
|
{include file=$includeFile}
|
||||||
|
|
||||||
{include file=#includeFile#}
|
{include file=#includeFile#}
|
||||||
|
|
||||||
{* display dropdown lists *}
|
{* display dropdown lists *}
|
||||||
<select name="company">
|
<select name="company">
|
||||||
{html_options values=$vals selected=$selected output=$output}
|
{html_options options=$vals selected=$selected_id}
|
||||||
</select>
|
</select>
|
||||||
|
</body>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
Each Smarty tag either prints a
|
Each Smarty tag either prints a
|
||||||
<link linkend="language.variables">variable</link> or invokes some sort
|
<link linkend="language.variables">variable</link> or invokes some sort
|
||||||
of function. Functions are processed and displayed by enclosing the
|
of function. Functions are processed and displayed by enclosing the
|
||||||
function and its attributes into delimiters like so: {funcname
|
function and its
|
||||||
|
<link linkend="language.syntax.attributes">attributes</link>
|
||||||
|
into delimiters like so: {funcname
|
||||||
attr1="val" attr2="val"}.
|
attr1="val" attr2="val"}.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
@@ -30,16 +32,20 @@
|
|||||||
<para>
|
<para>
|
||||||
Both <link linkend="language.builtin.functions">built-in functions</link>
|
Both <link linkend="language.builtin.functions">built-in functions</link>
|
||||||
and <link linkend="language.custom.functions">custom functions</link>
|
and <link linkend="language.custom.functions">custom functions</link>
|
||||||
have the same syntax in the templates. Built-in functions are the
|
have the same syntax within templates.
|
||||||
inner workings of Smarty, such as
|
</para>
|
||||||
|
<para>Built-in functions are the
|
||||||
|
<emphasis role="bold">inner</emphasis> workings of Smarty, such as
|
||||||
<link linkend="language.function.if">{if}</link>,
|
<link linkend="language.function.if">{if}</link>,
|
||||||
<link linkend="language.function.section">{section}</link> and
|
<link linkend="language.function.section">{section}</link> and
|
||||||
<link linkend="language.function.strip">{strip}</link>.
|
<link linkend="language.function.strip">{strip}</link>.
|
||||||
They cannot be modified. Custom functions are
|
They cannot be modified.
|
||||||
additional functions implemented via <link linkend="plugins">plugins</link>.
|
</para>
|
||||||
|
<para>Custom functions are <emphasis role="bold">additional</emphasis>
|
||||||
|
functions implemented via <link linkend="plugins">plugins</link>.
|
||||||
They can be modified to your liking, or you can add new ones.
|
They can be modified to your liking, or you can add new ones.
|
||||||
<link linkend="language.function.html.options">{html_options}</link> and
|
<link linkend="language.function.html.options">{html_options}</link> and
|
||||||
<link linkend="language.function.html.select.date">{html_select_date}</link>
|
<link linkend="language.function.popup">{popup}</link>
|
||||||
are examples of custom functions.
|
are examples of custom functions.
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<sect1 id="language.syntax.variables">
|
<sect1 id="language.syntax.variables">
|
||||||
<title>Variables</title>
|
<title>Variables</title>
|
||||||
<para>
|
<para>
|
||||||
Template variables start with a dollar sign. They can contain numbers,
|
Template variables start with a $dollar sign. They can contain numbers,
|
||||||
letters and underscores, much like a
|
letters and underscores, much like a
|
||||||
<ulink url="&url.php-manual;language.variables">PHP variable</ulink>.
|
<ulink url="&url.php-manual;language.variables">PHP variable</ulink>.
|
||||||
You can reference arrays
|
You can reference arrays
|
||||||
|
@@ -74,15 +74,15 @@
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* we don't want to print a table row unless content is displayed *}
|
{* we don't want to print a table row unless content is displayed *}
|
||||||
{capture name=banner}
|
{capture name=banner}
|
||||||
{include file="get_banner.tpl"}
|
{include file="get_banner.tpl"}
|
||||||
{/capture}
|
{/capture}
|
||||||
|
|
||||||
{if $smarty.capture.banner ne ''}
|
{if $smarty.capture.banner ne ''}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{$smarty.capture.banner}
|
{$smarty.capture.banner}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -91,7 +91,10 @@
|
|||||||
</example>
|
</example>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="language.function.eval">{eval}</link>,
|
See also
|
||||||
|
<link
|
||||||
|
linkend="language.variables.smarty.capture">$smarty.capture</link>,
|
||||||
|
<link linkend="language.function.eval">{eval}</link>,
|
||||||
<link linkend="language.function.fetch">{fetch}</link>,
|
<link linkend="language.function.fetch">{fetch}</link>,
|
||||||
<link linkend="api.fetch">fetch()</link>
|
<link linkend="api.fetch">fetch()</link>
|
||||||
and <link linkend="language.function.assign">{assign}</link>.
|
and <link linkend="language.function.assign">{assign}</link>.
|
||||||
|
@@ -66,18 +66,35 @@
|
|||||||
<para>
|
<para>
|
||||||
{config_load} is used for loading config
|
{config_load} is used for loading config
|
||||||
<link linkend="language.config.variables">#variables#</link> from a
|
<link linkend="language.config.variables">#variables#</link> from a
|
||||||
configuration file into the template.
|
<link linkend="config.files">configuration file</link> into the template.
|
||||||
See <link linkend="config.files">Config Files</link> for more
|
|
||||||
info.
|
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>{config_load}</title>
|
<title>{config_load}</title>
|
||||||
|
<para>
|
||||||
|
example.conf
|
||||||
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{config_load file="colors.conf"}
|
#this is config file comment
|
||||||
|
|
||||||
|
# global variables
|
||||||
|
pageTitle = "Main Menu"
|
||||||
|
bodyBgColor = #000000
|
||||||
|
tableBgColor = #000000
|
||||||
|
rowBgColor = #00ff00
|
||||||
|
|
||||||
|
#customer variables section
|
||||||
|
[Customer]
|
||||||
|
pageTitle = "Customer Info"
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>and the template</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
{config_load file="example.conf"}
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<title>{#pageTitle#}</title>
|
<title>{#pageTitle#|default:"No title"}</title>
|
||||||
<body bgcolor="{#bodyBgColor#}">
|
<body bgcolor="{#bodyBgColor#}">
|
||||||
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
||||||
<tr bgcolor="{#rowBgColor#}">
|
<tr bgcolor="{#rowBgColor#}">
|
||||||
@@ -95,21 +112,23 @@
|
|||||||
<link linkend="config.files">Config Files</link>
|
<link linkend="config.files">Config Files</link>
|
||||||
may also contain sections. You can load variables from
|
may also contain sections. You can load variables from
|
||||||
within a section with the added attribute
|
within a section with the added attribute
|
||||||
<emphasis>section</emphasis>.
|
<emphasis>'section'</emphasis>.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
<emphasis>Config file sections</emphasis> and the built-in
|
<emphasis>Config file sections</emphasis> and the built-in
|
||||||
template function called <emphasis>section</emphasis> have nothing
|
template function called
|
||||||
|
<link linkend="language.function.section"><emphasis>{section}</emphasis></link>
|
||||||
|
have nothing
|
||||||
to do with each other, they just happen to share a common naming
|
to do with each other, they just happen to share a common naming
|
||||||
convention.
|
convention.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<example>
|
<example>
|
||||||
<title>function config_load with section</title>
|
<title>function {config_load} with section</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{config_load file="colors.conf" section="Customer"}
|
{config_load file="example.conf" section="Customer"}
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<title>{#pageTitle#}</title>
|
<title>{#pageTitle#}</title>
|
||||||
|
@@ -75,20 +75,20 @@
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>{foreach} - item</title>
|
<title>{foreach} - item</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$arr = array( 1001,1002,1003);
|
$arr = array( 1001,1002,1003);
|
||||||
$smarty->assign('custid', $arr);
|
$smarty->assign('custid', $arr);
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* this example will print out all the values of the $custid array *}
|
{* this example will print out all the values of the $custid array *}
|
||||||
{foreach from=$custid item=curr_id}
|
{foreach from=$custid item=curr_id}
|
||||||
id: {$curr_id}<br />
|
id: {$curr_id}<br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
@@ -96,51 +96,54 @@
|
|||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
id: 1000<br />
|
id: 1000<br />
|
||||||
id: 1001<br />
|
id: 1001<br />
|
||||||
id: 1002<br />
|
id: 1002<br />
|
||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>{foreach} - item and key</title>
|
<title>{foreach} - item and key</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
// The key contains the key for each looped value
|
// The key contains the key for each looped value
|
||||||
// assignment looks like this:
|
// assignment looks like this:
|
||||||
<?php
|
<?php
|
||||||
$smarty->assign("contacts", array(
|
$smarty->assign('contacts', array(
|
||||||
array("phone" => "1",
|
array('phone' => '1',
|
||||||
"fax" => "2",
|
'fax' => '2',
|
||||||
"cell" => "3"),
|
'cell' => '3'),
|
||||||
array("phone" => "555-4444",
|
array('phone' => '555-4444',
|
||||||
"fax" => "555-3333",
|
'fax' => '555-3333',
|
||||||
"cell" => "760-1234"))
|
'cell' => '760-1234')
|
||||||
);
|
));
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{foreach name=outer item=contact from=$contacts}
|
{foreach name=outer item=contact from=$contacts}
|
||||||
{foreach key=key item=item from=$contact}
|
<hr />
|
||||||
{$key}: {$item}<br />
|
{foreach key=key item=item from=$contact}
|
||||||
{/foreach}
|
{$key}: {$item}<br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
]]>
|
{/foreach}
|
||||||
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
The above example will output:
|
The above example will output:
|
||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
phone: 1<br />
|
<hr />
|
||||||
fax: 2<br />
|
phone: 1<br />
|
||||||
cell: 3<br />
|
fax: 2<br />
|
||||||
phone: 555-4444<br />
|
cell: 3<br />
|
||||||
fax: 555-3333<br />
|
<hr />
|
||||||
cell: 760-1234<br />
|
phone: 555-4444<br />
|
||||||
|
fax: 555-3333<br />
|
||||||
|
cell: 760-1234<br />
|
||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
@@ -154,14 +157,14 @@
|
|||||||
$smarty->assign("contacts", $db->getAssoc($sql));
|
$smarty->assign("contacts", $db->getAssoc($sql));
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{foreach key=cid item=con from=$contacts}
|
{foreach key=cid item=con from=$contacts}
|
||||||
<a href="contact.php?contact_id={$cid}">{$con.name} - {$con.nick}</a><br />
|
<a href="contact.php?contact_id={$cid}">{$con.name} - {$con.nick}</a><br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
@@ -174,6 +177,10 @@
|
|||||||
attribute of foreach
|
attribute of foreach
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>See <link linkend="section.property.index">{section}</link>
|
||||||
|
for examples of the properties below as they are identical
|
||||||
|
</para>
|
||||||
|
|
||||||
<sect2 id="foreach.property.iteration">
|
<sect2 id="foreach.property.iteration">
|
||||||
<title>iteration</title>
|
<title>iteration</title>
|
||||||
<para>
|
<para>
|
||||||
@@ -220,6 +227,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
mode: sgml
|
mode: sgml
|
||||||
|
@@ -3,7 +3,8 @@
|
|||||||
<sect1 id="language.function.if">
|
<sect1 id="language.function.if">
|
||||||
<title>{if},{elseif},{else}</title>
|
<title>{if},{elseif},{else}</title>
|
||||||
<para>
|
<para>
|
||||||
<emphasis>{if}</emphasis> statements in Smarty have much the same flexibility as PHP if
|
<emphasis>{if}</emphasis> statements in Smarty have much the same flexibility as PHP
|
||||||
|
<ulink url="&url.php-manual;if"><command>if</command></ulink>
|
||||||
statements, with a few added features for the template engine.
|
statements, with a few added features for the template engine.
|
||||||
Every <emphasis>{if}</emphasis> must be paired with an
|
Every <emphasis>{if}</emphasis> must be paired with an
|
||||||
<emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and
|
<emphasis>{/if}</emphasis>. <emphasis>{else}</emphasis> and
|
||||||
@@ -137,70 +138,74 @@
|
|||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
<example>
|
<example>
|
||||||
<title>if statements</title>
|
<title>{if} statements</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{if $name eq "Fred"}
|
{if $name eq "Fred"}
|
||||||
Welcome Sir.
|
Welcome Sir.
|
||||||
{elseif $name eq "Wilma"}
|
{elseif $name eq "Wilma"}
|
||||||
Welcome Ma'am.
|
Welcome Ma'am.
|
||||||
{else}
|
{else}
|
||||||
Welcome, whatever you are.
|
Welcome, whatever you are.
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* an example with "or" logic *}
|
{* an example with "or" logic *}
|
||||||
{if $name eq "Fred" or $name eq "Wilma"}
|
{if $name eq "Fred" or $name eq "Wilma"}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* same as above *}
|
{* same as above *}
|
||||||
{if $name == "Fred" || $name == "Wilma"}
|
{if $name == "Fred" || $name == "Wilma"}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* the following syntax will NOT work, conditional qualifiers
|
{*
|
||||||
must be separated from surrounding elements by spaces *}
|
the following syntax will NOT work, conditional qualifiers
|
||||||
{if $name=="Fred" || $name=="Wilma"}
|
must be separated from surrounding elements by spaces
|
||||||
|
*}
|
||||||
|
{if $name=="Fred" || $name=="Wilma"}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
{* parenthesis are allowed *}
|
{* parenthesis are allowed *}
|
||||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* you can also embed php function calls *}
|
{* you can also embed php function calls *}
|
||||||
{if count($var) gt 0}
|
{if count($var) gt 0}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* test if values are even or odd *}
|
{* test if values are even or odd *}
|
||||||
{if $var is even}
|
{if $var is even}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
{if $var is odd}
|
{if $var is odd}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
{if $var is not odd}
|
{if $var is not odd}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* test if var is divisible by 4 *}
|
{* test if var is divisible by 4 *}
|
||||||
{if $var is div by 4}
|
{if $var is div by 4}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* test if var is even, grouped by two. i.e.,
|
{*
|
||||||
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
|
test if var is even, grouped by two. i.e.,
|
||||||
{if $var is even by 2}
|
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc.
|
||||||
|
*}
|
||||||
|
{if $var is even by 2}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
|
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
|
||||||
{if $var is even by 3}
|
{if $var is even by 3}
|
||||||
...
|
...
|
||||||
{/if}
|
{/if}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@@ -48,28 +48,30 @@
|
|||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
include_php is pretty much deprecated from Smarty, you can
|
{include_php} is pretty much deprecated from Smarty, you can
|
||||||
accomplish the same functionality via a custom template function.
|
accomplish the same functionality via a custom template function.
|
||||||
The only reason to use include_php is if you really have a need to
|
The only reason to use {include_php} is if you really have a need to
|
||||||
quarantine the php function away from the plugin directory or your
|
quarantine the php function away from the
|
||||||
|
<link linkend="variable.plugins.dir">plugins</link>
|
||||||
|
directory or your
|
||||||
application code. See the <link
|
application code. See the <link
|
||||||
linkend="tips.componentized.templates">componentized template
|
linkend="tips.componentized.templates">componentized template
|
||||||
example</link> for details.
|
example</link> for details.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
include_php tags are used to include a php script in your template.
|
{include_php} tags are used to include a php script in your template.
|
||||||
If <link linkend="variable.security">security is enabled</link>,
|
If <link linkend="variable.security">security is enabled</link>,
|
||||||
then the php script must be located in the <link
|
then the php script must be located in the <link
|
||||||
linkend="variable.trusted.dir">$trusted_dir</link> path.
|
linkend="variable.trusted.dir">$trusted_dir</link> path.
|
||||||
The include_php tag must have the attribute
|
The {include_php} tag must have the attribute
|
||||||
"file", which contains the path to the included php file, either
|
"file", which contains the path to the included php file, either
|
||||||
relative to
|
relative to
|
||||||
<link linkend="variable.trusted.dir">$trusted_dir</link>,
|
<link linkend="variable.trusted.dir">$trusted_dir</link>,
|
||||||
or an absolute path.
|
or an absolute path.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
include_php is a nice way to handle <link
|
{include_php} is a nice way to handle <link
|
||||||
linkend="tips.componentized.templates">componentized templates</link>, and
|
linkend="tips.componentized.templates">componentized templates</link>, and
|
||||||
keep PHP code separate from the template files. Lets say you have a
|
keep PHP code separate from the template files. Lets say you have a
|
||||||
template that shows your site navigation, which is pulled
|
template that shows your site navigation, which is pulled
|
||||||
@@ -89,7 +91,7 @@
|
|||||||
<para>
|
<para>
|
||||||
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
||||||
which will specify a template variable name that the output of
|
which will specify a template variable name that the output of
|
||||||
<emphasis>include_php</emphasis> will be assigned to instead of
|
<emphasis>{include_php}</emphasis> will be assigned to instead of
|
||||||
displayed.
|
displayed.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@@ -97,34 +99,32 @@
|
|||||||
include.
|
include.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function include_php</title>
|
<title>function {include_php}</title>
|
||||||
<programlisting>
|
<para>load_nav.php</para>
|
||||||
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
load_nav.php
|
<?php
|
||||||
-------------
|
|
||||||
|
|
||||||
<?php
|
// load in variables from a mysql db and assign them to the template
|
||||||
|
require_once("MySQL.class.php");
|
||||||
|
$sql = new MySQL;
|
||||||
|
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
|
||||||
|
$this->assign('sections',$sql->record);
|
||||||
|
|
||||||
// load in variables from a mysql db and assign them to the template
|
?>
|
||||||
require_once("MySQL.class.php");
|
|
||||||
$sql = new MySQL;
|
|
||||||
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
|
|
||||||
$this->assign('sections',$sql->record);
|
|
||||||
|
|
||||||
?>
|
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
Where index.pl is:
|
Where index.tpl is:
|
||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* absolute path, or relative to $trusted_dir *}
|
{* absolute path, or relative to $trusted_dir *}
|
||||||
{include_php file="/path/to/load_nav.php"}
|
{include_php file="/path/to/load_nav.php"}
|
||||||
|
|
||||||
{foreach item="curr_section" from=$sections}
|
{foreach item="curr_section" from=$sections}
|
||||||
<a href="{$curr_section.url}">{$curr_section.name}</a><br />
|
<a href="{$curr_section.url}">{$curr_section.name}</a><br />
|
||||||
{/foreach}
|
{/foreach}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@@ -51,20 +51,28 @@
|
|||||||
the attribute "file", which contains the template resource path.
|
the attribute "file", which contains the template resource path.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
You can optionally pass the <emphasis>assign</emphasis> attribute,
|
You can optionally pass the <emphasis>'assign'</emphasis> attribute,
|
||||||
which will specify a template variable name that the output of
|
which will specify a template variable name that the output of
|
||||||
{include} will be assigned to instead of
|
{include} will be assigned to instead of
|
||||||
displayed.
|
displayed.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function include</title>
|
<title>function {include}</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{include file="header.tpl"}
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{$title}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{include file="page_header.tpl"}
|
||||||
|
|
||||||
{* body of template goes here *}
|
{* body of template goes here *}
|
||||||
|
{include file="/$tpl_name.tpl"} <-- will replace $tpl_name with value
|
||||||
|
|
||||||
{include file="footer.tpl"}
|
{include file="page_footer.tpl"}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
@@ -76,17 +84,51 @@
|
|||||||
the case they are named alike.
|
the case they are named alike.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function include passing variables</title>
|
<title>{include} passing variables</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||||
|
|
||||||
{* body of template goes here *}
|
{* body of template goes here *}
|
||||||
|
|
||||||
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
|
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
<para>where header.tpl could be</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
<table border='1' width='100%' bgcolor='{$table_bgcolor|default:"#0000FF"}'>
|
||||||
|
<tr><td>
|
||||||
|
<h1>{$title}</h1>
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
|
||||||
|
<example>
|
||||||
|
<title>{include} and assign to variable</title>
|
||||||
|
<para>This example assign the contents of nav.tpl to a variable
|
||||||
|
and outputs at the top of page and the bottom.
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
<body>
|
||||||
|
{include file="nav.tpl" assign="navbar"}
|
||||||
|
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||||
|
{$navbar}
|
||||||
|
|
||||||
|
{* body of template goes here *}
|
||||||
|
|
||||||
|
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
|
||||||
|
{$navbar}
|
||||||
|
</body>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Use the syntax for <link
|
Use the syntax for <link
|
||||||
linkend="template.resources">template resources</link> to
|
linkend="template.resources">template resources</link> to
|
||||||
@@ -94,20 +136,20 @@
|
|||||||
directory.
|
directory.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function include template resource examples</title>
|
<title>{include} template resource examples</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* absolute filepath *}
|
{* absolute filepath *}
|
||||||
{include file="/usr/local/include/templates/header.tpl"}
|
{include file="/usr/local/include/templates/header.tpl"}
|
||||||
|
|
||||||
{* absolute filepath (same thing) *}
|
{* absolute filepath (same thing) *}
|
||||||
{include file="file:/usr/local/include/templates/header.tpl"}
|
{include file="file:/usr/local/include/templates/header.tpl"}
|
||||||
|
|
||||||
{* windows absolute filepath (MUST use "file:" prefix) *}
|
{* windows absolute filepath (MUST use "file:" prefix) *}
|
||||||
{include file="file:C:/www/pub/templates/header.tpl"}
|
{include file="file:C:/www/pub/templates/header.tpl"}
|
||||||
|
|
||||||
{* include from template resource named "db" *}
|
{* include from template resource named "db" *}
|
||||||
{include file="db:header.tpl"}
|
{include file="db:header.tpl"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@@ -54,8 +54,8 @@
|
|||||||
</informaltable>
|
</informaltable>
|
||||||
<para>
|
<para>
|
||||||
Insert tags work much like <link
|
Insert tags work much like <link
|
||||||
linkend="language.function.include">include</link> tags,
|
linkend="language.function.include">{include}</link> tags,
|
||||||
except that insert tags are not cached when you have
|
except that {insert} tags are not cached when you have
|
||||||
template <link linkend="caching">caching</link> enabled. They
|
template <link linkend="caching">caching</link> enabled. They
|
||||||
will be executed on every invocation of the template.
|
will be executed on every invocation of the template.
|
||||||
</para>
|
</para>
|
||||||
@@ -64,57 +64,60 @@
|
|||||||
the page. The banner can contain any mixture of HTML, images,
|
the page. The banner can contain any mixture of HTML, images,
|
||||||
flash, etc. so we can't just use a static link here, and we
|
flash, etc. so we can't just use a static link here, and we
|
||||||
don't want this contents cached with the page. In comes the
|
don't want this contents cached with the page. In comes the
|
||||||
insert tag: the template knows #banner_location_id# and
|
{insert} tag: the template knows #banner_location_id# and
|
||||||
#site_id# values (gathered from a config file), and needs to
|
#site_id# values (gathered from a
|
||||||
|
<link linkend="config.files">config file</link>), and needs to
|
||||||
call a function to get the banner contents.
|
call a function to get the banner contents.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function insert</title>
|
<title>function {insert}</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{* example of fetching a banner *}
|
{* example of fetching a banner *}
|
||||||
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}
|
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
In this example, we are using the name "getBanner" and passing the
|
In this example, we are using the name "getBanner" and passing the
|
||||||
parameters #banner_location_id# and #site_id#. Smarty will look
|
parameters #banner_location_id# and #site_id#. Smarty will look
|
||||||
for a function named insert_getBanner() in your PHP application, passing
|
for a function named insert_getBanner() in your PHP application, passing
|
||||||
the values of #banner_location_id# and #site_id# as the first argument
|
the values of #banner_location_id# and #site_id# as the first argument
|
||||||
in an associative array. All insert function names in
|
in an associative array. All {insert} function names in
|
||||||
your application must be prepended with "insert_" to remedy possible
|
your application must be prepended with "insert_" to remedy possible
|
||||||
function name-space conflicts. Your insert_getBanner() function should
|
function name-space conflicts. Your insert_getBanner() function should
|
||||||
do something with the passed values and return the results. These results
|
do something with the passed values and return the results. These results
|
||||||
are then displayed in the template in place of the insert tag.
|
are then displayed in the template in place of the {insert} tag.
|
||||||
In this example, Smarty would call this function:
|
In this example, Smarty would call this function:
|
||||||
insert_getBanner(array("lid" => "12345","sid" => "67890"));
|
insert_getBanner(array("lid" => "12345","sid" => "67890"));
|
||||||
and display the returned results in place of the insert tag.
|
and display the returned results in place of the {insert} tag.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you supply the "assign" attribute, the output of the insert tag
|
If you supply the "assign" attribute, the output of the {insert} tag
|
||||||
will be assigned to this template variable instead of being output
|
will be assigned to this template variable instead of being output
|
||||||
to the template. NOTE: assigning the output to a template variable
|
to the template. NOTE: assigning the output to a template variable
|
||||||
isn't too useful with caching enabled.
|
isn't too useful with
|
||||||
|
<link linkend="variable.caching">caching</link> enabled.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you supply the "script" attribute, this php script will be
|
If you supply the "script" attribute, this php script will be
|
||||||
included (only once) before the insert function is executed. This
|
included (only once) before the {insert} function is executed. This
|
||||||
is the case where the insert function may not exist yet, and a php
|
is the case where the insert function may not exist yet, and a php
|
||||||
script must be included first to make it work. The path can be
|
script must be included first to make it work. The path can be
|
||||||
either absolute, or relative to $trusted_dir. When <link
|
either absolute, or relative to
|
||||||
|
<link linkend="variable.trusted.dir">$trusted_dir</link>. When <link
|
||||||
linkend="variable.security">security is enabled</link>, the script
|
linkend="variable.security">security is enabled</link>, the script
|
||||||
must reside in <link linkend="variable.trusted.dir">$trusted_dir</link>.
|
must reside in <link linkend="variable.trusted.dir">$trusted_dir</link>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The Smarty object is passed as the second argument. This way you
|
The Smarty object is passed as the second argument. This way you
|
||||||
can reference and modify information in the Smarty object from
|
can reference and modify information in the Smarty object from
|
||||||
within the insert function.
|
within the {insert} function.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
It is possible to have portions of the template not
|
It is possible to have portions of the template not
|
||||||
cached. If you have <link linkend="caching">caching</link>
|
cached. If you have <link linkend="caching">caching</link>
|
||||||
turned on, insert tags will not be cached. They will run
|
turned on, {insert} tags will not be cached. They will run
|
||||||
dynamically every time the page is created, even within cached
|
dynamically every time the page is created, even within cached
|
||||||
pages. This works good for things like banners, polls, live
|
pages. This works good for things like banners, polls, live
|
||||||
weather, search results, user feedback areas, etc.
|
weather, search results, user feedback areas, etc.
|
||||||
|
@@ -3,7 +3,9 @@
|
|||||||
<sect1 id="language.function.ldelim">
|
<sect1 id="language.function.ldelim">
|
||||||
<title>{ldelim},{rdelim}</title>
|
<title>{ldelim},{rdelim}</title>
|
||||||
<para>
|
<para>
|
||||||
ldelim and rdelim are used for escaping template delimiters, in our case
|
{ldelim} and {rdelim} are used for
|
||||||
|
<link linkend="language.escaping">escaping</link>
|
||||||
|
template delimiters, by default
|
||||||
"{" or "}". You can also use <link
|
"{" or "}". You can also use <link
|
||||||
linkend="language.function.literal">{literal}{/literal}</link> to escape
|
linkend="language.function.literal">{literal}{/literal}</link> to escape
|
||||||
blocks of text.
|
blocks of text.
|
||||||
@@ -11,7 +13,7 @@
|
|||||||
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>.
|
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>ldelim, rdelim</title>
|
<title>{ldelim}, {rdelim}</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* this will print literal delimiters out of the template *}
|
{* this will print literal delimiters out of the template *}
|
||||||
|
@@ -5,14 +5,16 @@
|
|||||||
<para>
|
<para>
|
||||||
{literal} tags allow a block of data to be taken literally. This is typically
|
{literal} tags allow a block of data to be taken literally. This is typically
|
||||||
used around javascript or stylesheet blocks where curly braces would
|
used around javascript or stylesheet blocks where curly braces would
|
||||||
interfere with the template delimiter syntax. Anything within
|
interfere with the template
|
||||||
|
<link linkend="variable.left.delimiter">delimiter</link>
|
||||||
|
syntax. Anything within
|
||||||
{literal}{/literal} tags is not interpreted, but displayed as-is. If you
|
{literal}{/literal} tags is not interpreted, but displayed as-is. If you
|
||||||
need template tags embedded in your literal block, consider using <link
|
need template tags embedded in your {literal} block, consider using <link
|
||||||
linkend="language.function.ldelim">{ldelim}{rdelim}</link> to escape the
|
linkend="language.function.ldelim">{ldelim}{rdelim}</link> to escape the
|
||||||
individual delimiters instead.
|
individual delimiters instead.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>literal tags</title>
|
<title>{literal} tags</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{literal}
|
{literal}
|
||||||
|
@@ -9,17 +9,26 @@
|
|||||||
is for advanced users only, not normally needed.
|
is for advanced users only, not normally needed.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>php tags</title>
|
<title>{php} tags</title>
|
||||||
<programlisting>
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{php}
|
{php}
|
||||||
// including a php script directly
|
// including a php script directly
|
||||||
// from the template.
|
// from the template.
|
||||||
include("/path/to/display_weather.php");
|
include("/path/to/display_weather.php");
|
||||||
{/php}
|
{/php}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<note>
|
||||||
|
<title>Technical Note</title>
|
||||||
|
<para>
|
||||||
|
To access PHP variables in {php} blocks you may need to use the PHP
|
||||||
|
<ulink url="&url.php-manual;global">global</ulink>
|
||||||
|
keyword.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="variable.php.handling">$php_handling</link>,
|
<link linkend="variable.php.handling">$php_handling</link>,
|
||||||
|
@@ -140,7 +140,7 @@ id: 1000<br />
|
|||||||
{/section}
|
{/section}
|
||||||
<hr />
|
<hr />
|
||||||
{section name=bar loop=21 max=6 step=-2}
|
{section name=bar loop=21 max=6 step=-2}
|
||||||
{$smarty.section.bar.index}
|
{$smarty.section.bar.index}
|
||||||
{/section}
|
{/section}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
@@ -179,8 +179,8 @@ $smarty->assign('address',$addr);
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
{*
|
{*
|
||||||
the loop variable only determines the number of times to loop.
|
the loop variable only determines the number of times to loop.
|
||||||
you can access any variable from the template within the section.
|
you can access any variable from the template within the section.
|
||||||
This example assumes that $custid, $name and $address are all
|
This example assumes that $custid, $name and $address are all
|
||||||
arrays containing the same number of values
|
arrays containing the same number of values
|
||||||
*}
|
*}
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
@@ -270,10 +270,10 @@ $smarty->assign('contact_info', $info);
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{*
|
{*
|
||||||
sections can be nested as deep as you like. With nested sections,
|
sections can be nested as deep as you like. With nested sections,
|
||||||
you can access complex data structures, such as multi-dimensional
|
you can access complex data structures, such as multi-dimensional
|
||||||
arrays. In this example, $contact_type[customer] is an array of
|
arrays. In this example, $contact_type[customer] is an array of
|
||||||
contact types for the current customer.
|
contact types for the current customer.
|
||||||
*}
|
*}
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
<hr>
|
<hr>
|
||||||
@@ -690,7 +690,7 @@ iteration=6 index=15 id=3015<br />
|
|||||||
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
There were {$smarty.section.customer.loop} customers shown above.
|
There were {$smarty.section.customer.loop} customers shown above.
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
@@ -702,7 +702,7 @@ iteration=6 index=15 id=3015<br />
|
|||||||
1 id: 1001<br />
|
1 id: 1001<br />
|
||||||
2 id: 1002<br />
|
2 id: 1002<br />
|
||||||
|
|
||||||
There were 3 customers shown above.
|
There were 3 customers shown above.
|
||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
unmanageable templates.
|
unmanageable templates.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Anything within {strip}{/strip} tags in Smarty are stripped of the
|
Anything within {strip}{/strip} tags are stripped of the
|
||||||
extra spaces or carriage returns at the beginnings and ends of the
|
extra spaces or carriage returns at the beginnings and ends of the
|
||||||
lines before they are displayed. This way you can keep your
|
lines before they are displayed. This way you can keep your
|
||||||
templates readable, and not worry about extra white space causing
|
templates readable, and not worry about extra white space causing
|
||||||
@@ -25,12 +25,12 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<example>
|
<example>
|
||||||
<title>strip tags</title>
|
<title>{strip} tags</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* the following will be all run into one line upon output *}
|
{* the following will be all run into one line upon output *}
|
||||||
{strip}
|
{strip}
|
||||||
<table border=0>
|
<table border='0'>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<A HREF="{$url}">
|
<A HREF="{$url}">
|
||||||
|
@@ -37,11 +37,12 @@
|
|||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
<para>
|
<para>
|
||||||
{assign} is used for assigning template variables during the execution
|
{assign} is used for assigning template variables
|
||||||
of the template.
|
<emphasis role="bold">during the execution
|
||||||
|
of the template</emphasis>.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>assign</title>
|
<title>{assign}</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{assign var="name" value="Bob"}
|
{assign var="name" value="Bob"}
|
||||||
@@ -58,6 +59,63 @@ The value of $name is Bob.
|
|||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<example>
|
||||||
|
<title>Accessing {assign} variables from a PHP script.</title>
|
||||||
|
<para>
|
||||||
|
To access {assign} variables from php use
|
||||||
|
<link linkend="api.get.template.vars">get_template_vars()</link>.
|
||||||
|
However, the variables are only available after/during template execution
|
||||||
|
as in the following example
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
{* index.tpl *}
|
||||||
|
{assign var="foo" value="Smarty"}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// this will output nothing as the template has not been executed
|
||||||
|
echo $smarty->get_template_vars('foo');
|
||||||
|
|
||||||
|
// fetch the template to a dead variable
|
||||||
|
$dead = $smarty->fetch('index.tpl');
|
||||||
|
|
||||||
|
// this will output 'smarty' as the template has been executed
|
||||||
|
echo $smarty->get_template_vars('foo');
|
||||||
|
|
||||||
|
$smarty->assign('foo','Even smarter');
|
||||||
|
|
||||||
|
// this will output 'Even smarter'
|
||||||
|
echo $smarty->get_template_vars('foo');
|
||||||
|
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
|
||||||
|
<para>
|
||||||
|
The following functions can also <emphasis>optionally</emphasis> assign
|
||||||
|
template variables.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<link linkend="language.function.capture">{capture}</link>,
|
||||||
|
<link linkend="language.function.include">{include}</link>,
|
||||||
|
<link linkend="language.function.include.php">{include_php}</link>,
|
||||||
|
<link linkend="language.function.insert">{insert}</link>,
|
||||||
|
<link linkend="language.function.counter">{counter}</link>,
|
||||||
|
<link linkend="language.function.cycle">{cycle}</link>,
|
||||||
|
<link linkend="language.function.eval">{eval}</link>,
|
||||||
|
<link linkend="language.function.fetch">{fetch}</link>,
|
||||||
|
<link linkend="language.function.math">{math}</link>,
|
||||||
|
<link linkend="language.function.textformat">{textformat}</link>
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="api.assign">assign()</link>
|
See also <link linkend="api.assign">assign()</link>
|
||||||
and
|
and
|
||||||
|
@@ -83,19 +83,19 @@
|
|||||||
<example>
|
<example>
|
||||||
<title>{html_options}</title>
|
<title>{html_options}</title>
|
||||||
<para>
|
<para>
|
||||||
<emphasis role="bold">Example 2:</emphasis>
|
<emphasis role="bold">Example 1:</emphasis>
|
||||||
</para>
|
</para>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||||
$smarty->assign('cust_names', array(
|
$smarty->assign('cust_names', array(
|
||||||
'Joe Schmoe',
|
'Joe Schmoe',
|
||||||
'Jack Smith',
|
'Jack Smith',
|
||||||
'Jane Johnson',
|
'Jane Johnson',
|
||||||
'Charlie Brown'));
|
'Charlie Brown'));
|
||||||
$smarty->assign('customer_id', 1001);
|
$smarty->assign('customer_id', 1001);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
@@ -105,9 +105,9 @@ $smarty->assign('cust_names', array(
|
|||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<select name=customer_id>
|
<select name=customer_id>
|
||||||
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
|
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
|
||||||
</select>
|
</select>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
@@ -117,12 +117,13 @@ $smarty->assign('cust_names', array(
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$smarty->assign('cust_options', array(
|
$smarty->assign('cust_options', array(
|
||||||
1001 => 'Joe Schmoe',
|
1000 => 'Joe Schmoe',
|
||||||
1002 => 'Jack Smith',
|
1001 => 'Jack Smith',
|
||||||
1003 => 'Jane Johnson',
|
1002 => 'Jane Johnson',
|
||||||
1004 => 'Charlie Brown'));
|
1003 => 'Charlie Brown')
|
||||||
$smarty->assign('customer_id', 1001);
|
);
|
||||||
|
$smarty->assign('customer_id', 1001);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
@@ -132,9 +133,9 @@ where template is:
|
|||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<select name=customer_id>
|
<select name=customer_id>
|
||||||
{html_options options=$cust_options selected=$customer_id}
|
{html_options options=$cust_options selected=$customer_id}
|
||||||
</select>
|
</select>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
@@ -142,12 +143,12 @@ where template is:
|
|||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<select name=customer_id>
|
<select name=customer_id>
|
||||||
<option label="Joe Schmoe" value="1000">Joe Schmoe</option>
|
<option label="Joe Schmoe" value="1000">Joe Schmoe</option>
|
||||||
<option label="Jack Smith" value="1001" selected="selected">Jack Smith</option>
|
<option label="Jack Smith" value="1001" selected="selected">Jack Smith</option>
|
||||||
<option label="Jane Johnson" value="1002">Jane Johnson</option>
|
<option label="Jane Johnson" value="1002">Jane Johnson</option>
|
||||||
<option label="Charlie Brown" value="1003">Charlie Brown</option>
|
<option label="Charlie Brown" value="1003">Charlie Brown</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
@@ -161,7 +162,8 @@ where template is:
|
|||||||
$sql = 'select type_id, types from types order by type';
|
$sql = 'select type_id, types from types order by type';
|
||||||
$smarty->assign('types',$db->getAssoc($sql));
|
$smarty->assign('types',$db->getAssoc($sql));
|
||||||
|
|
||||||
$sql = 'select * from contacts where contact_id=12';
|
$sql = 'select contact_id, name, email, type_id
|
||||||
|
from contacts where contact_id='.$contact_id;
|
||||||
$smarty->assign('contact',$db->getRow($sql));
|
$smarty->assign('contact',$db->getRow($sql));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -173,6 +175,7 @@ where the template is:
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<select name="type_id">
|
<select name="type_id">
|
||||||
|
<option value='null'>-- none --</option>
|
||||||
{html_options name="type" options=$types selected=$contact.type_id}
|
{html_options name="type" options=$types selected=$contact.type_id}
|
||||||
</select>
|
</select>
|
||||||
]]>
|
]]>
|
||||||
|
@@ -83,13 +83,14 @@
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||||
$smarty->assign('cust_names', array(
|
$smarty->assign('cust_names', array(
|
||||||
'Joe Schmoe',
|
'Joe Schmoe',
|
||||||
'Jack Smith',
|
'Jack Smith',
|
||||||
'Jane Johnson',
|
'Jane Johnson',
|
||||||
'Charlie Brown'));
|
'Charlie Brown')
|
||||||
$smarty->assign('customer_id', 1001);
|
);
|
||||||
|
$smarty->assign('customer_id', 1001);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
@@ -100,7 +101,7 @@ $smarty->assign('cust_names', array(
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{html_radios name="id" values=$cust_ids output=$cust_names
|
{html_radios name="id" values=$cust_ids output=$cust_names
|
||||||
selected=$customer_id separator="<br />"}
|
selected=$customer_id separator="<br />"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
@@ -110,12 +111,12 @@ $smarty->assign('cust_names', array(
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$smarty->assign('cust_radios', array(
|
$smarty->assign('cust_radios', array(
|
||||||
1000 => 'Joe Schmoe',
|
1000 => 'Joe Schmoe',
|
||||||
1001 => 'Jack Smith',
|
1001 => 'Jack Smith',
|
||||||
1002 => 'Jane Johnson',
|
1002 => 'Jane Johnson',
|
||||||
1003 => 'Charlie Brown'));
|
1003 => 'Charlie Brown'));
|
||||||
$smarty->assign('customer_id', 1001);
|
$smarty->assign('customer_id', 1001);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
@@ -125,7 +126,7 @@ $smarty->assign('cust_names', array(
|
|||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
|
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
@@ -133,7 +134,8 @@ $smarty->assign('cust_names', array(
|
|||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<label for="id_1000"><input type="radio" name="id" value="1000" id="id_1000" />Joe
|
<label for="id_1000">
|
||||||
|
<input type="radio" name="id" value="1000" id="id_1000" />Joe
|
||||||
Schmoe</label><br />
|
Schmoe</label><br />
|
||||||
<label for="id_1001"><input type="radio" name="id" value="1001" id="id_1001"
|
<label for="id_1001"><input type="radio" name="id" value="1001" id="id_1001"
|
||||||
checked="checked" />Jack
|
checked="checked" />Jack
|
||||||
@@ -154,7 +156,8 @@ Brown</label><br />
|
|||||||
$sql = 'select type_id, types from types order by type';
|
$sql = 'select type_id, types from types order by type';
|
||||||
$smarty->assign('types',$db->getAssoc($sql));
|
$smarty->assign('types',$db->getAssoc($sql));
|
||||||
|
|
||||||
$sql = 'select * from contacts where contact_id=12';
|
$sql = 'select contact_id, name, email, type_id
|
||||||
|
from contacts where contact_id='.$contact_id;
|
||||||
$smarty->assign('contact',$db->getRow($sql));
|
$smarty->assign('contact',$db->getRow($sql));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -229,10 +229,9 @@
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>{html_select_date}</title>
|
<title>{html_select_date}</title>
|
||||||
|
<para>Template code</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
template code:
|
|
||||||
-------------
|
|
||||||
{html_select_date}
|
{html_select_date}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@@ -39,9 +39,10 @@
|
|||||||
<para>
|
<para>
|
||||||
This formats a date and time into the given
|
This formats a date and time into the given
|
||||||
<ulink url="&url.php-manual;strftime">strftime()</ulink> format.
|
<ulink url="&url.php-manual;strftime">strftime()</ulink> format.
|
||||||
Dates can be passed to Smarty as unix timestamps, mysql timestamps
|
Dates can be passed to Smarty as unix
|
||||||
or any string made up of month day year (parsable by
|
<ulink url="&url.php-manual;function.time">timestamps</ulink>, mysql timestamps
|
||||||
<ulink url="&url.php-manual;strtotime">strtotime()</ulink>).
|
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
|
Designers can then use date_format to have complete control of the
|
||||||
formatting of the date. If the date passed to date_format is empty
|
formatting of the date. If the date passed to date_format is empty
|
||||||
and a second parameter is passed, that will be used as the date to
|
and a second parameter is passed, that will be used as the date to
|
||||||
@@ -64,8 +65,8 @@ $smarty->assign('yesterday', strtotime('-1 day'));
|
|||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{$smarty.now|date_format}
|
{$smarty.now|date_format}
|
||||||
{$smarty.now|date_format:"%A, %B %e, %Y"}
|
{$smarty.now|date_format:"%D"}
|
||||||
{$smarty.now|date_format:"%H:%M:%S"}
|
{$smarty.now|date_format:"%I:%M %p"}
|
||||||
{$yesterday|date_format}
|
{$yesterday|date_format}
|
||||||
{$yesterday|date_format:"%A, %B %e, %Y"}
|
{$yesterday|date_format:"%A, %B %e, %Y"}
|
||||||
{$yesterday|date_format:"%H:%M:%S"}
|
{$yesterday|date_format:"%H:%M:%S"}
|
||||||
@@ -77,8 +78,8 @@ $smarty->assign('yesterday', strtotime('-1 day'));
|
|||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
Feb 6, 2001
|
Feb 6, 2001
|
||||||
Tuesday, February 6, 2001
|
02/06/01
|
||||||
14:33:00
|
02:33 pm
|
||||||
Feb 5, 2001
|
Feb 5, 2001
|
||||||
Monday, February 5, 2001
|
Monday, February 5, 2001
|
||||||
14:33:00
|
14:33:00
|
||||||
@@ -86,7 +87,7 @@ Monday, February 5, 2001
|
|||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
date_format conversion specifiers:
|
<command>date_format</command> conversion specifiers:
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%a - abbreviated weekday name according to the current locale
|
%a - abbreviated weekday name according to the current locale
|
||||||
@@ -113,7 +114,8 @@ Monday, February 5, 2001
|
|||||||
%D - same as %m/%d/%y
|
%D - same as %m/%d/%y
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%e - day of the month as a decimal number, a single digit is preceded by a space (range 1 to 31)
|
%e - day of the month as a decimal number, a single digit is preceded by a space (range 1
|
||||||
|
to 31)
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%g - Week-based year within century [00,99]
|
%g - Week-based year within century [00,99]
|
||||||
@@ -137,7 +139,8 @@ Monday, February 5, 2001
|
|||||||
%k - Hour (24-hour clock) single digits are preceded by a blank. (range 0 to 23)
|
%k - Hour (24-hour clock) single digits are preceded by a blank. (range 0 to 23)
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%l - hour as a decimal number using a 12-hour clock, single digits preceeded by a space (range 1 to 12)
|
%l - hour as a decimal number using a 12-hour clock, single digits preceeded by a space
|
||||||
|
(range 1 to 12)
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%m - month as a decimal number (range 01 to 12)
|
%m - month as a decimal number (range 01 to 12)
|
||||||
@@ -149,7 +152,8 @@ Monday, February 5, 2001
|
|||||||
%n - newline character
|
%n - newline character
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%p - either `am' or `pm' according to the given time value, or the corresponding strings for the
|
%p - either `am' or `pm' according to the given time value, or the corresponding strings
|
||||||
|
for the
|
||||||
current locale
|
current locale
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
@@ -171,11 +175,13 @@ Monday, February 5, 2001
|
|||||||
%u - weekday as a decimal number [1,7], with 1 representing Monday
|
%u - weekday as a decimal number [1,7], with 1 representing Monday
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%U - week number of the current year as a decimal number, starting with the first Sunday as the first
|
%U - week number of the current year as a decimal number, starting with the first Sunday
|
||||||
|
as the first
|
||||||
day of the first week
|
day of the first week
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%V - The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week
|
%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
|
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.
|
year, and with Monday as the first day of the week.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
@@ -183,7 +189,8 @@ Monday, February 5, 2001
|
|||||||
%w - day of the week as a decimal, Sunday being 0
|
%w - day of the week as a decimal, Sunday being 0
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
%W - week number of the current year as a decimal number, starting with the first Monday as the first
|
%W - week number of the current year as a decimal number, starting with the first Monday
|
||||||
|
as the first
|
||||||
day of the first week
|
day of the first week
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
@@ -218,6 +225,7 @@ Monday, February 5, 2001
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="language.variables.smarty.now">$smarty.now</link>,
|
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>
|
<link linkend="language.function.html.select.date">{html_select_date}</link>
|
||||||
and <link linkend="tips.dates">date tips</link>.
|
and <link linkend="tips.dates">date tips</link>.
|
||||||
</para>
|
</para>
|
||||||
@@ -245,3 +253,4 @@ vi: ts=1 sw=1
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,12 +4,15 @@
|
|||||||
<title>Variables</title>
|
<title>Variables</title>
|
||||||
<para>
|
<para>
|
||||||
Smarty has several different types of variables. The type of the variable
|
Smarty has several different types of variables. The type of the variable
|
||||||
depends on what symbol it is prefixed with (or enclosed within).
|
depends on what symbol it is prefixed or enclosed within.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Variables 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,
|
for <link linkend="language.syntax.functions">function</link>
|
||||||
etc. To print a variable, simply enclose it in the delimiters so that it
|
<link linkend="language.syntax.attributes">attributes</link> and
|
||||||
|
<link linkend="language.modifiers">modifiers</link>, inside conditional expressions,
|
||||||
|
etc. To print a variable, simply enclose it in the
|
||||||
|
<link linkend="variable.left.delimiter">delimiters</link> so that it
|
||||||
is the only thing contained between them. Examples:
|
is the only thing contained between them. Examples:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
@@ -3,28 +3,53 @@
|
|||||||
<sect1 id="language.assigned.variables">
|
<sect1 id="language.assigned.variables">
|
||||||
<title>Variables assigned from PHP</title>
|
<title>Variables assigned from PHP</title>
|
||||||
<para>
|
<para>
|
||||||
Variables that are assigned from PHP are referenced by preceding them with
|
Variables that are
|
||||||
a dollar sign <literal>$</literal>. Variables assigned from within the
|
<link linkend="api.assign">assigned</link> from PHP are referenced by preceding them with
|
||||||
|
a dollar sign <literal>$</literal>. Variables assigned from within a
|
||||||
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.
|
function are also displayed this way.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>assigned variables</title>
|
<title>assigned variables</title>
|
||||||
<programlisting>
|
<para> php script</para>
|
||||||
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
Hello {$firstname}, glad to see you could make it.
|
<?php
|
||||||
<br />
|
|
||||||
Your last login was on {$lastLoginDate}.
|
$smarty = new Smarty;
|
||||||
|
|
||||||
|
$smarty->assign('firstname', 'Doug');
|
||||||
|
$smarty->assign('lastname', 'Evans');
|
||||||
|
$smarty->assign('meetingPlace', 'New York');
|
||||||
|
|
||||||
|
$smarty->display('index.tpl');
|
||||||
|
|
||||||
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
where the content of index.tpl is:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
Hello {$firstname} {$lastname}, glad to see you can make it.
|
||||||
|
<br />
|
||||||
|
{* this will not work as $vars are case sensitive *}
|
||||||
|
This weeks meeting is in {$meetingplace}.
|
||||||
|
{* this will work *}
|
||||||
|
This weeks meeting is in {$meetingPlace}.
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
This will output:
|
This will output:
|
||||||
</para>
|
</para>
|
||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
Hello Doug, glad to see you could make it.
|
Hello Doug Evans, glad to see you can make it.
|
||||||
<br />
|
<br />
|
||||||
Your last login was on January 11th, 2001.
|
This weeks meeting is in .
|
||||||
|
This weeks meeting is in New York.
|
||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
@@ -40,7 +65,6 @@ Your last login was on January 11th, 2001.
|
|||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty = new Smarty;
|
|
||||||
$smarty->assign('Contacts',
|
$smarty->assign('Contacts',
|
||||||
array('fax' => '555-222-9876',
|
array('fax' => '555-222-9876',
|
||||||
'email' => 'zaphod@slartibartfast.com',
|
'email' => 'zaphod@slartibartfast.com',
|
||||||
@@ -87,12 +111,12 @@ zaphod@slartibartfast.com<br />
|
|||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty->assign('Contacts', array(
|
||||||
$smarty->assign('Contacts',
|
'555-222-9876',
|
||||||
array('555-222-9876',
|
'zaphod@slartibartfast.com',
|
||||||
'zaphod@slartibartfast.com',
|
array('555-444-3333',
|
||||||
array('555-444-3333',
|
'555-111-1234')
|
||||||
'555-111-1234')));
|
));
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -86,13 +86,17 @@ rowBgColor = "#cccccc"
|
|||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
Config file variables cannot be used until
|
Config file variables cannot be used until
|
||||||
after they are loaded in from a config file. This procedure is
|
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>.
|
explained later in this document under
|
||||||
</para>
|
<link linkend="language.function.config.load"><command>{config_load}</command></link>.
|
||||||
<para>See also <link linkend="language.syntax.variables">Variables</link> and <link linkend="language.variables.smarty">$smarty reserved
|
</para>
|
||||||
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>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="language.variables.smarty">
|
<sect1 id="language.variables.smarty">
|
||||||
<title>{$smarty} reserved variables</title>
|
<title>{$smarty} reserved variable</title>
|
||||||
<para>
|
<para>
|
||||||
The reserved {$smarty} variable can be used to access several
|
The reserved {$smarty} variable can be used to access several
|
||||||
special template variables. The full list of them follows.
|
special template variables. The full list of them follows.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<sect2 id="language.variables.smarty.request">
|
<sect2 id="language.variables.smarty.request">
|
||||||
<title>Request variables</title>
|
<title>Request variables</title>
|
||||||
<para>
|
<para>
|
||||||
The request variables such as get, post, cookies, server,
|
The <ulink url="&url.php-manual;reserved.variables">request variables
|
||||||
environment, and session variables can be accessed as demonstrated
|
</ulink> such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION
|
||||||
in the examples below:
|
can be accessed as demonstrated in the examples below:
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>displaying request variables</title>
|
<title>displaying request variables</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* display value of page from URL (GET) http://www.example.com/index.php?page=foo *}
|
{* display value of page from URL (GET) http://www.example.com/index.php?page=foo *}
|
||||||
{$smarty.get.page}
|
{$smarty.get.page}
|
||||||
@@ -39,25 +39,27 @@
|
|||||||
{* display the variable "username" from merged get/post/cookies/server/env *}
|
{* display the variable "username" from merged get/post/cookies/server/env *}
|
||||||
{$smarty.request.username}
|
{$smarty.request.username}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
For historical reasons {$SCRIPT_NAME} can be accessed
|
For historical reasons {$SCRIPT_NAME} can be accessed
|
||||||
directly though {$smarty.server.SCRIPT_NAME} is the
|
directly, although {$smarty.server.SCRIPT_NAME} is the
|
||||||
proposed way to access this value.
|
proposed way to access this value.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2 id="language.variables.smarty.now">
|
<sect2 id="language.variables.smarty.now">
|
||||||
<title>{$smarty.now}</title>
|
<title>{$smarty.now}</title>
|
||||||
<para>
|
<para>
|
||||||
The current timestamp can be accessed with {$smarty.now}. The
|
The current <ulink url="&url.php-manual;function.time">timestamp</ulink>
|
||||||
number reflects the number of seconds passed since the so-called
|
can be accessed with {$smarty.now}. The number reflects the number of
|
||||||
Epoch (January 1, 1970) and can be passed directly to
|
seconds passed since the so-called Epoch (January 1, 1970)
|
||||||
<link linkend="language.modifier.date.format">date_format</link> modifier for display purposes.
|
and can be passed directly to the
|
||||||
</para>
|
<link linkend="language.modifier.date.format">date_format</link>
|
||||||
|
modifier for display purposes.
|
||||||
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>using {$smarty.now}</title>
|
<title>using {$smarty.now}</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@@ -169,3 +171,4 @@ vim: et tw=78 syn=sgml
|
|||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
@@ -136,7 +136,7 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Plugin architecture
|
<link linkend="plugins">Plugin</link> architecture
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
@@ -160,25 +160,26 @@
|
|||||||
upgrade to a new version of Smarty.
|
upgrade to a new version of Smarty.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Smarty library files</title>
|
<title>Required Smarty library files</title>
|
||||||
<screen>
|
<screen>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
Smarty.class.php
|
Smarty.class.php
|
||||||
Smarty_Compiler.class.php
|
Smarty_Compiler.class.php
|
||||||
Config_File.class.php
|
Config_File.class.php
|
||||||
debug.tpl
|
debug.tpl
|
||||||
/internals/*.php (all of them)
|
/libs/*.php (all of them)
|
||||||
/plugins/*.php (all of them)
|
/plugins/*.php (all of them)
|
||||||
]]>
|
]]>
|
||||||
</screen>
|
</screen>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
Smarty uses a PHP constant named <link
|
Smarty uses a PHP constant named
|
||||||
linkend="constant.smarty.dir">SMARTY_DIR</link> which is the system
|
<link linkend="constant.smarty.dir">SMARTY_DIR</link> which is the system
|
||||||
filepath Smarty library directory. Basically, if your application can find
|
file path to the Smarty 'libs/' directory. Basically, if your application
|
||||||
the <filename>Smarty.class.php</filename> file, you do not need to set
|
can find the <filename>Smarty.class.php</filename> file, you do not need
|
||||||
SMARTY_DIR, Smarty will figure it out on its own. Therefore, if
|
to set <link linkend="constant.smarty.dir">SMARTY_DIR</link>
|
||||||
<filename>Smarty.class.php</filename> is not in your include_path, or you
|
Smarty will figure it out on its own. Therefore, if
|
||||||
|
<filename>Smarty.class.php</filename> is not in your include_path, or you
|
||||||
do not supply an absolute path to it in your application, then you must
|
do not supply an absolute path to it in your application, then you must
|
||||||
define SMARTY_DIR manually. SMARTY_DIR <emphasis>must</emphasis> include a
|
define SMARTY_DIR manually. SMARTY_DIR <emphasis>must</emphasis> include a
|
||||||
trailing slash.
|
trailing slash.
|
||||||
@@ -247,11 +248,15 @@ $smarty = new Smarty;
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
Now that the library files are in place, it's time to setup the Smarty
|
Now that the library files are in place, it's time to setup the Smarty
|
||||||
directories for your application. Smarty requires four directories which
|
directories for your application.</para>
|
||||||
are (by default) named <filename class="directory">templates</filename>,
|
<para>
|
||||||
<filename class="directory">templates_c</filename>, <filename
|
Smarty requires four directories which
|
||||||
class="directory">configs</filename> and <filename
|
are (by default) named <filename class="directory">'templates/'</filename>,
|
||||||
class="directory">cache</filename>. Each of these are definable by the
|
<filename class="directory">'templates_c/'</filename>, <filename
|
||||||
|
class="directory">'configs/'</filename> and <filename
|
||||||
|
class="directory">'cache/'</filename>.
|
||||||
|
</para>
|
||||||
|
<para>Each of these are definable by the
|
||||||
Smarty class properties
|
Smarty class properties
|
||||||
<link linkend="variable.template.dir">
|
<link linkend="variable.template.dir">
|
||||||
<varname>$template_dir</varname></link>,
|
<varname>$template_dir</varname></link>,
|
||||||
@@ -286,19 +291,24 @@ $smarty = new Smarty;
|
|||||||
<para>
|
<para>
|
||||||
You will need as least one file under your document root, and that is the
|
You will need as least one file under your document root, and that is the
|
||||||
script accessed by the web browser. We will call our script
|
script accessed by the web browser. We will call our script
|
||||||
<filename>index.php</filename>, and place it in a subdirectory under the
|
<emphasis>'index.php'</emphasis>, and place it in a subdirectory under the
|
||||||
document root called <filename class="directory">/guestbook/</filename>.
|
document root called <filename class="directory">/guestbook/</filename>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
It is convenient to setup the web server so that "index.php" can be
|
It is convenient to setup the web server so that 'index.php' can be
|
||||||
identified as the default directory index, so if you access
|
identified as the default directory index, so if you access
|
||||||
"http://www.example.com/guestbook/", the index.php script will be executed
|
http://www.example.com/guestbook/, the 'index.php' script will be executed
|
||||||
without "index.php" in the URL. In Apache you can set this up by adding
|
without adding 'index.php' to the URL. In Apache you can set this up by adding
|
||||||
"index.php" onto the end of your DirectoryIndex setting (separate each
|
"index.php" onto the end of your <emphasis>DirectoryIndex</emphasis> setting (separate
|
||||||
entry with a space.)
|
each entry with a space.) as in the httpd.conf example
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
<emphasis>DirectoryIndex
|
||||||
|
index.htm index.html index.php index.php3 default.html index.cgi
|
||||||
|
</emphasis>
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
@@ -328,7 +338,8 @@ $smarty = new Smarty;
|
|||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Smarty will need write access to the
|
Smarty will need <emphasis role="bold">write access</emphasis>
|
||||||
|
(windows users please ignore) to the
|
||||||
<link linkend="variable.compile.dir">
|
<link linkend="variable.compile.dir">
|
||||||
<emphasis>$compile_dir</emphasis></link> and
|
<emphasis>$compile_dir</emphasis></link> and
|
||||||
<link linkend="variable.cache.dir">
|
<link linkend="variable.cache.dir">
|
||||||
@@ -364,8 +375,8 @@ chmod 770 /web/www.example.com/smarty/guestbook/cache/
|
|||||||
</note>
|
</note>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
We need to create the index.tpl file that Smarty will load. This will be
|
We need to create the 'index.tpl' file that Smarty will load. This will be
|
||||||
located in your $template_dir.
|
located in your <link linkend="variable.template.dir">$template_dir</link>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
@@ -383,7 +394,9 @@ Hello, {$name}!
|
|||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
{* Smarty *} is a template comment. It is not required, but it is good
|
{* Smarty *} is a template
|
||||||
|
<link linkend="language.syntax.comments">comment</link>.
|
||||||
|
It is not required, but it is good
|
||||||
practice to start all your template files with this comment. It makes
|
practice to start all your template files with this comment. It makes
|
||||||
the file easy to recognize regardless of the file extension. For
|
the file easy to recognize regardless of the file extension. For
|
||||||
example, text editors could recognize the file and turn on special
|
example, text editors could recognize the file and turn on special
|
||||||
@@ -392,8 +405,8 @@ Hello, {$name}!
|
|||||||
</note>
|
</note>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Now lets edit index.php. We'll create an instance of Smarty, assign a
|
Now lets edit 'index.php'. We'll create an instance of Smarty, assign a
|
||||||
template variable and display the index.tpl file. In our example
|
template variable and display the 'index.tpl' file. In our example
|
||||||
environment, "/usr/local/lib/php/Smarty" is in our include_path. Be sure you
|
environment, "/usr/local/lib/php/Smarty" is in our include_path. Be sure you
|
||||||
do the same, or use absolute paths.
|
do the same, or use absolute paths.
|
||||||
</para>
|
</para>
|
||||||
@@ -553,3 +566,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -12,10 +12,12 @@
|
|||||||
</note>'>
|
</note>'>
|
||||||
|
|
||||||
<!ENTITY parameter.compileid '<para>
|
<!ENTITY parameter.compileid '<para>
|
||||||
As an optional third parameter, you can pass a <parameter>compile_id</parameter>.
|
As an optional third parameter, you can pass a
|
||||||
|
<link linkend="variable.compile.id">$compile_id</link>.
|
||||||
This is in the event that you want to compile different versions of
|
This is in the event that you want to compile different versions of
|
||||||
the same template, such as having separate templates compiled
|
the same template, such as having separate templates compiled
|
||||||
for different languages. Another use for compile_id is when you
|
for different languages. Another use for
|
||||||
|
<link linkend="variable.compile.id">$compile_id</link> is when you
|
||||||
use more than one
|
use more than one
|
||||||
<link linkend="variable.template.dir">$template_dir</link>
|
<link linkend="variable.template.dir">$template_dir</link>
|
||||||
but only one
|
but only one
|
||||||
|
@@ -66,7 +66,7 @@
|
|||||||
meticulous and overbearing the PHP language may look to the average
|
meticulous and overbearing the PHP language may look to the average
|
||||||
designer, and this could be masked with a much simpler templating
|
designer, and this could be masked with a much simpler templating
|
||||||
syntax. So what if we combined the two strengths? Thus, Smarty was
|
syntax. So what if we combined the two strengths? Thus, Smarty was
|
||||||
born...
|
born... :-)
|
||||||
</para>
|
</para>
|
||||||
</preface>
|
</preface>
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<chapter id="api.functions">
|
<chapter id="api.functions">
|
||||||
<title>Methods</title>
|
<title>Smarty Class Methods()</title>
|
||||||
&programmers.api-functions.api-append;
|
&programmers.api-functions.api-append;
|
||||||
&programmers.api-functions.api-append-by-ref;
|
&programmers.api-functions.api-append-by-ref;
|
||||||
&programmers.api-functions.api-assign;
|
&programmers.api-functions.api-assign;
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.append.by.ref">
|
<refentry id="api.append.by.ref">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>append_by_ref</refname>
|
<refname>append_by_ref()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>append values by reference</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>append_by_ref</methodname>
|
<type>void</type><methodname>append_by_ref</methodname>
|
||||||
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.append">
|
<refentry id="api.append">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>append</refname>
|
<refname>append()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>append an element to an assigned array</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>append</methodname>
|
<type>void</type><methodname>append</methodname>
|
||||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<methodparam choice="opt"><type>bool</type><parameter>merge</parameter></methodparam>
|
<methodparam choice="opt"><type>bool</type><parameter>merge</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This is used to append an element to an assigned array. If you append
|
If you append
|
||||||
to a string value, it is converted to an array value and then
|
to a string value, it is converted to an array value and then
|
||||||
appended to. You can explicitly pass name/value pairs, or associative
|
appended to. You can explicitly pass name/value pairs, or associative
|
||||||
arrays containing the name/value pairs. If you pass the optional third
|
arrays containing the name/value pairs. If you pass the optional third
|
||||||
|
@@ -2,18 +2,19 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.assign.by.ref">
|
<refentry id="api.assign.by.ref">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>assign_by_ref</refname>
|
<refname>assign_by_ref()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>assign values by reference</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>assign_by_ref</methodname>
|
<type>void</type><methodname>assign_by_ref</methodname>
|
||||||
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
||||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This is used to assign values to the templates by reference instead of
|
This is used to <link linkend="api.assign">assign()</link>
|
||||||
|
values to the templates by reference instead of
|
||||||
making a copy. See the PHP manual on variable referencing for an explanation.
|
making a copy. See the PHP manual on variable referencing for an explanation.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<example>
|
<example>
|
||||||
<title>assign_by_ref</title>
|
<title>assign_by_ref()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.assign">
|
<refentry id="api.assign">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>assign</refname>
|
<refname>assign()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>assign values to the templates</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>assign</methodname>
|
<type>void</type><methodname>assign</methodname>
|
||||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||||
@@ -17,13 +17,12 @@
|
|||||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This is used to assign values to the templates. You can
|
You can explicitly pass name/value pairs, or associative arrays
|
||||||
explicitly pass name/value pairs, or associative arrays
|
|
||||||
containing the name/value pairs.
|
containing the name/value pairs.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>assign</title>
|
<title>assign()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// passing name/value pairs
|
// passing name/value pairs
|
||||||
@@ -32,17 +31,42 @@ $smarty->assign('Address', $address);
|
|||||||
|
|
||||||
// passing an associative array
|
// passing an associative array
|
||||||
$smarty->assign(array('city' => 'Lincoln', 'state' => 'Nebraska'));
|
$smarty->assign(array('city' => 'Lincoln', 'state' => 'Nebraska'));
|
||||||
|
|
||||||
|
// passing a row from a database (eg adodb)
|
||||||
|
$sql = 'select id, name, email from contacts where contact ='.$id;
|
||||||
|
$smarty->assign('contact', $db->getRow($sql));
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Access these in the template with
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
{$Name}
|
||||||
|
{$Address}
|
||||||
|
{$city}
|
||||||
|
{$state}
|
||||||
|
|
||||||
|
{$contact.id}, {$contact.name},{$contact.email}
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
|
For more complex array assignments see
|
||||||
|
<link linkend="language.function.foreach">{foreach}</link>
|
||||||
|
and
|
||||||
|
<link linkend="language.function.section">{section}</link>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
See also <link linkend="api.assign.by.ref">assign_by_ref()</link>,
|
See also <link linkend="api.assign.by.ref">assign_by_ref()</link>,
|
||||||
|
<link linkend="api.get.template.vars">get_template_vars()</link>,
|
||||||
<link linkend="api.clear.assign">clear_assign()</link>,
|
<link linkend="api.clear.assign">clear_assign()</link>,
|
||||||
<link linkend="api.append">append()</link>,
|
<link linkend="api.append">append()</link>
|
||||||
<link linkend="language.function.assign">{assign}</link>,
|
|
||||||
and
|
and
|
||||||
<link linkend="api.get.template.vars">get_template_vars()</link>
|
<link linkend="language.function.assign">{assign}</link>
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
@@ -2,25 +2,33 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.clear.all.assign">
|
<refentry id="api.clear.all.assign">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>clear_all_assign</refname>
|
<refname>clear_all_assign()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>clears the values of all assigned variables</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>clear_all_assign</methodname>
|
<type>void</type><methodname>clear_all_assign</methodname>
|
||||||
<void />
|
<void />
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
|
||||||
This clears the values of all assigned variables.
|
|
||||||
</para>
|
|
||||||
<example>
|
<example>
|
||||||
<title>clear_all_assign</title>
|
<title>clear_all_assign()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
// passing name/value pairs
|
||||||
|
$smarty->assign('Name', 'Fred');
|
||||||
|
$smarty->assign('Address', $address);
|
||||||
|
|
||||||
|
// will output above
|
||||||
|
print_r( $smarty->get_template_vars() );
|
||||||
|
|
||||||
// clear all assigned variables
|
// clear all assigned variables
|
||||||
$smarty->clear_all_assign();
|
$smarty->clear_all_assign();
|
||||||
|
|
||||||
|
// will output nothing
|
||||||
|
print_r( $smarty->get_template_vars() );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@@ -2,17 +2,17 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.clear.all.cache">
|
<refentry id="api.clear.all.cache">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>clear_all_cache</refname>
|
<refname>clear_all_cache()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>clears the entire template cache</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>clear_all_cache</methodname>
|
<type>void</type><methodname>clear_all_cache</methodname>
|
||||||
<methodparam choice="opt"><type>int</type><parameter>expire_time</parameter></methodparam>
|
<methodparam choice="opt"><type>int</type><parameter>expire_time</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This clears the entire template cache. As an optional
|
As an optional
|
||||||
parameter, you can supply a minimum age in seconds the cache
|
parameter, you can supply a minimum age in seconds the cache
|
||||||
files must be before they will get cleared.
|
files must be before they will get cleared.
|
||||||
</para>
|
</para>
|
||||||
@@ -29,7 +29,8 @@ $smarty->clear_all_cache();
|
|||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="api.clear.cache">clear_cache()</link>
|
<link linkend="api.clear.cache">clear_cache()</link>,
|
||||||
|
<link linkend="api.is.cached">is_cached()</link>
|
||||||
and
|
and
|
||||||
<link linkend="caching">caching</link>
|
<link linkend="caching">caching</link>
|
||||||
</para>
|
</para>
|
||||||
|
@@ -2,29 +2,28 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.clear.assign">
|
<refentry id="api.clear.assign">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>clear_assign</refname>
|
<refname>clear_assign()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>clears the value of an assigned variable</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>clear_assign</methodname>
|
<type>void</type><methodname>clear_assign</methodname>
|
||||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This clears the value of an assigned variable. This
|
This can be a single value, or an array of values.
|
||||||
can be a single value, or an array of values.
|
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>clear_assign</title>
|
<title>clear_assign()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// clear a single variable
|
// clear a single variable
|
||||||
$smarty->clear_assign("Name");
|
$smarty->clear_assign('Name');
|
||||||
|
|
||||||
// clear multiple variables
|
// clears multiple variables
|
||||||
$smarty->clear_assign(array("Name", "Address", "Zip"));
|
$smarty->clear_assign(array('Name', 'Address', 'Zip'));
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
@@ -33,6 +32,7 @@ $smarty->clear_assign(array("Name", "Address", "Zip"));
|
|||||||
See also
|
See also
|
||||||
<link linkend="api.clear.all.assign">clear_all_assign()</link>,
|
<link linkend="api.clear.all.assign">clear_all_assign()</link>,
|
||||||
<link linkend="api.clear.config">clear_config()</link>,
|
<link linkend="api.clear.config">clear_config()</link>,
|
||||||
|
<link linkend="api.get.template.vars">get_template_vars()</link>,
|
||||||
<link linkend="api.assign">assign()</link>
|
<link linkend="api.assign">assign()</link>
|
||||||
and <link linkend="api.append">append()</link>
|
and <link linkend="api.append">append()</link>
|
||||||
</para>
|
</para>
|
||||||
|
@@ -2,46 +2,52 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.clear.cache">
|
<refentry id="api.clear.cache">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>clear_cache</refname>
|
<refname>clear_cache()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>clears the cache for a specific template</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>clear_cache</methodname>
|
<type>void</type><methodname>clear_cache</methodname>
|
||||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter>
|
||||||
|
</methodparam>
|
||||||
<methodparam choice="opt"><type>int</type><parameter>expire_time</parameter></methodparam>
|
<methodparam choice="opt"><type>int</type><parameter>expire_time</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This clears the cache for a specific <parameter>template</parameter>.
|
If you have <link linkend="caching.multiple.caches">multiple caches</link>
|
||||||
If you have multiple caches for this template, you can clear a specific
|
for a template, you can clear a specific
|
||||||
cache by supplying the <parameter>cache_id</parameter> as the second
|
cache by supplying the <parameter>cache_id</parameter> as the second
|
||||||
parameter.
|
parameter.
|
||||||
You can also pass a <parameter>compile_id</parameter> as a third parameter.
|
You can also pass a
|
||||||
You can "group" templates together so they can be removed as a group. See the
|
<link linkend="variable.compile.id"><parameter>$compile_id</parameter></link>
|
||||||
|
as a third parameter.
|
||||||
|
You can <link linkend="caching.groups">"group"</link> templates
|
||||||
|
together so they can be removed as a group. See the
|
||||||
<link linkend="caching">caching section</link> for more
|
<link linkend="caching">caching section</link> for more
|
||||||
information. As an optional fourth parameter, you can supply a
|
information. As an optional fourth parameter, you can supply a
|
||||||
minimum age in seconds the cache file must be before it will
|
minimum age in seconds the cache file must be before it will
|
||||||
get cleared.
|
get cleared.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>clear_cache</title>
|
<title>clear_cache()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// clear the cache for a template
|
// clear the cache for a template
|
||||||
$smarty->clear_cache("index.tpl");
|
$smarty->clear_cache('index.tpl');
|
||||||
|
|
||||||
// clear the cache for a particular cache id in an multiple-cache template
|
// clear the cache for a particular cache id in an multiple-cache template
|
||||||
$smarty->clear_cache("index.tpl", "CACHEID");
|
$smarty->clear_cache('index.tpl', 'CACHEID');
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
|
<link linkend="api.clear.all.cache">clear_all_cache()</link>
|
||||||
|
and
|
||||||
<link linkend="caching">caching</link>.
|
<link linkend="caching">caching</link>.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
@@ -66,3 +72,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -2,28 +2,31 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.clear.compiled.tpl">
|
<refentry id="api.clear.compiled.tpl">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>clear_compiled_tpl</refname>
|
<refname>clear_compiled_tpl()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>clears the compiled version of the specified template resource</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>clear_compiled_tpl</methodname>
|
<type>void</type><methodname>clear_compiled_tpl</methodname>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>tpl_file</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>tpl_file</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter>
|
||||||
|
</methodparam>
|
||||||
<methodparam choice="opt"><type>int</type><parameter>exp_time</parameter></methodparam>
|
<methodparam choice="opt"><type>int</type><parameter>exp_time</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This clears the compiled version of the specified template
|
This clears the compiled version of the specified template
|
||||||
resource, or all compiled template files if one is not specified.
|
resource, or all compiled template files if one is not specified.
|
||||||
if you pass a compile_id only the compiled template for this
|
If you pass a <link linkend="variable.compile.id">$compile_id</link>
|
||||||
specific compile_id is cleared. if you pass an exp_time, then only
|
only the compiled template for this
|
||||||
|
specific <link linkend="variable.compile.id">$compile_id</link>
|
||||||
|
is cleared. if you pass an exp_time, then only
|
||||||
compiled templates older than exp_time seconds are cleared, by
|
compiled templates older than exp_time seconds are cleared, by
|
||||||
default all compiled templates are cleared regardless of their age.
|
default all compiled templates are cleared regardless of their age.
|
||||||
This function is for advanced use only, not normally needed.
|
This function is for advanced use only, not normally needed.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>clear_compiled_tpl</title>
|
<title>clear_compiled_tpl()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
@@ -58,3 +61,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.clear.config">
|
<refentry id="api.clear.config">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>clear_config</refname>
|
<refname>clear_config()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>clears assigned config variables</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>clear_config</methodname>
|
<type>void</type><methodname>clear_config</methodname>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>var</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>var</parameter></methodparam>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
supplied, only that variable is cleared.
|
supplied, only that variable is cleared.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>clear_config</title>
|
<title>clear_config()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
@@ -33,6 +33,7 @@ $smarty->clear_config('foobar');
|
|||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
|
<link linkend="api.get.config.vars">get_config_vars()</link>,
|
||||||
<link linkend="language.config.variables">config variables</link>,
|
<link linkend="language.config.variables">config variables</link>,
|
||||||
<link linkend="config.files">config files</link>,
|
<link linkend="config.files">config files</link>,
|
||||||
<link linkend="language.function.config.load">{config_load}</link>,
|
<link linkend="language.function.config.load">{config_load}</link>,
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.config.load">
|
<refentry id="api.config.load">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>config_load</refname>
|
<refname>config_load()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose> loads config file data and assigns it to the template</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>config_load</methodname>
|
<type>void</type><methodname>config_load</methodname>
|
||||||
<methodparam><type>string</type><parameter>file</parameter></methodparam>
|
<methodparam><type>string</type><parameter>file</parameter></methodparam>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<example>
|
<example>
|
||||||
<title>config_load</title>
|
<title>config_load()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
@@ -51,6 +51,7 @@ $smarty->config_load('my.conf', 'foobar');
|
|||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="language.function.config.load">{config_load}</link>,
|
<link linkend="language.function.config.load">{config_load}</link>,
|
||||||
|
<link linkend="api.get.config.vars">get_config_vars()</link>,
|
||||||
<link linkend="api.clear.config">clear_config()</link>,
|
<link linkend="api.clear.config">clear_config()</link>,
|
||||||
and
|
and
|
||||||
<link linkend="language.config.variables">config variables</link>
|
<link linkend="language.config.variables">config variables</link>
|
||||||
|
@@ -2,19 +2,22 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.display">
|
<refentry id="api.display">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>display</refname>
|
<refname>display()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>displays the template</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>display</methodname>
|
<type>void</type><methodname>display</methodname>
|
||||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter>
|
||||||
|
</methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This displays the template. Supply a valid <link
|
This displays the template unlike
|
||||||
|
<link linkend="api.fetch">fetch()</link>.
|
||||||
|
Supply a valid <link
|
||||||
linkend="template.resources">template resource</link>
|
linkend="template.resources">template resource</link>
|
||||||
type and path. As an optional second parameter, you can pass a
|
type and path. As an optional second parameter, you can pass a
|
||||||
$cache id.
|
$cache id.
|
||||||
@@ -23,7 +26,7 @@
|
|||||||
</para>
|
</para>
|
||||||
¶meter.compileid;
|
¶meter.compileid;
|
||||||
<example>
|
<example>
|
||||||
<title>display</title>
|
<title>display()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
@@ -57,24 +60,25 @@ $smarty->display("index.tpl");
|
|||||||
<para>
|
<para>
|
||||||
Use the syntax for <link
|
Use the syntax for <link
|
||||||
linkend="template.resources">template resources</link> to
|
linkend="template.resources">template resources</link> to
|
||||||
display files outside of the $template_dir directory.
|
display files outside of the
|
||||||
|
<link linkend="variable.template.dir">$template_dir</link> directory.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>function display template resource examples</title>
|
<title>function display() template resource examples</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// absolute filepath
|
// absolute filepath
|
||||||
$smarty->display("/usr/local/include/templates/header.tpl");
|
$smarty->display('/usr/local/include/templates/header.tpl');
|
||||||
|
|
||||||
// absolute filepath (same thing)
|
// absolute filepath (same thing)
|
||||||
$smarty->display("file:/usr/local/include/templates/header.tpl");
|
$smarty->display('file:/usr/local/include/templates/header.tpl');
|
||||||
|
|
||||||
// windows absolute filepath (MUST use "file:" prefix)
|
// windows absolute filepath (MUST use "file:" prefix)
|
||||||
$smarty->display("file:C:/www/pub/templates/header.tpl");
|
$smarty->display('file:C:/www/pub/templates/header.tpl');
|
||||||
|
|
||||||
// include from template resource named "db"
|
// include from template resource named "db"
|
||||||
$smarty->display("db:header.tpl");
|
$smarty->display('db:header.tpl');
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
@@ -106,3 +110,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -2,19 +2,21 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.fetch">
|
<refentry id="api.fetch">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>fetch</refname>
|
<refname>fetch()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>returns the template output</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>string</type><methodname>fetch</methodname>
|
<type>string</type><methodname>fetch</methodname>
|
||||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>$compile_id</parameter>
|
||||||
|
</methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This returns the template output instead of displaying it.
|
This returns the template output instead of
|
||||||
|
<link linkend="api.display">displaying</link> it.
|
||||||
Supply a valid <link
|
Supply a valid <link
|
||||||
linkend="template.resources">template resource</link>
|
linkend="template.resources">template resource</link>
|
||||||
type and path. As an optional second parameter, you can pass a
|
type and path. As an optional second parameter, you can pass a
|
||||||
@@ -22,45 +24,101 @@
|
|||||||
section</link> for more information.
|
section</link> for more information.
|
||||||
</para>
|
</para>
|
||||||
¶meter.compileid;
|
¶meter.compileid;
|
||||||
<para>
|
|
||||||
<example>
|
<para>
|
||||||
<title>fetch</title>
|
<example>
|
||||||
<programlisting role="php">
|
<title>fetch()</title>
|
||||||
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
include("Smarty.class.php");
|
include('Smarty.class.php');
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
|
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
// only do db calls if cache doesn't exist
|
// only do db calls if cache doesn't exist
|
||||||
if(!$smarty->is_cached("index.tpl")) {
|
if(!$smarty->is_cached('index.tpl')) {
|
||||||
|
|
||||||
// dummy up some data
|
// dummy up some data
|
||||||
$address = "245 N 50th";
|
$address = '245 N 50th';
|
||||||
$db_data = array(
|
$db_data = array(
|
||||||
"City" => "Lincoln",
|
'City' => 'Lincoln',
|
||||||
"State" => "Nebraska",
|
'State' => 'Nebraska',
|
||||||
"Zip" => "68502"
|
'Zip' => '68502'
|
||||||
);
|
);
|
||||||
|
|
||||||
$smarty->assign("Name","Fred");
|
$smarty->assign('Name','Fred');
|
||||||
$smarty->assign("Address",$address);
|
$smarty->assign('Address',$address);
|
||||||
$smarty->assign($db_data);
|
$smarty->assign($db_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// capture the output
|
// capture the output
|
||||||
$output = $smarty->fetch("index.tpl");
|
$output = $smarty->fetch('index.tpl');
|
||||||
|
|
||||||
// do something with $output here
|
// do something with $output here
|
||||||
|
|
||||||
echo $output;
|
echo $output;
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<title>Using fetch() to send an email</title>
|
||||||
|
<para>
|
||||||
|
The email_body.txt template
|
||||||
</para>
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
Dear {$contact.name},
|
||||||
|
|
||||||
|
Welcome and thankyou for signing up as a member of our user group,
|
||||||
|
|
||||||
|
Click on the link below to login with your user name of '{$contact.login_id}'
|
||||||
|
so you can post in our forums.
|
||||||
|
|
||||||
|
http://{$smarty.server.SERVER_NAME}/index.php?page=login
|
||||||
|
|
||||||
|
List master
|
||||||
|
Some user group
|
||||||
|
|
||||||
|
{include file="email_disclaimer.txt"}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
The email_disclaimer.txt template
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
This e-mail is intended for the addressee shown. It contains information
|
||||||
|
....... etc .......
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
and the php script using the PHP
|
||||||
|
<ulink url="&url.php-manual;function.mail">mail()</ulink> function
|
||||||
|
</para>
|
||||||
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// get contact from database eg using pear or adodb
|
||||||
|
$query = 'select name, email, login_id from contacts where contact_id='.$contact_id;
|
||||||
|
$contact = $db->getRow($sql);
|
||||||
|
$smarty->assign('contact', $contact);
|
||||||
|
|
||||||
|
mail($contact['email'], 'Subject', $smarty->fetch('email_body.txt'));
|
||||||
|
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="language.function.fetch">{fetch}</link>
|
<link linkend="language.function.fetch">{fetch}</link>
|
||||||
@@ -92,3 +150,5 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,24 +2,26 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.get.config.vars">
|
<refentry id="api.get.config.vars">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>get_config_vars</refname>
|
<refname>get_config_vars()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>returns the given loaded config variable value</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>array</type><methodname>get_config_vars</methodname>
|
<type>array</type><methodname>get_config_vars</methodname>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This returns the given loaded config variable value. If no parameter
|
If no parameter is given, an array of all loaded
|
||||||
is given, an array of all loaded config variables is returned.
|
<link linkend="language.config.variables">config variables</link>
|
||||||
|
is returned.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>get_config_vars</title>
|
<title>get_config_vars()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// get loaded config template var 'foo'
|
// get loaded config template var 'foo'
|
||||||
$foo = $smarty->get_config_vars('foo');
|
$foo = $smarty->get_config_vars('foo');
|
||||||
|
|
||||||
|
@@ -2,22 +2,23 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.get.registered.object">
|
<refentry id="api.get.registered.object">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>get_registered_object</refname>
|
<refname>get_registered_object()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>returns a reference to a registered object</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>array</type><methodname>get_registered_object</methodname>
|
<type>array</type><methodname>get_registered_object</methodname>
|
||||||
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This returns a reference to a registered object. This is useful
|
This is useful
|
||||||
from within a custom function when you need direct access to a
|
from within a custom function when you need direct access to a
|
||||||
registered object.
|
<link linkend="api.register.object">registered object</link>. See
|
||||||
|
<link linkend="advanced.features.objects">objects</link> for more info.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>get_registered_object</title>
|
<title>get_registered_object()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
@@ -33,6 +34,13 @@ function smarty_block_foo($params, &$smarty)
|
|||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.object">register_object()</link>,
|
||||||
|
<link linkend="api.unregister.object">unregister_object()</link>
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features.objects">objects section</link>
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,18 +2,19 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.get.template.vars">
|
<refentry id="api.get.template.vars">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>get_template_vars</refname>
|
<refname>get_template_vars()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>returns assigned variable value(s)</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>array</type><methodname>get_template_vars</methodname>
|
<type>array</type><methodname>get_template_vars</methodname>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This returns the given assigned variable value. If no parameter
|
If no parameter
|
||||||
is given, an array of all assigned variables is returned.
|
is given, an array of all <link linkend="api.assign">assigned</link>
|
||||||
|
variables are returned.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>get_template_vars</title>
|
<title>get_template_vars</title>
|
||||||
@@ -35,7 +36,10 @@ print_r($tpl_vars);
|
|||||||
<para>
|
<para>
|
||||||
See also <link linkend="api.assign">assign()</link>,
|
See also <link linkend="api.assign">assign()</link>,
|
||||||
<link linkend="language.function.assign">{assign}</link>,
|
<link linkend="language.function.assign">{assign}</link>,
|
||||||
<link linkend="api.clear.assign">clear_assign()</link>
|
<link linkend="api.assign.by.ref">assign_by_ref()</link>,
|
||||||
|
<link linkend="api.append">append()</link>,
|
||||||
|
<link linkend="api.clear.assign">clear_assign()</link>,
|
||||||
|
<link linkend="api.clear.all.assign">clear_all_assign()</link>
|
||||||
and
|
and
|
||||||
<link linkend="api.get.config.vars">get_config_vars()</link>
|
<link linkend="api.get.config.vars">get_config_vars()</link>
|
||||||
</para>
|
</para>
|
||||||
|
@@ -2,41 +2,44 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.is.cached">
|
<refentry id="api.is.cached">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>is_cached</refname>
|
<refname>is_cached()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>returns true if there is a valid cache for this template</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>bool</type><methodname>is_cached</methodname>
|
<type>bool</type><methodname>is_cached</methodname>
|
||||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter>
|
||||||
|
</methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This returns &true; if there is a valid cache for this template.
|
|
||||||
This only works if <link
|
This only works if <link
|
||||||
linkend="variable.caching">$caching</link> is set to true.
|
linkend="variable.caching">$caching</link> is set to true. See also the
|
||||||
|
<link linkend="caching">caching section</link>.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>is_cached</title>
|
<title>is_cached()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
if(!$smarty->is_cached("index.tpl")) {
|
if(!$smarty->is_cached('index.tpl')) {
|
||||||
// do database calls, assign vars here
|
// do database calls, assign vars here
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty->display("index.tpl");
|
$smarty->display('index.tpl');
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<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.
|
in case you want
|
||||||
|
<link linkend="caching.multiple.caches">multiple caches</link>
|
||||||
|
for the given template.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
You can supply a
|
You can supply a
|
||||||
@@ -46,21 +49,22 @@ $smarty->display("index.tpl");
|
|||||||
<link linkend="variable.compile.id">$compile_id</link> is used.
|
<link linkend="variable.compile.id">$compile_id</link> is used.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
If you do not want to pass a cache id but want to pass a compile
|
If you do not want to pass a cache id but want to pass a
|
||||||
id you have to pass <literal>null</literal> as cache id.
|
<link linkend="variable.compile.id">$compile_id</link>
|
||||||
|
you have to pass <emphasis>null</emphasis> as cache id.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>is_cached with multiple-cache template</title>
|
<title>is_cached() with multiple-cache template</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->caching = true;
|
$smarty->caching = true;
|
||||||
|
|
||||||
if(!$smarty->is_cached("index.tpl", "FrontPage")) {
|
if(!$smarty->is_cached('index.tpl', 'FrontPage')) {
|
||||||
// do database calls, assign vars here
|
// do database calls, assign vars here
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty->display("index.tpl", "FrontPage");
|
$smarty->display('index.tpl', 'FrontPage');
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
@@ -70,19 +74,29 @@ $smarty->display("index.tpl", "FrontPage");
|
|||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
If <literal>is_cached</literal> returns true it actually loads the
|
If <literal>is_cached()</literal> returns true it actually loads the
|
||||||
cached output and stores it internally. Any subsequent call to
|
cached output and stores it internally. Any subsequent call to
|
||||||
<link linkend="api.display">display()</link> or
|
<link linkend="api.display">display()</link> or
|
||||||
<link linkend="api.fetch">fetch()</link>
|
<link linkend="api.fetch">fetch()</link>
|
||||||
will return this internally stored output and does not try to reload
|
will return this internally stored output and does not try to reload
|
||||||
the cache file. This prevents a race condition that may occur when a
|
the cache file. This prevents a race condition that may occur when a
|
||||||
second process clears the cache between the calls to is_cached and to
|
second process clears the cache between the calls to is_cached() and to
|
||||||
display in the example above. This also means calls to
|
<link linkend="api.display">display()</link>
|
||||||
|
in the example above. This also means calls to
|
||||||
<link linkend="api.clear.cache">clear_cache()</link>
|
<link linkend="api.clear.cache">clear_cache()</link>
|
||||||
and other changes of the cache-settings may have no effect after
|
and other changes of the cache-settings may have no effect after
|
||||||
is_cached() returned true.
|
is_cached() returned true.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.clear.cache">clear_cache()</link>,
|
||||||
|
<link linkend="api.clear.all.cache">clear_all_cache()</link>,
|
||||||
|
and
|
||||||
|
<link linkend="caching">caching section</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
@@ -105,3 +119,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -2,18 +2,18 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.load.filter">
|
<refentry id="api.load.filter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>load_filter</refname>
|
<refname>load_filter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>load a filter plugin</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>load_filter</methodname>
|
<type>void</type><methodname>load_filter</methodname>
|
||||||
<methodparam><type>string</type><parameter>type</parameter></methodparam>
|
<methodparam><type>string</type><parameter>type</parameter></methodparam>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This function can be used to load a filter plugin. The first
|
The first
|
||||||
argument specifies the type of the filter to load and can be one
|
argument specifies the type of the filter to load and can be one
|
||||||
of the following: 'pre', 'post', or 'output'. The second argument
|
of the following: 'pre', 'post', or 'output'. The second argument
|
||||||
specifies the name of the filter plugin, for example, 'trim'.
|
specifies the name of the filter plugin, for example, 'trim'.
|
||||||
@@ -23,13 +23,28 @@
|
|||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->load_filter('pre', 'trim'); // load prefilter named 'trim'
|
|
||||||
$smarty->load_filter('pre', 'datefooter'); // load another prefilter named 'datefooter'
|
// load prefilter named 'trim'
|
||||||
$smarty->load_filter('output', 'compress'); // load output filter named 'compress'
|
$smarty->load_filter('pre', 'trim');
|
||||||
|
|
||||||
|
// load another prefilter named 'datefooter'
|
||||||
|
$smarty->load_filter('pre', 'datefooter');
|
||||||
|
|
||||||
|
// load output filter named 'compress'
|
||||||
|
$smarty->load_filter('output', 'compress');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
|
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||||
|
<link linkend="api.register.outputfilter">register_outputfilter()</link>
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features">Advanced features</link>.
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.block">
|
<refentry id="api.register.block">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_block</refname>
|
<refname>register_block()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register block functions plugins</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_block</methodname>
|
<type>void</type><methodname>register_block</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
<methodparam><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register block functions plugins.
|
Use this to dynamically register
|
||||||
|
<link linkend="plugins.block.functions">block functions plugins</link>.
|
||||||
Pass in the block function name, followed by the PHP
|
Pass in the block function name, followed by the PHP
|
||||||
function callback that implements it.
|
function callback that implements it.
|
||||||
</para>
|
</para>
|
||||||
@@ -38,11 +39,11 @@
|
|||||||
on how to use them properly.
|
on how to use them properly.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>register_block</title>
|
<title>register_block()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->register_block("translate", "do_translation");
|
$smarty->register_block('translate', 'do_translation');
|
||||||
|
|
||||||
function do_translation ($params, $content, &$smarty, &$repeat)
|
function do_translation ($params, $content, &$smarty, &$repeat)
|
||||||
{
|
{
|
||||||
@@ -67,6 +68,14 @@ Hello, world!
|
|||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.unregister.block">unregister_block()</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.block.functions">Plugin Block Functions</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.compiler.function">
|
<refentry id="api.register.compiler.function">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_compiler_function</refname>
|
<refname>register_compiler_function()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register a compiler function plugin</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>bool</type><methodname>register_compiler_function</methodname>
|
<type>bool</type><methodname>register_compiler_function</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
@@ -14,17 +14,22 @@
|
|||||||
<methodparam><type>bool</type><parameter>cacheable</parameter></methodparam>
|
<methodparam><type>bool</type><parameter>cacheable</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register a compiler function plugin.
|
Pass in the
|
||||||
Pass in the compiler function name, followed by the PHP
|
<link linkend="plugins.compiler.functions">compiler function</link> name,
|
||||||
function that implements it.
|
followed by the PHP function that implements it.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>impl</parameter> can be either (a) a string
|
The php-function callback <parameter>impl</parameter> can be either:
|
||||||
containing the function name or (b) an array of the form
|
</para>
|
||||||
<literal>array(&$object, $method)</literal> with
|
<para>
|
||||||
|
(a) a string containing the function name
|
||||||
|
</para>
|
||||||
|
<para>(b) an array of the form <literal>array(&$object, $method)</literal> with
|
||||||
<literal>&$object</literal> being a reference to an
|
<literal>&$object</literal> being a reference to an
|
||||||
object and <literal>$method</literal> being a string
|
object and <literal>$method</literal> being a string
|
||||||
containing the mehod-name or (c) an array of the form
|
containing the mehod-name
|
||||||
|
</para>
|
||||||
|
<para>(c) an array of the form
|
||||||
<literal>array(&$class, $method)</literal> with
|
<literal>array(&$class, $method)</literal> with
|
||||||
<literal>$class</literal> being a classname and
|
<literal>$class</literal> being a classname and
|
||||||
<literal>$method</literal> being a class method of that
|
<literal>$method</literal> being a class method of that
|
||||||
@@ -35,6 +40,16 @@
|
|||||||
most cases. See <link linkend="caching.cacheable">Controlling
|
most cases. See <link linkend="caching.cacheable">Controlling
|
||||||
Cacheability of Plugins' Output</link> on how to it properly.
|
Cacheability of Plugins' Output</link> on how to it properly.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link
|
||||||
|
linkend="api.unregister.compiler.function">unregister_compiler_function()
|
||||||
|
</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.compiler.functions">Plugin Compiler Functions</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,32 +2,39 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.function">
|
<refentry id="api.register.function">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_function</refname>
|
<refname>register_function()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register template function plugins</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_function</methodname>
|
<type>void</type><methodname>register_function</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>bool</type><parameter>cacheable</parameter></methodparam>
|
<methodparam choice="opt"><type>bool</type><parameter>cacheable</parameter></methodparam>
|
||||||
<methodparam choice="opt"><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
<methodparam choice="opt"><type>mixed</type><parameter>cache_attrs</parameter>
|
||||||
|
</methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register template function plugins.
|
Pass in the <link linkend="plugins.functions">template function</link>
|
||||||
Pass in the template function name, followed by the PHP
|
name, followed by the PHP function name that implements it.
|
||||||
function name that implements it.
|
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>impl</parameter> can be either (a) a string
|
The php-function callback <parameter>impl</parameter> can be either
|
||||||
containing the function name or (b) an array of the form
|
</para>
|
||||||
|
<para>
|
||||||
|
(a) a string containing the function name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(b) an array of the form
|
||||||
<literal>array(&$object, $method)</literal> with
|
<literal>array(&$object, $method)</literal> with
|
||||||
<literal>&$object</literal> being a reference to an
|
<literal>&$object</literal> being a reference to an
|
||||||
object and <literal>$method</literal> being a string
|
object and <literal>$method</literal> being a string
|
||||||
containing the mehod-name or (c) an array of the form
|
containing the mehod-name
|
||||||
<literal>array(&$class, $method)</literal> with
|
</para>
|
||||||
<literal>$class</literal> being a classname and
|
<para>
|
||||||
|
(c) an array of the form <literal>array(&$class, $method)</literal>
|
||||||
|
with <literal>$class</literal> being a classname and
|
||||||
<literal>$method</literal> being a class method of that
|
<literal>$method</literal> being a class method of that
|
||||||
class.
|
class.
|
||||||
</para>
|
</para>
|
||||||
@@ -38,11 +45,11 @@
|
|||||||
on how to use them properly.
|
on how to use them properly.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>register_function</title>
|
<title>register_function()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->register_function("date_now", "print_current_date");
|
$smarty->register_function('date_now', 'print_current_date');
|
||||||
|
|
||||||
function print_current_date($params)
|
function print_current_date($params)
|
||||||
{
|
{
|
||||||
@@ -53,13 +60,30 @@ function print_current_date($params)
|
|||||||
return strftime($format,time());
|
return strftime($format,time());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now you can use this in Smarty to print the current date: {date_now}
|
|
||||||
// or, {date_now format="%Y/%m/%d"} to format it.
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
<para>
|
||||||
|
And in the template
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
{date_now}
|
||||||
|
|
||||||
|
{* or to format differently *}
|
||||||
|
{date_now format="%Y/%m/%d"}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.unregister.function">unregister_function()</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.functions">Plugin functions</link>
|
||||||
|
.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
@@ -82,3 +106,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -2,18 +2,18 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.modifier">
|
<refentry id="api.register.modifier">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_modifier</refname>
|
<refname>register_modifier()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register modifier plugin</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_modifier</methodname>
|
<type>void</type><methodname>register_modifier</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register modifier plugin. Pass in the
|
Pass in the
|
||||||
template modifier name, followed by the PHP function that it
|
template modifier name, followed by the PHP function that it
|
||||||
implements it.
|
implements it.
|
||||||
</para>
|
</para>
|
||||||
@@ -30,25 +30,33 @@
|
|||||||
class.
|
class.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>register_modifier</title>
|
<title>register_modifier()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// let's map PHP's stripslashes function to a Smarty modifier.
|
// let's map PHP's stripslashes function to a Smarty modifier.
|
||||||
|
$smarty->register_modifier('sslash', 'stripslashes');
|
||||||
|
|
||||||
$smarty->register_modifier("sslash", "stripslashes");
|
|
||||||
|
|
||||||
// now you can use {$var|sslash} to strip slashes from variables
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
<para>template</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
{* use 'sslash' to strip slashes from variables *}
|
||||||
|
{$var|sslash}
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="api.unregister.modifier">unregister_modifier()</link>,
|
<link linkend="api.unregister.modifier">unregister_modifier()</link>,
|
||||||
<link linkend="api.register.function">register_function()</link>,
|
<link linkend="api.register.function">register_function()</link>,
|
||||||
<link linkend="language.modifiers">modifiers</link>,
|
<link linkend="language.modifiers">modifiers</link>,
|
||||||
|
|
||||||
<link linkend="plugins">Extending Smarty with plugins</link>
|
<link linkend="plugins">Extending Smarty with plugins</link>
|
||||||
and
|
and
|
||||||
<link linkend="plugins.modifiers">Plugin modifiers</link>,
|
<link linkend="plugins.modifiers">Plugin modifiers</link>,
|
||||||
|
@@ -2,26 +2,27 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.object">
|
<refentry id="api.register.object">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_object</refname>
|
<refname>register_object()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>register an object for use in the templates</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_object</methodname>
|
<type>void</type><methodname>register_object</methodname>
|
||||||
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
||||||
<methodparam><type>object</type><parameter>object</parameter></methodparam>
|
<methodparam><type>object</type><parameter>object</parameter></methodparam>
|
||||||
<methodparam><type>array</type><parameter>allowed_methods_properties</parameter></methodparam>
|
<methodparam><type>array</type><parameter>allowed_methods_properties</parameter>
|
||||||
|
</methodparam>
|
||||||
<methodparam><type>boolean</type><parameter>format</parameter></methodparam>
|
<methodparam><type>boolean</type><parameter>format</parameter></methodparam>
|
||||||
<methodparam><type>array</type><parameter>block_methods</parameter></methodparam>
|
<methodparam><type>array</type><parameter>block_methods</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This is to register an object for use in the templates. See the
|
See the
|
||||||
<link linkend="advanced.features.objects">object section</link>
|
<link linkend="advanced.features.objects">objects section</link>
|
||||||
of the manual for examples.
|
for examples.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
See Also <link linkend="api.unregister.object">unregister_object()</link>.
|
See also <link linkend="api.unregister.object">unregister_object()</link>.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
@@ -46,3 +47,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -2,34 +2,55 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.outputfilter">
|
<refentry id="api.register.outputfilter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_outputfilter</refname>
|
<refname>register_outputfilter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register outputfilters</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_outputfilter</methodname>
|
<type>void</type><methodname>register_outputfilter</methodname>
|
||||||
<methodparam><type>mixed</type><parameter>function</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>function</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register outputfilters to operate on
|
Use this to dynamically register
|
||||||
a template's output before it is displayed. See
|
<link linkend="plugins.outputfilters">outputfilters</link> to operate on
|
||||||
|
a template's output before it is
|
||||||
|
<link linkend="api.display">displayed</link>. See
|
||||||
<link linkend="advanced.features.outputfilters">template output
|
<link linkend="advanced.features.outputfilters">template output
|
||||||
filters</link>
|
filters</link>
|
||||||
for more information on how to set up an output filter function.
|
for more information on how to set up an output filter function.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>function</parameter> can be either (a) a string
|
The php-function callback <parameter>function</parameter> can be either
|
||||||
containing the function name or (b) an array of the form
|
</para>
|
||||||
|
<para>
|
||||||
|
(a) a string
|
||||||
|
containing the function name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(b) an array of the form
|
||||||
<literal>array(&$object, $method)</literal> with
|
<literal>array(&$object, $method)</literal> with
|
||||||
<literal>&$object</literal> being a reference to an
|
<literal>&$object</literal> being a reference to an
|
||||||
object and <literal>$method</literal> being a string
|
object and <literal>$method</literal> being a string
|
||||||
containing the mehod-name or (c) an array of the form
|
containing the mehod-name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(c) an array of the form
|
||||||
<literal>array(&$class, $method)</literal> with
|
<literal>array(&$class, $method)</literal> with
|
||||||
<literal>$class</literal> being a classname and
|
<literal>$class</literal> being a classname and
|
||||||
<literal>$method</literal> being a class method of that
|
<literal>$method</literal> being a class method of that
|
||||||
class.
|
class.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.unregister.outputfilter">unregister_outputfilter()</link>,
|
||||||
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
|
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||||
|
<link linkend="api.load.filter">load_filter()</link>,
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features.outputfilters">template
|
||||||
|
output filters</link>.
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,33 +2,54 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.postfilter">
|
<refentry id="api.register.postfilter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_postfilter</refname>
|
<refname>register_postfilter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register postfilters</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_postfilter</methodname>
|
<type>void</type><methodname>register_postfilter</methodname>
|
||||||
<methodparam><type>mixed</type><parameter>function</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>function</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register postfilters to run templates
|
Use this to dynamically register
|
||||||
|
<link linkend="advanced.features.postfilters">postfilters</link> to run templates
|
||||||
through after they are compiled. See <link
|
through after they are compiled. See <link
|
||||||
linkend="advanced.features.postfilters">template postfilters</link> for
|
linkend="advanced.features.postfilters">template postfilters</link> for
|
||||||
more information on how to setup a postfiltering function.
|
more information on how to setup a postfiltering function.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>function</parameter> can be either (a) a string
|
The php-function callback <parameter>function</parameter> can be either
|
||||||
containing the function name or (b) an array of the form
|
</para>
|
||||||
|
<para>
|
||||||
|
(a) a string containing the function name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(b) an array of the form
|
||||||
<literal>array(&$object, $method)</literal> with
|
<literal>array(&$object, $method)</literal> with
|
||||||
<literal>&$object</literal> being a reference to an
|
<literal>&$object</literal> being a reference to an
|
||||||
object and <literal>$method</literal> being a string
|
object and <literal>$method</literal> being a string
|
||||||
containing the mehod-name or (c) an array of the form
|
containing the mehod-name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(c) an array of the form
|
||||||
<literal>array(&$class, $method)</literal> with
|
<literal>array(&$class, $method)</literal> with
|
||||||
<literal>$class</literal> being a classname and
|
<literal>$class</literal> being a classname and
|
||||||
<literal>$method</literal> being a class method of that
|
<literal>$method</literal> being a class method of that
|
||||||
class.
|
class.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.unregister.postfilter">unregister_postfilter()</link>,
|
||||||
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
|
<link linkend="api.register.outputfilter">register_ouputfilter()</link>,
|
||||||
|
<link linkend="api.load.filter">load_filter()</link>,
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features.outputfilters">template
|
||||||
|
output filters</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,33 +2,53 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.prefilter">
|
<refentry id="api.register.prefilter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_prefilter</refname>
|
<refname>register_prefilter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register prefilters</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_prefilter</methodname>
|
<type>void</type><methodname>register_prefilter</methodname>
|
||||||
<methodparam><type>mixed</type><parameter>function</parameter></methodparam>
|
<methodparam><type>mixed</type><parameter>function</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register prefilters to run templates
|
Use this to dynamically register
|
||||||
through before they are compiled. See <link
|
<link linkend="advanced.features.prefilters">prefilters</link>
|
||||||
|
to run templates through before they are compiled. See <link
|
||||||
linkend="advanced.features.prefilters">template prefilters</link> for
|
linkend="advanced.features.prefilters">template prefilters</link> for
|
||||||
more information on how to setup a prefiltering function.
|
more information on how to setup a prefiltering function.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>function</parameter> can be either (a) a string
|
The php-function callback <parameter>function</parameter> can be either
|
||||||
containing the function name or (b) an array of the form
|
</para>
|
||||||
|
<para>
|
||||||
|
(a) a string
|
||||||
|
containing the function name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(b) an array of the form
|
||||||
<literal>array(&$object, $method)</literal> with
|
<literal>array(&$object, $method)</literal> with
|
||||||
<literal>&$object</literal> being a reference to an
|
<literal>&$object</literal> being a reference to an
|
||||||
object and <literal>$method</literal> being a string
|
object and <literal>$method</literal> being a string
|
||||||
containing the mehod-name or (c) an array of the form
|
containing the mehod-name
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
(c) an array of the form
|
||||||
<literal>array(&$class, $method)</literal> with
|
<literal>array(&$class, $method)</literal> with
|
||||||
<literal>$class</literal> being a classname and
|
<literal>$class</literal> being a classname and
|
||||||
<literal>$method</literal> being a class method of that
|
<literal>$method</literal> being a class method of that
|
||||||
class.
|
class.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.unregister.prefilter">unregister_prefilter()</link>,
|
||||||
|
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||||
|
<link linkend="api.register.outputfilter">register_ouputfilter()</link>,
|
||||||
|
<link linkend="api.load.filter">load_filter()</link>,
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features.outputfilters">template
|
||||||
|
output filters</link>.
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,18 +2,20 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.register.resource">
|
<refentry id="api.register.resource">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>register_resource</refname>
|
<refname>register_resource()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically register resources</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Descrption</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>register_resource</methodname>
|
<type>void</type><methodname>register_resource</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
<methodparam><type>array</type><parameter>resource_funcs</parameter></methodparam>
|
<methodparam><type>array</type><parameter>resource_funcs</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically register a resource plugin with Smarty.
|
Use this to dynamically register a
|
||||||
|
<link linkend="template.resources">resource plugin</link>
|
||||||
|
with Smarty.
|
||||||
Pass in the name of the resource and the array of PHP functions
|
Pass in the name of the resource and the array of PHP functions
|
||||||
implementing it. See
|
implementing it. See
|
||||||
<link linkend="template.resources">template resources</link>
|
<link linkend="template.resources">template resources</link>
|
||||||
@@ -40,18 +42,28 @@
|
|||||||
"secure" and "trusted".
|
"secure" and "trusted".
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>register_resource</title>
|
<title>register_resource()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->register_resource("db", array("db_get_template",
|
$smarty->register_resource('db', array(
|
||||||
"db_get_timestamp",
|
'db_get_template',
|
||||||
"db_get_secure",
|
'db_get_timestamp',
|
||||||
"db_get_trusted"));
|
'db_get_secure',
|
||||||
|
'db_get_trusted')
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.unregister.resource">unregister_resource()</link>
|
||||||
|
and
|
||||||
|
<link linkend="template.resources">template resources</link>
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,18 +2,17 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.template.exists">
|
<refentry id="api.template.exists">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>template_exists</refname>
|
<refname>template_exists()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>checks whether the specified template exists</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>bool</type><methodname>template_exists</methodname>
|
<type>bool</type><methodname>template_exists</methodname>
|
||||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
This function checks whether the specified template exists. It can
|
It can accept either a path to the template on the filesystem or a
|
||||||
accept either a path to the template on the filesystem or a
|
|
||||||
resource string specifying the template.
|
resource string specifying the template.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.trigger.error">
|
<refentry id="api.trigger.error">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>trigger_error</refname>
|
<refname>trigger_error()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>output an error message</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>trigger_error</methodname>
|
<type>void</type><methodname>trigger_error</methodname>
|
||||||
<methodparam><type>string</type><parameter>error_msg</parameter></methodparam>
|
<methodparam><type>string</type><parameter>error_msg</parameter></methodparam>
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
<para>
|
<para>
|
||||||
This function can be used to output an error message using Smarty.
|
This function can be used to output an error message using Smarty.
|
||||||
<parameter>level</parameter> parameter can be one of the values
|
<parameter>level</parameter> parameter can be one of the values
|
||||||
used for
|
used for the PHP
|
||||||
<ulink url="&url.php-manual;trigger_error">trigger_error()</ulink>
|
<ulink url="&url.php-manual;trigger_error">trigger_error()</ulink>
|
||||||
PHP function, i.e. E_USER_NOTICE,
|
function, i.e. E_USER_NOTICE,
|
||||||
E_USER_WARNING, etc. By default it's E_USER_WARNING.
|
E_USER_WARNING, etc. By default it's E_USER_WARNING.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
|
@@ -2,19 +2,28 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.block">
|
<refentry id="api.unregister.block">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_block</refname>
|
<refname>unregister_block()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister block function plugins</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_block</methodname>
|
<type>void</type><methodname>unregister_block</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically unregister block function plugin.
|
Use this to dynamically unregister
|
||||||
|
<link linkend="plugins.block.functions">block function plugins</link>.
|
||||||
Pass in the block function <parameter>name</parameter>.
|
Pass in the block function <parameter>name</parameter>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.block">register_block()</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.block.functions">Block Functions Plugins</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,19 +2,29 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.compiler.function">
|
<refentry id="api.unregister.compiler.function">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_compiler_function</refname>
|
<refname>unregister_compiler_function()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister a compiler function</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_compiler_function</methodname>
|
<type>void</type><methodname>unregister_compiler_function</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically unregister a compiler function. Pass in
|
Pass in
|
||||||
the <parameter>name</parameter> of the compiler function.
|
the <parameter>name</parameter> of the compiler function.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link
|
||||||
|
linkend="api.register.compiler.function">register_compiler_function()
|
||||||
|
</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.compiler.functions">Plugin Compiler Functions</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -3,16 +3,15 @@
|
|||||||
<refentry id="api.unregister.function">
|
<refentry id="api.unregister.function">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_function</refname>
|
<refname>unregister_function</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister template function plugin</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_function</methodname>
|
<type>void</type><methodname>unregister_function</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically unregister template function plugin.
|
|
||||||
Pass in the template function name.
|
Pass in the template function name.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
@@ -20,13 +19,22 @@
|
|||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// we don't want template designers to have access to system files
|
|
||||||
|
|
||||||
$smarty->unregister_function("fetch");
|
// we don't want template designers to have access to system files
|
||||||
|
$smarty->unregister_function('fetch');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link
|
||||||
|
linkend="api.register.function">register_function()
|
||||||
|
</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,31 +2,37 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.modifier">
|
<refentry id="api.unregister.modifier">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_modifier</refname>
|
<refname>unregister_modifier()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister modifier plugin</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_modifier</methodname>
|
<type>void</type><methodname>unregister_modifier</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically unregister modifier plugin. Pass in the
|
Pass in the template modifier name.
|
||||||
template modifier name.
|
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>unregister_modifier</title>
|
<title>unregister_modifier()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// we don't want template designers to strip tags from elements
|
|
||||||
|
|
||||||
$smarty->unregister_modifier("strip_tags");
|
// we don't want template designers to strip tags from elements
|
||||||
|
$smarty->unregister_modifier('strip_tags');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.modifier">register_modifier()</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.modifiers">Plugin modifiers</link>,
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,19 +2,22 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.object">
|
<refentry id="api.unregister.object">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_object</refname>
|
<refname>unregister_object()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister an object</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_object</methodname>
|
<type>void</type><methodname>unregister_object</methodname>
|
||||||
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
|
||||||
Use this to unregister an object.
|
<para>
|
||||||
</para>
|
See also
|
||||||
<para>See also <link linkend="api.register.object">register_object</link> <link linkend="advanced.features.objects">object section</link></para>
|
<link linkend="api.register.object">register_object()</link>
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features.objects">objects section</link>
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.outputfilter">
|
<refentry id="api.unregister.outputfilter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_outputfilter</refname>
|
<refname>unregister_outputfilter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister an output filter</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_outputfilter</methodname>
|
<type>void</type><methodname>unregister_outputfilter</methodname>
|
||||||
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
||||||
@@ -14,6 +14,14 @@
|
|||||||
<para>
|
<para>
|
||||||
Use this to dynamically unregister an output filter.
|
Use this to dynamically unregister an output filter.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.outputfilter">register_outputfilter()</link>
|
||||||
|
and
|
||||||
|
<link linkend="advanced.features.outputfilters">template
|
||||||
|
output filters</link>.
|
||||||
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,18 +2,24 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.postfilter">
|
<refentry id="api.unregister.postfilter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_postfilter</refname>
|
<refname>unregister_postfilter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister a postfilter</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_postfilter</methodname>
|
<type>void</type><methodname>unregister_postfilter</methodname>
|
||||||
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
|
||||||
Use this to dynamically unregister a postfilter.
|
<para>
|
||||||
</para>
|
See also
|
||||||
|
<link linkend="api.unregister.postfilter">register_postfilter()</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.prefilters.postfilters">template
|
||||||
|
post filters</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,18 +2,23 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.prefilter">
|
<refentry id="api.unregister.prefilter">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_prefilter</refname>
|
<refname>unregister_prefilter()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister a prefilter</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_prefilter</methodname>
|
<type>void</type><methodname>unregister_prefilter</methodname>
|
||||||
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
|
||||||
Use this to dynamically unregister a prefilter.
|
<para>
|
||||||
</para>
|
See also
|
||||||
|
<link linkend="api.register.prefilter">register_prefilter()</link>
|
||||||
|
and
|
||||||
|
<link linkend="plugins.prefilters.postfilters">pre filters</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -2,29 +2,39 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<refentry id="api.unregister.resource">
|
<refentry id="api.unregister.resource">
|
||||||
<refnamediv>
|
<refnamediv>
|
||||||
<refname>unregister_resource</refname>
|
<refname>unregister_resource()</refname>
|
||||||
<refpurpose></refpurpose>
|
<refpurpose>dynamically unregister a resource plugin</refpurpose>
|
||||||
</refnamediv>
|
</refnamediv>
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title />
|
<title>Description</title>
|
||||||
<methodsynopsis>
|
<methodsynopsis>
|
||||||
<type>void</type><methodname>unregister_resource</methodname>
|
<type>void</type><methodname>unregister_resource</methodname>
|
||||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||||
</methodsynopsis>
|
</methodsynopsis>
|
||||||
<para>
|
<para>
|
||||||
Use this to dynamically unregister a resource plugin. Pass in the
|
Pass in the
|
||||||
name of the resource.
|
name of the resource.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>unregister_resource</title>
|
<title>unregister_resource()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
$smarty->unregister_resource("db");
|
|
||||||
|
$smarty->unregister_resource('db');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.resource">register_resource()</link>
|
||||||
|
and
|
||||||
|
<link linkend="template.resources">template resources</link>
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<chapter id="api.variables">
|
<chapter id="api.variables">
|
||||||
<title>Variables</title>
|
<title>Smarty Class Variables</title>
|
||||||
|
|
||||||
&programmers.api-variables.variable-template-dir;
|
&programmers.api-variables.variable-template-dir;
|
||||||
&programmers.api-variables.variable-compile-dir;
|
&programmers.api-variables.variable-compile-dir;
|
||||||
|
@@ -6,11 +6,16 @@
|
|||||||
This is the name of the directory where template caches are
|
This is the name of the directory where template caches are
|
||||||
stored. By default this is "./cache", meaning that it will look
|
stored. By default this is "./cache", meaning that it will look
|
||||||
for the cache directory in the same directory as the executing
|
for the cache directory in the same directory as the executing
|
||||||
php script. You can also use your own
|
php script.
|
||||||
|
<emphasis role="bold">This directory must
|
||||||
|
be writeable by the web server. </emphasis>
|
||||||
|
You can also use your own
|
||||||
<link linkend="section.template.cache.handler.func">
|
<link linkend="section.template.cache.handler.func">
|
||||||
custom cache handler</link>
|
custom cache handler</link>
|
||||||
function to control cache files, which will ignore this
|
function to control cache files, which will ignore this
|
||||||
setting.
|
setting.
|
||||||
|
See also
|
||||||
|
<link linkend="variable.use.sub.dirs">$use_sub_dirs</link>.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
@@ -26,7 +31,18 @@
|
|||||||
the web server document root.
|
the web server document root.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
</sect1>
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="variable.caching">$caching</link>,
|
||||||
|
<link linkend="variable.use.sub.dirs">$use_sub_dirs</link>,
|
||||||
|
<link linkend="variable.cache.lifetime">$cache_lifetime</link>,
|
||||||
|
<link linkend="variable.cache.handler.func">$cache_handler_func</link>,
|
||||||
|
<link linkend="variable.cache.modified.check">$cache_modified_check</link>
|
||||||
|
and
|
||||||
|
<link linkend="caching">Caching section</link>.
|
||||||
|
</para>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -1,15 +1,27 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="variable.cache.modified.check">
|
<sect1 id="variable.cache.modified.check">
|
||||||
<title>$cache_modified_check</title>
|
<title>$cache_modified_check</title>
|
||||||
<para>
|
<para>
|
||||||
If set to true, Smarty will respect the If-Modified-Since
|
If set to true, Smarty will respect the If-Modified-Since
|
||||||
header sent from the client. If the cached file timestamp has
|
header sent from the client. If the cached file timestamp has
|
||||||
not changed since the last visit, then a "304 Not Modified"
|
not changed since the last visit, then a "304 Not Modified"
|
||||||
header will be sent instead of the content. This works only on
|
header will be sent instead of the content. This works only on
|
||||||
cached content without <command>insert</command> tags.
|
cached content without
|
||||||
</para>
|
<link linkend="language.function.insert"><command>{insert}</command></link>
|
||||||
</sect1>
|
tags.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="variable.caching">$caching</link>,
|
||||||
|
<link linkend="variable.cache.lifetime">$cache_lifetime</link>,
|
||||||
|
<link linkend="variable.cache.handler.func">$cache_handler_func</link>,
|
||||||
|
and
|
||||||
|
<link linkend="caching">Caching section</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</sect1>
|
||||||
|
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -5,8 +5,9 @@
|
|||||||
<para>
|
<para>
|
||||||
This tells Smarty whether or not to cache the output of the templates.
|
This tells Smarty whether or not to cache the output of the templates.
|
||||||
By default this is set to 0, or disabled. If your templates generate
|
By default this is set to 0, or disabled. If your templates generate
|
||||||
redundant redundant content, it is advisable to turn on caching. This
|
redundant content, it is advisable to turn on $caching. This
|
||||||
will result in significant performance gains. You can also have multiple
|
will result in significant performance gains. You can also have
|
||||||
|
<link linkend="caching.multiple.caches">multiple</link>
|
||||||
caches for the same template. A value of 1 or 2 enables caching. 1 tells
|
caches for the same template. A value of 1 or 2 enables caching. 1 tells
|
||||||
Smarty to use the current
|
Smarty to use the current
|
||||||
<link linkend="variable.cache.lifetime">$cache_lifetime</link>
|
<link linkend="variable.cache.lifetime">$cache_lifetime</link>
|
||||||
@@ -30,6 +31,17 @@
|
|||||||
is enabled, the cached content will always be
|
is enabled, the cached content will always be
|
||||||
regenerated.
|
regenerated.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="variable.cache.dir">$cache_dir</link>,
|
||||||
|
<link linkend="variable.cache.lifetime">$cache_lifetime</link>,
|
||||||
|
<link linkend="variable.cache.handler.func">$cache_handler_func</link>,
|
||||||
|
<link linkend="variable.cache.modified.check">$cache_modified_check</link>
|
||||||
|
and
|
||||||
|
<link linkend="caching">Caching section</link>.
|
||||||
|
</para>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -7,7 +7,9 @@
|
|||||||
located. By default this is "./templates_c", meaning that it
|
located. By default this is "./templates_c", meaning that it
|
||||||
will look for the compile directory in the same directory as
|
will look for the compile directory in the same directory as
|
||||||
the executing php script. <emphasis role="bold">This directory must
|
the executing php script. <emphasis role="bold">This directory must
|
||||||
be writeable by the web server.</emphasis>
|
be writeable by the web server. </emphasis> See also
|
||||||
|
<link linkend="variable.use.sub.dirs">$use_sub_dirs</link>.
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
@@ -24,7 +26,9 @@
|
|||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="variable.compile.id">$compile_id</link>.
|
See also <link linkend="variable.compile.id">$compile_id</link>
|
||||||
|
and
|
||||||
|
<link linkend="variable.use.sub.dirs">$use_sub_dirs</link>.
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -21,19 +21,23 @@
|
|||||||
<link linkend="plugins.prefilters.postfilters">prefilter</link>
|
<link linkend="plugins.prefilters.postfilters">prefilter</link>
|
||||||
that localizes your templates
|
that localizes your templates
|
||||||
(that is: translates language dependend parts) at compile time, then
|
(that is: translates language dependend parts) at compile time, then
|
||||||
you should use the current language as compile_id and you will get a
|
you should use the current language as $compile_id and you will get a
|
||||||
set of compiled templates for each language you use.
|
set of compiled templates for each language you use.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Another example would be to use the same compile directory across
|
Another example would be to use the same compile directory across
|
||||||
multiple domains / multiple vhosts. eg:
|
multiple domains / multiple virtual hosts.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>compile_id</title>
|
<title>$compile_id</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
$smarty->compile_id = $_SERVER['SERVER_NAME'];
|
<?php
|
||||||
$smarty->compile_dir = 'path/to/shared_compile_dir';
|
|
||||||
|
$smarty->compile_id = $_SERVER['SERVER_NAME'];
|
||||||
|
$smarty->compile_dir = 'path/to/shared_compile_dir';
|
||||||
|
|
||||||
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
@@ -2,23 +2,41 @@
|
|||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<sect1 id="variable.use.sub.dirs">
|
<sect1 id="variable.use.sub.dirs">
|
||||||
<title>$use_sub_dirs</title>
|
<title>$use_sub_dirs</title>
|
||||||
<para>
|
<para>
|
||||||
Set this to false if your PHP environment does not allow the creation of
|
Smarty will create subdirectories under the
|
||||||
sub directories by Smarty. Sub directories are more efficient, so use them
|
<link linkend="variable.compile.dir">templates_c</link> and
|
||||||
if you can.
|
<link linkend="variable.cache.dir">cache</link>
|
||||||
</para>
|
directories if $use_sub_dirs is set to true.
|
||||||
|
In an environment where there are potentially tens of thousands of files created,
|
||||||
|
this may help the filesystem speed.
|
||||||
|
On the other hand, some environments do not allow PHP processes to
|
||||||
|
create directories, so this must be disabled. The default is false (disabled).
|
||||||
|
Sub directories are more efficient, so use them if you can.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Theoretically you get much better perfomance on a filesystem with 10
|
||||||
|
directories each having 100 files, than with 1 directory having 1000
|
||||||
|
files. This was certainly the case with Solaris 7 (UFS)... with newer
|
||||||
|
filesystems such as ext3 and especially reiserfs, the difference is almost
|
||||||
|
nothing.
|
||||||
|
</para>
|
||||||
|
<note>
|
||||||
|
<title>Technical Note</title>
|
||||||
|
<para>
|
||||||
|
$use_sub_dirs=true doesn't work with safe_mode=On, that's why it's
|
||||||
|
switchable and why it's off by default.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Note</title>
|
||||||
<para>
|
<para>
|
||||||
Since Smarty-2.6.2 <varname>$use_sub_dirs</varname> defaults to false.
|
Since Smarty-2.6.2 <varname>$use_sub_dirs</varname> defaults to false.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="variable.template.dir">$template_dir</link>,
|
See also
|
||||||
<link linkend="variable.compile.dir">$compile_dir</link>,
|
<link linkend="variable.compile.dir">$compile_dir</link>,
|
||||||
<link linkend="variable.config.dir">$config_dir</link>,
|
and
|
||||||
<link linkend="variable.plugins.dir">$plugins_dir</link>
|
|
||||||
and
|
|
||||||
<link linkend="variable.cache.dir">$cache_dir</link>.
|
<link linkend="variable.cache.dir">$cache_dir</link>.
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
@@ -42,3 +60,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||||||
vim: et tw=78 syn=sgml
|
vim: et tw=78 syn=sgml
|
||||||
vi: ts=1 sw=1
|
vi: ts=1 sw=1
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<sect1 id="caching.setting.up">
|
<sect1 id="caching.setting.up">
|
||||||
<title>Setting Up Caching</title>
|
<title>Setting Up Caching</title>
|
||||||
<para>
|
<para>
|
||||||
The first thing to do is enable caching. This is done by setting <link
|
The first thing to do is enable caching by setting <link
|
||||||
linkend="variable.caching">$caching</link> = true (or 1.)
|
linkend="variable.caching">$caching</link> = true (or 1.)
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
@@ -49,7 +49,7 @@ $smarty->display('index.tpl');
|
|||||||
linkend="variable.cache.lifetime">$cache_lifetime</link> for details.
|
linkend="variable.cache.lifetime">$cache_lifetime</link> for details.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>setting cache_lifetime per cache</title>
|
<title>setting $cache_lifetime per cache</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
@@ -1,39 +1,51 @@
|
|||||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
<!-- $Revision$ -->
|
<!-- $Revision$ -->
|
||||||
<chapter id="smarty.constants">
|
<chapter id="smarty.constants">
|
||||||
<title>Constants</title>
|
<title>Constants</title>
|
||||||
|
|
||||||
<sect1 id="constant.smarty.dir">
|
<sect1 id="constant.smarty.dir">
|
||||||
<title>SMARTY_DIR</title>
|
<title>SMARTY_DIR</title>
|
||||||
<para>
|
<para>
|
||||||
This should be the full system path to the location of the Smarty
|
This should be the full system path to the location of the Smarty
|
||||||
class files. If this is not defined, then Smarty will attempt to
|
class files. If this is not defined, then Smarty will attempt to
|
||||||
determine the appropriate value automatically. If defined, the path
|
determine the appropriate value automatically. If defined, the path
|
||||||
must end with a slash.
|
<emphasis role="bold">must end with a slash</emphasis>.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>SMARTY_DIR</title>
|
<title>SMARTY_DIR</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// set path to Smarty directory
|
// set path to Smarty directory *nix style
|
||||||
define("SMARTY_DIR","/usr/local/lib/php/Smarty/");
|
define('SMARTY_DIR','/usr/local/lib/php/Smarty/libs/');
|
||||||
|
|
||||||
require_once(SMARTY_DIR."Smarty.class.php");
|
// path to Smarty windows style
|
||||||
|
define('SMARTY_DIR','c:/webroot/libs/Smarty/libs/');
|
||||||
|
|
||||||
|
// hack that works on both under DOCUMENT _ROOT (not recommended)
|
||||||
|
define('SMARTY-DIR',str_replace("\\","/",getcwd()).'/includes/Smarty/libs/');
|
||||||
|
|
||||||
|
// include the smarty class Note 'S' is upper case
|
||||||
|
require_once(SMARTY_DIR.'Smarty.class.php');
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="language.variables.smarty.const">$smarty.const</link>
|
<link linkend="language.variables.smarty.const">$smarty.const</link>
|
||||||
</para>
|
and
|
||||||
</sect1>
|
<link
|
||||||
<sect1 id="constant.smarty.core.dir">
|
linkend="variable.php.handling">$php_handling constants</link>
|
||||||
|
</para>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
<sect1 id="constant.smarty.core.dir">
|
||||||
<title>SMARTY_CORE_DIR</title>
|
<title>SMARTY_CORE_DIR</title>
|
||||||
<para>
|
<para>
|
||||||
This should be the full system path to the location of the Smarty core
|
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/
|
files. If not defined, Smarty will default this constant to the
|
||||||
|
<emphasis>libs/</emphasis>
|
||||||
sub-directory below
|
sub-directory below
|
||||||
<link linkend="constant.smarty.dir">SMARTY_DIR</link>.
|
<link linkend="constant.smarty.dir">SMARTY_DIR</link>.
|
||||||
If defined, the path must end with a slash.
|
If defined, the path must end with a slash.
|
||||||
@@ -44,9 +56,10 @@ require_once(SMARTY_DIR."Smarty.class.php");
|
|||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
// load core.get_microtime.php
|
|
||||||
|
|
||||||
require_once(SMARTY_CORE_DIR."core.get_microtime.php");
|
// load core.get_microtime.php
|
||||||
|
require_once(SMARTY_CORE_DIR.'core.get_microtime.php');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
Reference in New Issue
Block a user