mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
more examples, WS and linking from Peter. Thanks :)
This commit is contained in:
@@ -12,7 +12,9 @@
|
|||||||
table backgrounds work properly. Many would use an
|
table backgrounds work properly. Many would use an
|
||||||
<link linkend="language.function.if">{if}</link> statement to
|
<link linkend="language.function.if">{if}</link> statement to
|
||||||
handle this, but there is a shorthand way with Smarty, using the
|
handle this, but there is a shorthand way with Smarty, using the
|
||||||
<emphasis>default</emphasis> variable modifier.
|
<link
|
||||||
|
linkend="language.modifier.default"><emphasis>default</emphasis></link>
|
||||||
|
variable modifier.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Printing &nbsp; when a variable is empty</title>
|
<title>Printing &nbsp; when a variable is empty</title>
|
||||||
@@ -69,53 +71,71 @@
|
|||||||
<title>Passing variable title to header template</title>
|
<title>Passing variable title to header template</title>
|
||||||
<para>
|
<para>
|
||||||
When the majority of your templates use the same headers and footers, it
|
When the majority of your templates use the same headers and footers, it
|
||||||
is common to split those out into their own templates and include them.
|
is common to split those out into their own templates and
|
||||||
|
<link linkend="language.function.include">{include}</link> them.
|
||||||
But what if the header needs to have a different title, depending on
|
But what if the header needs to have a different title, depending on
|
||||||
what page you are coming from? You can pass the title to the header when
|
what page you are coming from? You can pass the title to the header when
|
||||||
it is included.
|
it is included.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>Passing the title variable to the header template</title>
|
<title>Passing the title variable to the header template</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<filename>mainpage.tpl</filename>
|
||||||
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
mainpage.tpl
|
|
||||||
------------
|
|
||||||
|
|
||||||
{include file="header.tpl" title="Main Page"}
|
{include file="header.tpl" title="Main Page"}
|
||||||
{* template body goes here *}
|
{* template body goes here *}
|
||||||
{include file="footer.tpl"}
|
{include file="footer.tpl"}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
archives.tpl
|
<filename>archives.tpl</filename>
|
||||||
------------
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
|
||||||
{config_load file="archive_page.conf"}
|
{config_load file="archive_page.conf"}
|
||||||
{include file="header.tpl" title=#archivePageTitle#}
|
{include file="header.tpl" title=#archivePageTitle#}
|
||||||
{* template body goes here *}
|
{* template body goes here *}
|
||||||
{include file="footer.tpl"}
|
{include file="footer.tpl"}
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<filename>header.tpl</filename>
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>{$title|default:"BC News"}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
header.tpl
|
<para>
|
||||||
----------
|
<filename>footer.tpl</filename>
|
||||||
<HTML>
|
</para>
|
||||||
<HEAD>
|
<programlisting>
|
||||||
<TITLE>{$title|default:"BC News"}</TITLE>
|
<![CDATA[
|
||||||
</HEAD>
|
</body>
|
||||||
<BODY>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
footer.tpl
|
|
||||||
----------
|
|
||||||
</BODY>
|
|
||||||
</HTML>
|
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
When the main page is drawn, the title of "Main Page" is passed to the
|
When the main page is drawn, the title of "Main Page" is passed to the
|
||||||
header.tpl, and will subsequently be used as the title. When the
|
<filename>header.tpl</filename>, and will subsequently be used as the title. When the
|
||||||
archives page is drawn, the title will be "Archives". Notice in the
|
archives page is drawn, the title will be "Archives". Notice in the
|
||||||
archive example, we are using a variable from the archives_page.conf
|
archive example, we are using a variable from the
|
||||||
|
<filename>archives_page.conf</filename>
|
||||||
file instead of a hard coded variable. Also notice that "BC News" is
|
file instead of a hard coded variable. Also notice that "BC News" is
|
||||||
printed if the $title variable is not set, using the
|
printed if the $title variable is not set, using the
|
||||||
<link linkend="language.modifier.default">default</link>
|
<link linkend="language.modifier.default">default</link>
|
||||||
@@ -191,7 +211,7 @@ Jan 4, 2001
|
|||||||
|
|
||||||
$startDate = makeTimeStamp($startDate_Year, $startDate_Month, $startDate_Day);
|
$startDate = makeTimeStamp($startDate_Year, $startDate_Month, $startDate_Day);
|
||||||
|
|
||||||
function makeTimeStamp($year="", $month="", $day="")
|
function makeTimeStamp($year='', $month='', $day='')
|
||||||
{
|
{
|
||||||
if(empty($year)) {
|
if(empty($year)) {
|
||||||
$year = strftime("%Y");
|
$year = strftime("%Y");
|
||||||
@@ -222,15 +242,20 @@ function makeTimeStamp($year="", $month="", $day="")
|
|||||||
<sect1 id="tips.wap">
|
<sect1 id="tips.wap">
|
||||||
<title>WAP/WML</title>
|
<title>WAP/WML</title>
|
||||||
<para>
|
<para>
|
||||||
WAP/WML templates require a php Content-Type header to be passed along
|
WAP/WML templates require a php
|
||||||
|
<ulink url="&url.php-manual;header">Content-Type header</ulink>
|
||||||
|
to be passed along
|
||||||
with the template. The easist way to do this would be to write a custom
|
with the template. The easist way to do this would be to write a custom
|
||||||
function that prints the header. If you are using caching, that won't
|
function that prints the header. If you are using
|
||||||
work so we'll do it using the insert tag (remember insert tags are not
|
<link linkend="caching">caching</link>, that won't
|
||||||
cached!) Be sure that there is nothing output to the browser before the
|
work so we'll do it using the
|
||||||
|
<link linkend="language.function.insert">{insert}</link>
|
||||||
|
tag; remember {insert} tags are not
|
||||||
|
cached! Be sure that there is nothing output to the browser before the
|
||||||
template, or else the header may fail.
|
template, or else the header may fail.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>using insert to write a WML Content-Type header</title>
|
<title>using {insert} to write a WML Content-Type header</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
@@ -289,8 +314,8 @@ function insert_header($params)
|
|||||||
Traditionally, programming templates into your applications goes as
|
Traditionally, programming templates into your applications goes as
|
||||||
follows: First, you accumulate your variables within your PHP
|
follows: First, you accumulate your variables within your PHP
|
||||||
application, (maybe with database queries.) Then, you instantiate your
|
application, (maybe with database queries.) Then, you instantiate your
|
||||||
Smarty object, <link linkend="api.assign">assign</link> the variables and
|
Smarty object, <link linkend="api.assign">assign()</link> the variables and
|
||||||
<link linkend="api.display">display</link> the template. So lets
|
<link linkend="api.display">display()</link> the template. So lets
|
||||||
say for example we have a stock ticker on our template. We would
|
say for example we have a stock ticker on our template. We would
|
||||||
collect the stock data in our application, then assign these variables
|
collect the stock data in our application, then assign these variables
|
||||||
in the template and display it. Now wouldn't it be nice if you could
|
in the template and display it. Now wouldn't it be nice if you could
|
||||||
@@ -303,12 +328,15 @@ function insert_header($params)
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>componentized template</title>
|
<title>componentized template</title>
|
||||||
|
<para>
|
||||||
|
<filename>function.load_ticker.php</filename> -
|
||||||
|
drop file in
|
||||||
|
<link linkend="variable.plugins.dir">$plugins directory</link>
|
||||||
|
</para>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// drop file "function.load_ticker.php" in plugin directory
|
|
||||||
|
|
||||||
// setup our function for fetching stock data
|
// setup our function for fetching stock data
|
||||||
function fetch_ticker($symbol)
|
function fetch_ticker($symbol)
|
||||||
{
|
{
|
||||||
@@ -328,10 +356,11 @@ function smarty_function_load_ticker($params, &$smarty)
|
|||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
<filename>index.tpl</filename>
|
||||||
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
{* in index.tpl *}
|
|
||||||
|
|
||||||
{load_ticker symbol="YHOO" assign="ticker"}
|
{load_ticker symbol="YHOO" assign="ticker"}
|
||||||
|
|
||||||
Stock Name: {$ticker.name} Stock Price: {$ticker.price}
|
Stock Name: {$ticker.name} Stock Price: {$ticker.price}
|
||||||
@@ -352,7 +381,8 @@ Stock Name: {$ticker.name} Stock Price: {$ticker.price}
|
|||||||
lists? One way spammers collect E-mail addresses is from web pages. To
|
lists? One way spammers collect E-mail addresses is from web pages. To
|
||||||
help combat this problem, you can make your E-mail address show up in
|
help combat this problem, you can make your E-mail address show up in
|
||||||
scrambled javascript in the HTML source, yet it it will look and work
|
scrambled javascript in the HTML source, yet it it will look and work
|
||||||
correctly in the browser. This is done with the mailto plugin.
|
correctly in the browser. This is done with the
|
||||||
|
<link linkend="language.function.mailto">{mailto}</link> plugin.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>Example of Obfuscating an E-mail Address</title>
|
<title>Example of Obfuscating an E-mail Address</title>
|
||||||
@@ -369,11 +399,13 @@ Send inquiries to
|
|||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
This method isn't 100% foolproof. A spammer could conceivably program his
|
This method isn't 100% foolproof. A spammer could conceivably program his
|
||||||
e-mail collector to decode these values, but not likely.
|
e-mail collector to decode these values, but not likely....hopefully.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="language.modifier.escape">escape</link>.
|
See also <link linkend="language.modifier.escape">escape</link>
|
||||||
|
and
|
||||||
|
<link linkend="language.function.mailto">{mailto}</link>.
|
||||||
</para>
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
@@ -55,6 +55,110 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
|
|||||||
go to the line number to figure out where the corresponding error is in
|
go to the line number to figure out where the corresponding error is in
|
||||||
the template.
|
the template.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<example>
|
||||||
|
<title>Other common errors</title>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
|
Warning: Smarty error: unable to read resource: "index.tpl" in...
|
||||||
|
or
|
||||||
|
Warning: Smarty error: unable to read resource: "site.conf" in...
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
|
<para>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <link linkend="variable.template.dir">$template_dir</link>
|
||||||
|
is incorrect, doesn't exist or
|
||||||
|
the file <filename>index.tpl</filename> is not in the
|
||||||
|
<filename class="directory">templates/</filename> directory
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A <link linkend="language.function.config.load">{config_load}</link>
|
||||||
|
function is within a template (or
|
||||||
|
<link linkend="api.config.load">config_load()</link>
|
||||||
|
has been called) and either
|
||||||
|
<link linkend="variable.config.dir">$config_dir</link>
|
||||||
|
is incorrent , does not exist or
|
||||||
|
<filename>site.conf</filename> is not in the directory.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</listitem><listitem>
|
||||||
|
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
|
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
|
||||||
|
or is not a directory...
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
|
<para>
|
||||||
|
Either the
|
||||||
|
<link linkend="variable.compile.dir">$compile_dir</link>
|
||||||
|
is incorrectly set, the directory does not exist,
|
||||||
|
or <filename>templates_c</filename> is a
|
||||||
|
file and not a directory.
|
||||||
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
|
Fatal error: Smarty error: unable to write to $compile_dir '....
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
|
<para>
|
||||||
|
The <link linkend="variable.compile.dir">$compile_dir</link>
|
||||||
|
is not writable by the web server. See the bottom of the
|
||||||
|
<link linkend="installing.smarty.basic">installing smarty</link> page
|
||||||
|
for permissions.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</listitem><listitem>
|
||||||
|
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
|
Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
|
||||||
|
or is not a directory. in /..
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
|
<para>
|
||||||
|
This means that
|
||||||
|
<link linkend="variable.caching">$caching</link> is enabled and either;
|
||||||
|
the
|
||||||
|
<link linkend="variable.cache.dir">$cache_dir</link>
|
||||||
|
is incorrectly set, the directory does not exist,
|
||||||
|
or <filename>cache</filename> is a
|
||||||
|
file and not a directory.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
</listitem><listitem>
|
||||||
|
|
||||||
|
<screen>
|
||||||
|
<![CDATA[
|
||||||
|
Fatal error: Smarty error: unable to write to $cache_dir '/...
|
||||||
|
]]>
|
||||||
|
</screen>
|
||||||
|
<para>
|
||||||
|
This means that
|
||||||
|
<link linkend="variable.caching">$caching</link> is enabled and the
|
||||||
|
<link linkend="variable.cache.dir">$cache_dir</link>
|
||||||
|
is not writable by the web server. See the bottom of the
|
||||||
|
<link linkend="installing.smarty.basic">installing smarty</link> page
|
||||||
|
for permissions.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="chapter.debugging.console">debugging</link>,
|
<link linkend="chapter.debugging.console">debugging</link>,
|
||||||
@@ -84,3 +188,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
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@@ -44,9 +44,9 @@
|
|||||||
or any string made up of month day year, parsable by
|
or any string made up of month day year, parsable by
|
||||||
<ulink url="&url.php-manual;strtotime">strtotime()</ulink>.
|
<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
|
||||||
and a second parameter is passed, that will be used as the date to
|
<command>date_format</command> is empty and a second parameter is passed,
|
||||||
format.
|
that will be used as the date to format.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>date_format</title>
|
<title>date_format</title>
|
||||||
@@ -60,7 +60,7 @@ $smarty->assign('yesterday', strtotime('-1 day'));
|
|||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
Where template is:
|
Where template is (uses <link linkend="language.variables.smarty.now">$smarty.now</link>):
|
||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
<sect1 id="language.variables.smarty">
|
<sect1 id="language.variables.smarty">
|
||||||
<title>{$smarty} reserved variable</title>
|
<title>{$smarty} reserved variable</title>
|
||||||
<para>
|
<para>
|
||||||
The reserved {$smarty} variable can be used to access several
|
The PHP 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>
|
||||||
|
|
||||||
@@ -12,7 +12,10 @@
|
|||||||
<para>
|
<para>
|
||||||
The <ulink url="&url.php-manual;reserved.variables">request variables
|
The <ulink url="&url.php-manual;reserved.variables">request variables
|
||||||
</ulink> such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION
|
</ulink> such as $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV and $_SESSION
|
||||||
can be accessed as demonstrated in the examples below:
|
(see <link linkend="variable.request.vars.order">$request_vars_order</link>
|
||||||
|
and <link
|
||||||
|
linkend="variable.request.use.auto.globals">$request_use_auto_globals</link>
|
||||||
|
) can be accessed as demonstrated in the examples below:
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>displaying request variables</title>
|
<title>displaying request variables</title>
|
||||||
|
@@ -25,10 +25,10 @@
|
|||||||
</para>
|
</para>
|
||||||
¶meter.compileid;
|
¶meter.compileid;
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<example>
|
<example>
|
||||||
<title>fetch()</title>
|
<title>fetch()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
include('Smarty.class.php');
|
include('Smarty.class.php');
|
||||||
@@ -61,17 +61,17 @@ $output = $smarty->fetch('index.tpl');
|
|||||||
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>
|
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<title>Using fetch() to send an email</title>
|
||||||
|
<para>
|
||||||
|
The email_body.tpl template
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
Dear {$contact.name},
|
Dear {$contact.name},
|
||||||
|
|
||||||
@@ -85,23 +85,28 @@ http://{$smarty.server.SERVER_NAME}/index.php?page=login
|
|||||||
List master
|
List master
|
||||||
Some user group
|
Some user group
|
||||||
|
|
||||||
{include file="email_disclaimer.txt"}
|
{include file="email_disclaimer.tpl"}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
The email_disclaimer.txt template
|
The email_disclaimer.tpl template which uses the
|
||||||
|
<link linkend="language.function.textformat">{textformat}</link> modifier.
|
||||||
</para>
|
</para>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
This e-mail is intended for the addressee shown. It contains information
|
{textformat wrap=40}
|
||||||
....... etc .......
|
Unless you are named "{$contact.name}", you may read only the "odd numbered
|
||||||
|
words" (every other word beginning with the first) of the message above. If you have
|
||||||
|
violated that, then you hereby owe the sender 10 GBP for each even
|
||||||
|
numbered word you have read
|
||||||
|
{/textformat}
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
and the php script using the PHP
|
and the php script using the PHP
|
||||||
<ulink url="&url.php-manual;function.mail">mail()</ulink> function
|
<ulink url="&url.php-manual;function.mail">mail()</ulink> function
|
||||||
</para>
|
</para>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@@ -110,14 +115,13 @@ $query = 'select name, email, login_id from contacts where contact_id='.$contac
|
|||||||
$contact = $db->getRow($sql);
|
$contact = $db->getRow($sql);
|
||||||
$smarty->assign('contact', $contact);
|
$smarty->assign('contact', $contact);
|
||||||
|
|
||||||
mail($contact['email'], 'Subject', $smarty->fetch('email_body.txt'));
|
mail($contact['email'], 'Subject', $smarty->fetch('email_body.tpl'));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
]]>
|
]]>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
@@ -150,5 +154,3 @@ 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
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
@@ -41,7 +41,8 @@ $smarty->load_filter('output', 'compress');
|
|||||||
See also
|
See also
|
||||||
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||||
<link linkend="api.register.outputfilter">register_outputfilter()</link>
|
<link linkend="api.register.outputfilter">register_outputfilter()</link>,
|
||||||
|
<link linkend="variable.autoload.filters">$autoload_filters</link>
|
||||||
and
|
and
|
||||||
<link linkend="advanced.features">Advanced features</link>.
|
<link linkend="advanced.features">Advanced features</link>.
|
||||||
</para>
|
</para>
|
||||||
|
@@ -21,24 +21,30 @@
|
|||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>impl</parameter> can be either:
|
The php-function callback <parameter>impl</parameter> can be either:
|
||||||
</para>
|
</para>
|
||||||
|
<orderedlist numeration="loweralpha">
|
||||||
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
(a) a string containing the function name
|
a string containing the function name
|
||||||
</para>
|
</para>
|
||||||
<para>(b) an array of the form <literal>array(&$object, $method)</literal> with
|
</listitem><listitem>
|
||||||
|
<para>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
|
containing the mehod-name
|
||||||
</para>
|
</para>
|
||||||
<para>(c) an array of the form
|
</listitem><listitem>
|
||||||
|
<para>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>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
<para>
|
<para>
|
||||||
<parameter>cacheable</parameter> can be omitted in
|
<parameter>cacheable</parameter> can be omitted in
|
||||||
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 use it properly.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@@ -22,22 +22,29 @@
|
|||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>impl</parameter> can be either
|
The php-function callback <parameter>impl</parameter> can be either
|
||||||
</para>
|
</para>
|
||||||
|
<orderedlist numeration="loweralpha">
|
||||||
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
(a) a string containing the function name
|
a string containing the function name
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(b) an array of the form
|
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
|
containing the mehod-name
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(c) an array of the form <literal>array(&$class, $method)</literal>
|
an array of the form <literal>array(&$class, $method)</literal>
|
||||||
with <literal>$class</literal> being a classname and
|
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>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<parameter>cacheable</parameter> and <parameter>cache_attrs</parameter> can be
|
<parameter>cacheable</parameter> and <parameter>cache_attrs</parameter> can be
|
||||||
omitted in most cases. See <link
|
omitted in most cases. See <link
|
||||||
|
@@ -18,17 +18,30 @@
|
|||||||
implements it.
|
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
|
<orderedlist numeration="loweralpha">
|
||||||
<literal>&$object</literal> being a reference to an
|
<listitem>
|
||||||
|
<para>a string containing the function name
|
||||||
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
|
<para>an array of the form <literal>array(&$object,
|
||||||
|
$method)</literal> with <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>
|
||||||
|
</listitem><listitem>
|
||||||
|
<para>
|
||||||
|
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>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>register_modifier()</title>
|
<title>register_modifier()</title>
|
||||||
<programlisting role="php">
|
<programlisting role="php">
|
||||||
@@ -59,7 +72,7 @@ $smarty->register_modifier('sslash', 'stripslashes');
|
|||||||
<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">Creating Plugin modifiers</link>,
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
@@ -22,7 +22,10 @@
|
|||||||
for examples.
|
for examples.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
See also <link linkend="api.unregister.object">unregister_object()</link>.
|
See also
|
||||||
|
<link linkend="api.get.registered.object">get_registered_object()</link>,
|
||||||
|
and
|
||||||
|
<link linkend="api.unregister.object">unregister_object()</link>.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
@@ -23,30 +23,36 @@
|
|||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>function</parameter> can be either
|
The php-function callback <parameter>function</parameter> can be either
|
||||||
</para>
|
</para>
|
||||||
|
<orderedlist numeration="loweralpha">
|
||||||
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
(a) a string
|
a string containing the function name
|
||||||
containing the function name
|
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(b) an array of the form
|
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
|
containing the mehod-name
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(c) an array of the form
|
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>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="api.unregister.outputfilter">unregister_outputfilter()</link>,
|
<link linkend="api.unregister.outputfilter">unregister_outputfilter()</link>,
|
||||||
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||||
<link linkend="api.load.filter">load_filter()</link>,
|
<link linkend="api.load.filter">load_filter()</link>,
|
||||||
|
<link linkend="variable.autoload.filters">$autoload_filters</link>
|
||||||
and
|
and
|
||||||
<link linkend="advanced.features.outputfilters">template
|
<link linkend="advanced.features.outputfilters">template
|
||||||
output filters</link>.
|
output filters</link>.
|
||||||
|
@@ -21,30 +21,36 @@
|
|||||||
<para>
|
<para>
|
||||||
The php-function callback <parameter>function</parameter> can be either
|
The php-function callback <parameter>function</parameter> can be either
|
||||||
</para>
|
</para>
|
||||||
|
<orderedlist numeration="loweralpha">
|
||||||
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
(a) a string containing the function name
|
a string containing the function name
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(b) an array of the form
|
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
|
containing the mehod-name
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(c) an array of the form
|
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>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="api.unregister.postfilter">unregister_postfilter()</link>,
|
<link linkend="api.unregister.postfilter">unregister_postfilter()</link>,
|
||||||
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
<link linkend="api.register.outputfilter">register_ouputfilter()</link>,
|
<link linkend="api.register.outputfilter">register_ouputfilter()</link>,
|
||||||
<link linkend="api.load.filter">load_filter()</link>,
|
<link linkend="api.load.filter">load_filter()</link>,
|
||||||
|
<link linkend="variable.autoload.filters">$autoload_filters</link>
|
||||||
and
|
and
|
||||||
<link linkend="advanced.features.outputfilters">template
|
<link linkend="advanced.features.outputfilters">template
|
||||||
output filters</link>.
|
output filters</link>.
|
||||||
|
@@ -18,37 +18,46 @@
|
|||||||
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
|
The php-function callback <parameter>function</parameter> can be either
|
||||||
</para>
|
</para>
|
||||||
|
<orderedlist numeration="loweralpha">
|
||||||
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
(a) a string
|
a string containing the function name
|
||||||
containing the function name
|
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(b) an array of the form
|
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
|
containing the mehod-name
|
||||||
</para>
|
</para>
|
||||||
|
</listitem><listitem>
|
||||||
<para>
|
<para>
|
||||||
(c) an array of the form
|
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>
|
||||||
|
</listitem>
|
||||||
|
</orderedlist>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="api.unregister.prefilter">unregister_prefilter()</link>,
|
<link linkend="api.unregister.prefilter">unregister_prefilter()</link>,
|
||||||
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||||
<link linkend="api.register.outputfilter">register_ouputfilter()</link>,
|
<link linkend="api.register.outputfilter">register_ouputfilter()</link>,
|
||||||
<link linkend="api.load.filter">load_filter()</link>,
|
<link linkend="api.load.filter">load_filter()</link>,
|
||||||
|
<link linkend="variable.autoload.filters">$autoload_filters</link>
|
||||||
and
|
and
|
||||||
<link linkend="advanced.features.outputfilters">template
|
<link linkend="advanced.features.outputfilters">template
|
||||||
output filters</link>.
|
output filters</link>.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -15,6 +15,55 @@
|
|||||||
It can accept either a path to the template on the filesystem or a
|
It can accept either a path to the template on the filesystem or a
|
||||||
resource string specifying the template.
|
resource string specifying the template.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<example>
|
||||||
|
<title>template_exists()</title>
|
||||||
|
<para>
|
||||||
|
This example uses $_GET['page'] to include a content template. If
|
||||||
|
the template doesnt exist then an error page is displayed instead.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The <filename>page_container.tpl</filename>
|
||||||
|
</para>
|
||||||
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<html>
|
||||||
|
<head><title>{$title}</title></head>
|
||||||
|
<body>
|
||||||
|
{include file='page_top.tpl'}
|
||||||
|
|
||||||
|
{* include middle content page *}
|
||||||
|
{include file=$page_mid}
|
||||||
|
|
||||||
|
{include file='page_footer.tpl'}
|
||||||
|
</body>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
and the php script
|
||||||
|
</para>
|
||||||
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// set the filename eg index.inc.tpl
|
||||||
|
$template_name = $_GET['page'].'inc.tpl';
|
||||||
|
|
||||||
|
if( !smarty->template_exists($template_name) ){
|
||||||
|
$filename= 'page_not_found.inc.tpl';
|
||||||
|
}
|
||||||
|
$smarty->assign('page_mid', $template_name);
|
||||||
|
|
||||||
|
$smarty->display('page_container.tpl');
|
||||||
|
|
||||||
|
?>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
See also
|
See also
|
||||||
<link linkend="api.display">display()</link>,
|
<link linkend="api.display">display()</link>,
|
||||||
|
@@ -19,6 +19,15 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
|
|||||||
</programlisting>
|
</programlisting>
|
||||||
</informalexample>
|
</informalexample>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
See also
|
||||||
|
<link linkend="api.register.outputfilter">register_outputfilter()</link>,
|
||||||
|
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||||
|
<link linkend="api.register.postfilter">register_postfilter()</link>
|
||||||
|
and
|
||||||
|
<link linkend="api.load.filter">load_filter()</link>
|
||||||
|
</para>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
|
@@ -4,11 +4,13 @@
|
|||||||
<title>$cache_dir</title>
|
<title>$cache_dir</title>
|
||||||
<para>
|
<para>
|
||||||
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
|
||||||
for the cache directory in the same directory as the executing
|
<filename class="directory">"./cache"</filename>, meaning that
|
||||||
php script.
|
Smarty will look for the cache directory in the same directory
|
||||||
|
as the executing php script.
|
||||||
<emphasis role="bold">This directory must
|
<emphasis role="bold">This directory must
|
||||||
be writeable by the web server. </emphasis>
|
be writeable by the web server</emphasis>
|
||||||
|
(<link linkend="installing.smarty.basic">see install</link>).
|
||||||
You can also use your own
|
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>
|
||||||
@@ -64,3 +66,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,8 @@
|
|||||||
<sect1 id="variable.caching">
|
<sect1 id="variable.caching">
|
||||||
<title>$caching</title>
|
<title>$caching</title>
|
||||||
<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
|
||||||
|
to the <link linkend="variable.cache.dir">$cache_dir</link>.
|
||||||
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 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
|
will result in significant performance gains. You can also have
|
||||||
|
@@ -4,10 +4,14 @@
|
|||||||
<title>$compile_dir</title>
|
<title>$compile_dir</title>
|
||||||
<para>
|
<para>
|
||||||
This is the name of the directory where compiled templates are
|
This is the name of the directory where compiled templates are
|
||||||
located. By default this is "./templates_c", meaning that it
|
located. By default this is
|
||||||
|
<filename class="directory">"./templates_c"</filename>
|
||||||
|
, 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> See also
|
be writeable by the web server</emphasis>
|
||||||
|
(<link linkend="installing.smarty.basic">see install</link>).
|
||||||
|
Also
|
||||||
<link linkend="variable.use.sub.dirs">$use_sub_dirs</link>.
|
<link linkend="variable.use.sub.dirs">$use_sub_dirs</link>.
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
@@ -6,9 +6,10 @@
|
|||||||
This is the directory used to store
|
This is the directory used to store
|
||||||
<link linkend="config.files">config files</link>
|
<link linkend="config.files">config files</link>
|
||||||
used in the
|
used in the
|
||||||
templates. Default is "./configs", meaning that it will look
|
templates. Default is
|
||||||
for the configs directory in the same directory as the
|
<filename class="directory">"./configs"</filename>, meaning that
|
||||||
executing php script.
|
Smarty will look for the configs directory in the same directory
|
||||||
|
as the executing php script.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
|
@@ -4,7 +4,8 @@
|
|||||||
<title>$debug_tpl</title>
|
<title>$debug_tpl</title>
|
||||||
<para>
|
<para>
|
||||||
This is the name of the template file used for the debugging console. By
|
This is the name of the template file used for the debugging console. By
|
||||||
default, it is named debug.tpl and is located in the <link
|
default, it is named <filename>debug.tpl</filename> and is
|
||||||
|
located in the <link
|
||||||
linkend="constant.smarty.dir">SMARTY_DIR</link>.
|
linkend="constant.smarty.dir">SMARTY_DIR</link>.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
|
@@ -21,8 +21,8 @@
|
|||||||
<note>
|
<note>
|
||||||
<para>
|
<para>
|
||||||
Embedding PHP code into templates is highly discouraged.
|
Embedding PHP code into templates is highly discouraged.
|
||||||
Use <link linkend="language.custom.functions">custom functions</link> or
|
Use <link linkend="plugins.functions">custom functions</link> or
|
||||||
<link linkend="language.modifiers">modifiers</link> instead.
|
<link linkend="plugins.modifiers">modifiers</link> instead.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
@@ -4,7 +4,8 @@
|
|||||||
<title>$plugins_dir</title>
|
<title>$plugins_dir</title>
|
||||||
<para>
|
<para>
|
||||||
This is the directory (or directories) where Smarty will look for the
|
This is the directory (or directories) where Smarty will look for the
|
||||||
plugins that it needs. Default is "plugins" under the
|
plugins that it needs. Default is
|
||||||
|
<filename class="directory">"plugins"</filename> under the
|
||||||
<link linkend="constant.smarty.dir">SMARTY_DIR</link>. If you
|
<link linkend="constant.smarty.dir">SMARTY_DIR</link>. If you
|
||||||
supply a relative path, Smarty will first look under the
|
supply a relative path, Smarty will first look under the
|
||||||
<link linkend="constant.smarty.dir">SMARTY_DIR</link>, then
|
<link linkend="constant.smarty.dir">SMARTY_DIR</link>, then
|
||||||
@@ -16,11 +17,30 @@
|
|||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
For best performance, do not setup your plugins_dir to have to use the
|
For best performance, do not setup your $plugins_dir to have to use
|
||||||
PHP include path. Use an absolute pathname, or a path relative to
|
the PHP include path. Use an absolute pathname, or a path relative
|
||||||
SMARTY_DIR or the cwd.
|
to SMARTY_DIR or the cwd.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
||||||
|
<example>
|
||||||
|
<title>multiple $plugins_dir</title>
|
||||||
|
<programlisting role="php">
|
||||||
|
<![CDATA[
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$smarty->plugins_dir = array(
|
||||||
|
'plugins', // the default under SMARTY_DIR
|
||||||
|
'/path/to/shared/plugins',
|
||||||
|
'../../includes/my/plugins'
|
||||||
|
);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
<!-- Keep this comment at the end of the file
|
<!-- Keep this comment at the end of the file
|
||||||
Local variables:
|
Local variables:
|
||||||
|
@@ -5,9 +5,12 @@
|
|||||||
<para>
|
<para>
|
||||||
This is the name of the default template directory. If you do
|
This is the name of the default template directory. If you do
|
||||||
not supply a resource type when including files, they will be
|
not supply a resource type when including files, they will be
|
||||||
found here. By default this is "./templates", meaning that it
|
found here. By default this is
|
||||||
will look for the templates directory in the same directory as
|
<filename class="directory">"./templates"</filename>,
|
||||||
the executing php script.
|
meaning that Smarty
|
||||||
|
will look for the
|
||||||
|
<filename class="directory">templates</filename> directory in
|
||||||
|
the same directory as the executing php script.
|
||||||
</para>
|
</para>
|
||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
|
@@ -23,8 +23,9 @@ nothing.
|
|||||||
<note>
|
<note>
|
||||||
<title>Technical Note</title>
|
<title>Technical Note</title>
|
||||||
<para>
|
<para>
|
||||||
$use_sub_dirs=true doesn't work with safe_mode=On, that's why it's
|
$use_sub_dirs=true doesn't work with
|
||||||
switchable and why it's off by default.
|
<ulink url="&url.php-manual;features.safe-mode">safe_mode=On</ulink>,
|
||||||
|
that's why it's switchable and why it's off by default.
|
||||||
</para>
|
</para>
|
||||||
</note>
|
</note>
|
||||||
<note>
|
<note>
|
||||||
|
@@ -4,12 +4,17 @@
|
|||||||
<title>Controlling Cacheability of Plugins' Output</title>
|
<title>Controlling Cacheability of Plugins' Output</title>
|
||||||
<para>
|
<para>
|
||||||
Since Smarty-2.6.0 plugins the cacheability of plugins can be declared
|
Since Smarty-2.6.0 plugins the cacheability of plugins can be declared
|
||||||
when registering them. The third parameter to register_block,
|
when registering them. The third parameter to
|
||||||
register_compiler_function and register_function is called
|
<link linkend="api.register.block">register_block()</link>,
|
||||||
|
<link
|
||||||
|
linkend="api.register.compiler.function">register_compiler_function()
|
||||||
|
</link> and
|
||||||
|
<link linkend="api.register.block">register_function()</link> is called
|
||||||
<parameter>$cacheable</parameter> and defaults to true which is also
|
<parameter>$cacheable</parameter> and defaults to true which is also
|
||||||
the behaviour of plugins in Smarty versions before 2.6.0
|
the behaviour of plugins in Smarty versions before 2.6.0
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
When registering a plugin with $cacheable=false the plugin is
|
When registering a plugin with $cacheable=false the plugin is
|
||||||
called everytime the page is displayed, even if the page comes
|
called everytime the page is displayed, even if the page comes
|
||||||
@@ -18,7 +23,7 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
In contrast to <link linkend="language.function.insert">{insert}</link>
|
In contrast to <link linkend="plugins.inserts">insert</link>
|
||||||
the attributes to the plugins are not cached by default. They can be
|
the attributes to the plugins are not cached by default. They can be
|
||||||
declared to be cached with the fourth parameter
|
declared to be cached with the fourth parameter
|
||||||
<parameter>$cache_attrs</parameter>. <parameter>$cache_attrs</parameter>
|
<parameter>$cache_attrs</parameter>. <parameter>$cache_attrs</parameter>
|
||||||
|
@@ -22,8 +22,9 @@ define('SMARTY_DIR','/usr/local/lib/php/Smarty/libs/');
|
|||||||
// path to Smarty windows style
|
// path to Smarty windows style
|
||||||
define('SMARTY_DIR','c:/webroot/libs/Smarty/libs/');
|
define('SMARTY_DIR','c:/webroot/libs/Smarty/libs/');
|
||||||
|
|
||||||
// hack that works on both under DOCUMENT _ROOT (not recommended)
|
// hack (not recommended) that works on both *nix and wind
|
||||||
define('SMARTY-DIR',str_replace("\\","/",getcwd()).'/includes/Smarty/libs/');
|
// Smarty is assumend to be in 'includes' dir under script
|
||||||
|
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty/libs/');
|
||||||
|
|
||||||
// include the smarty class Note 'S' is upper case
|
// include the smarty class Note 'S' is upper case
|
||||||
require_once(SMARTY_DIR.'Smarty.class.php');
|
require_once(SMARTY_DIR.'Smarty.class.php');
|
||||||
|
Reference in New Issue
Block a user