more examples, WS and linking from Peter. Thanks :)

This commit is contained in:
nlopess
2005-06-05 15:47:25 +00:00
parent 7ed67f0384
commit eea494dcd2
26 changed files with 541 additions and 250 deletions

View File

@@ -12,7 +12,9 @@
table backgrounds work properly. Many would use an
<link linkend="language.function.if">{if}</link> statement to
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>
<example>
<title>Printing &amp;nbsp; when a variable is empty</title>
@@ -69,53 +71,71 @@
<title>Passing variable title to header template</title>
<para>
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
what page you are coming from? You can pass the title to the header when
it is included.
</para>
<example>
<title>Passing the title variable to the header template</title>
<para>
<filename>mainpage.tpl</filename>
</para>
<programlisting>
<![CDATA[
mainpage.tpl
------------
{include file="header.tpl" title="Main Page"}
{* template body goes here *}
{include file="footer.tpl"}
]]>
</programlisting>
archives.tpl
------------
<para>
<filename>archives.tpl</filename>
</para>
<programlisting>
<![CDATA[
{config_load file="archive_page.conf"}
{include file="header.tpl" title=#archivePageTitle#}
{* template body goes here *}
{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
----------
<HTML>
<HEAD>
<TITLE>{$title|default:"BC News"}</TITLE>
</HEAD>
<BODY>
footer.tpl
----------
</BODY>
</HTML>
<para>
<filename>footer.tpl</filename>
</para>
<programlisting>
<![CDATA[
</body>
</html>
]]>
</programlisting>
</example>
<para>
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
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
printed if the $title variable is not set, using the
<link linkend="language.modifier.default">default</link>
@@ -191,7 +211,7 @@ Jan 4, 2001
$startDate = makeTimeStamp($startDate_Year, $startDate_Month, $startDate_Day);
function makeTimeStamp($year="", $month="", $day="")
function makeTimeStamp($year='', $month='', $day='')
{
if(empty($year)) {
$year = strftime("%Y");
@@ -222,15 +242,20 @@ function makeTimeStamp($year="", $month="", $day="")
<sect1 id="tips.wap">
<title>WAP/WML</title>
<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
function that prints the header. If you are using caching, that won't
work so we'll do it using the insert tag (remember insert tags are not
cached!) Be sure that there is nothing output to the browser before the
function that prints the header. If you are using
<link linkend="caching">caching</link>, that won't
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.
</para>
<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">
<![CDATA[
<?php
@@ -289,8 +314,8 @@ function insert_header($params)
Traditionally, programming templates into your applications goes as
follows: First, you accumulate your variables within your PHP
application, (maybe with database queries.) Then, you instantiate your
Smarty object, <link linkend="api.assign">assign</link> the variables and
<link linkend="api.display">display</link> the template. So lets
Smarty object, <link linkend="api.assign">assign()</link> the variables and
<link linkend="api.display">display()</link> the template. So lets
say for example we have a stock ticker on our template. We would
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
@@ -303,12 +328,15 @@ function insert_header($params)
</para>
<example>
<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">
<![CDATA[
<?php
// drop file "function.load_ticker.php" in plugin directory
// setup our function for fetching stock data
function fetch_ticker($symbol)
{
@@ -328,10 +356,11 @@ function smarty_function_load_ticker($params, &$smarty)
?>
]]>
</programlisting>
<para>
<filename>index.tpl</filename>
</para>
<programlisting>
<![CDATA[
{* in index.tpl *}
{load_ticker symbol="YHOO" assign="ticker"}
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
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
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>
<example>
<title>Example of Obfuscating an E-mail Address</title>
@@ -369,11 +399,13 @@ Send inquiries to
<title>Technical Note</title>
<para>
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>
</note>
<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>
</sect1>
</chapter>

View File

@@ -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
the template.
</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>
See also
<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
vi: ts=1 sw=1
-->

View File

@@ -44,9 +44,9 @@
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
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
format.
formatting of the date. If the date passed to
<command>date_format</command> is empty and a second parameter is passed,
that will be used as the date to format.
</para>
<example>
<title>date_format</title>
@@ -60,7 +60,7 @@ $smarty->assign('yesterday', strtotime('-1 day'));
]]>
</programlisting>
<para>
Where template is:
Where template is (uses <link linkend="language.variables.smarty.now">$smarty.now</link>):
</para>
<programlisting>
<![CDATA[

View File

@@ -3,7 +3,7 @@
<sect1 id="language.variables.smarty">
<title>{$smarty} reserved variable</title>
<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.
</para>
@@ -12,7 +12,10 @@
<para>
The <ulink url="&url.php-manual;reserved.variables">request variables
</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>
<example>
<title>displaying request variables</title>

View File

@@ -25,10 +25,10 @@
</para>
&parameter.compileid;
<para>
<example>
<title>fetch()</title>
<programlisting role="php">
<para>
<example>
<title>fetch()</title>
<programlisting role="php">
<![CDATA[
<?php
include('Smarty.class.php');
@@ -61,17 +61,17 @@ $output = $smarty->fetch('index.tpl');
echo $output;
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Using fetch() to send an email</title>
<para>
The email_body.txt template
</programlisting>
</example>
</para>
<programlisting>
<para>
<example>
<title>Using fetch() to send an email</title>
<para>
The email_body.tpl template
</para>
<programlisting>
<![CDATA[
Dear {$contact.name},
@@ -85,23 +85,28 @@ http://{$smarty.server.SERVER_NAME}/index.php?page=login
List master
Some user group
{include file="email_disclaimer.txt"}
{include file="email_disclaimer.tpl"}
]]>
</programlisting>
</programlisting>
<para>
The email_disclaimer.txt template
The email_disclaimer.tpl template which uses the
<link linkend="language.function.textformat">{textformat}</link> modifier.
</para>
<programlisting>
<programlisting>
<![CDATA[
This e-mail is intended for the addressee shown. It contains information
....... etc .......
{textformat wrap=40}
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>
and the php script using the PHP
<ulink url="&url.php-manual;function.mail">mail()</ulink> function
</para>
<programlisting role="php">
<programlisting role="php">
<![CDATA[
<?php
@@ -110,14 +115,13 @@ $query = 'select name, email, login_id from contacts where contact_id='.$contac
$contact = $db->getRow($sql);
$smarty->assign('contact', $contact);
mail($contact['email'], 'Subject', $smarty->fetch('email_body.txt'));
mail($contact['email'], 'Subject', $smarty->fetch('email_body.tpl'));
?>
]]>
</programlisting>
</example>
</para>
</programlisting>
</example>
</para>
<para>
See also
@@ -150,5 +154,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -41,7 +41,8 @@ $smarty->load_filter('output', 'compress');
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>
<link linkend="api.register.outputfilter">register_outputfilter()</link>,
<link linkend="variable.autoload.filters">$autoload_filters</link>
and
<link linkend="advanced.features">Advanced features</link>.
</para>

View File

@@ -21,24 +21,30 @@
<para>
The php-function callback <parameter>impl</parameter> can be either:
</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>
(a) a string containing the function name
a string containing the function name
</para>
<para>(b) an array of the form <literal>array(&amp;$object, $method)</literal> with
</listitem><listitem>
<para>an array of the form <literal>array(&amp;$object, $method)</literal> with
<literal>&amp;$object</literal> being a reference to an
object and <literal>$method</literal> being a string
containing the mehod-name
</para>
<para>(c) an array of the form
</listitem><listitem>
<para>an array of the form
<literal>array(&amp;$class, $method)</literal> with
<literal>$class</literal> being a classname and
<literal>$method</literal> being a class method of that
class.
</para>
</listitem>
</orderedlist>
<para>
<parameter>cacheable</parameter> can be omitted in
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>

View File

@@ -22,22 +22,29 @@
<para>
The php-function callback <parameter>impl</parameter> can be either
</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>
(a) a string containing the function name
a string containing the function name
</para>
</listitem><listitem>
<para>
(b) an array of the form
an array of the form
<literal>array(&amp;$object, $method)</literal> with
<literal>&amp;$object</literal> being a reference to an
object and <literal>$method</literal> being a string
containing the mehod-name
</para>
</listitem><listitem>
<para>
(c) an array of the form <literal>array(&amp;$class, $method)</literal>
an array of the form <literal>array(&amp;$class, $method)</literal>
with <literal>$class</literal> being a classname and
<literal>$method</literal> being a class method of that
class.
</para>
</listitem>
</orderedlist>
<para>
<parameter>cacheable</parameter> and <parameter>cache_attrs</parameter> can be
omitted in most cases. See <link

View File

@@ -18,17 +18,30 @@
implements it.
</para>
<para>
The php-function callback <parameter>impl</parameter> can be either (a) a string
containing the function name or (b) an array of the form
<literal>array(&amp;$object, $method)</literal> with
<literal>&amp;$object</literal> being a reference to an
The php-function callback <parameter>impl</parameter> can be either
</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>a string containing the function name
</para>
</listitem><listitem>
<para>an array of the form <literal>array(&amp;$object,
$method)</literal> with <literal>&amp;$object</literal>
being a reference to an
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(&amp;$class, $method)</literal> with
<literal>$class</literal> being a classname and
<literal>$method</literal> being a class method of that
class.
</para>
</listitem>
</orderedlist>
<example>
<title>register_modifier()</title>
<programlisting role="php">
@@ -59,7 +72,7 @@ $smarty->register_modifier('sslash', 'stripslashes');
<link linkend="language.modifiers">modifiers</link>,
<link linkend="plugins">Extending Smarty with plugins</link>
and
<link linkend="plugins.modifiers">Plugin modifiers</link>,
<link linkend="plugins.modifiers">Creating Plugin modifiers</link>,
</para>
</refsect1>
</refentry>

View File

@@ -22,7 +22,10 @@
for examples.
</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>
</refsect1>
</refentry>

View File

@@ -23,30 +23,36 @@
<para>
The php-function callback <parameter>function</parameter> can be either
</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>
(a) a string
containing the function name
a string containing the function name
</para>
</listitem><listitem>
<para>
(b) an array of the form
an array of the form
<literal>array(&amp;$object, $method)</literal> with
<literal>&amp;$object</literal> being a reference to an
object and <literal>$method</literal> being a string
containing the mehod-name
</para>
</listitem><listitem>
<para>
(c) an array of the form
an array of the form
<literal>array(&amp;$class, $method)</literal> with
<literal>$class</literal> being a classname and
<literal>$method</literal> being a class method of that
class.
</para>
</listitem>
</orderedlist>
<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>,
<link linkend="variable.autoload.filters">$autoload_filters</link>
and
<link linkend="advanced.features.outputfilters">template
output filters</link>.

View File

@@ -21,30 +21,36 @@
<para>
The php-function callback <parameter>function</parameter> can be either
</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>
(a) a string containing the function name
a string containing the function name
</para>
</listitem><listitem>
<para>
(b) an array of the form
an array of the form
<literal>array(&amp;$object, $method)</literal> with
<literal>&amp;$object</literal> being a reference to an
object and <literal>$method</literal> being a string
containing the mehod-name
</para>
</listitem><listitem>
<para>
(c) an array of the form
an array of the form
<literal>array(&amp;$class, $method)</literal> with
<literal>$class</literal> being a classname and
<literal>$method</literal> being a class method of that
class.
</para>
</listitem>
</orderedlist>
<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>,
<link linkend="variable.autoload.filters">$autoload_filters</link>
and
<link linkend="advanced.features.outputfilters">template
output filters</link>.

View File

@@ -18,37 +18,46 @@
linkend="advanced.features.prefilters">template prefilters</link> for
more information on how to setup a prefiltering function.
</para>
<para>
The php-function callback <parameter>function</parameter> can be either
</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>
(a) a string
containing the function name
a string containing the function name
</para>
</listitem><listitem>
<para>
(b) an array of the form
an array of the form
<literal>array(&amp;$object, $method)</literal> with
<literal>&amp;$object</literal> being a reference to an
object and <literal>$method</literal> being a string
containing the mehod-name
</para>
</listitem><listitem>
<para>
(c) an array of the form
an array of the form
<literal>array(&amp;$class, $method)</literal> with
<literal>$class</literal> being a classname and
<literal>$method</literal> being a class method of that
class.
</para>
</listitem>
</orderedlist>
<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>,
<link linkend="variable.autoload.filters">$autoload_filters</link>
and
<link linkend="advanced.features.outputfilters">template
output filters</link>.
</para>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View File

@@ -15,6 +15,55 @@
It can accept either a path to the template on the filesystem or a
resource string specifying the template.
</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>
See also
<link linkend="api.display">display()</link>,

View File

@@ -19,6 +19,15 @@ $smarty->autoload_filters = array('pre' => array('trim', 'stamp'),
</programlisting>
</informalexample>
</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>
<!-- Keep this comment at the end of the file

View File

@@ -4,11 +4,13 @@
<title>$cache_dir</title>
<para>
This is the name of the directory where template caches are
stored. By default this is "./cache", meaning that it will look
for the cache directory in the same directory as the executing
php script.
stored. By default this is
<filename class="directory">"./cache"</filename>, meaning that
Smarty will look for the cache directory in the same directory
as the executing php script.
<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
<link linkend="section.template.cache.handler.func">
custom cache handler</link>
@@ -64,3 +66,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View File

@@ -3,7 +3,8 @@
<sect1 id="variable.caching">
<title>$caching</title>
<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
redundant content, it is advisable to turn on $caching. This
will result in significant performance gains. You can also have

View File

@@ -4,10 +4,14 @@
<title>$compile_dir</title>
<para>
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
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>.
</para>

View File

@@ -6,9 +6,10 @@
This is the directory used to store
<link linkend="config.files">config files</link>
used in the
templates. Default is "./configs", meaning that it will look
for the configs directory in the same directory as the
executing php script.
templates. Default is
<filename class="directory">"./configs"</filename>, meaning that
Smarty will look for the configs directory in the same directory
as the executing php script.
</para>
<note>
<title>Technical Note</title>

View File

@@ -4,7 +4,8 @@
<title>$debug_tpl</title>
<para>
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>.
</para>
<para>

View File

@@ -21,8 +21,8 @@
<note>
<para>
Embedding PHP code into templates is highly discouraged.
Use <link linkend="language.custom.functions">custom functions</link> or
<link linkend="language.modifiers">modifiers</link> instead.
Use <link linkend="plugins.functions">custom functions</link> or
<link linkend="plugins.modifiers">modifiers</link> instead.
</para>
</note>
</sect1>

View File

@@ -4,7 +4,8 @@
<title>$plugins_dir</title>
<para>
This is the directory (or directories) where Smarty will look for the
plugins that it needs. Default is "plugins" under the
plugins that it needs. Default is
<filename class="directory">"plugins"</filename> under the
<link linkend="constant.smarty.dir">SMARTY_DIR</link>. If you
supply a relative path, Smarty will first look under the
<link linkend="constant.smarty.dir">SMARTY_DIR</link>, then
@@ -16,11 +17,30 @@
<note>
<title>Technical Note</title>
<para>
For best performance, do not setup your plugins_dir to have to use the
PHP include path. Use an absolute pathname, or a path relative to
SMARTY_DIR or the cwd.
For best performance, do not setup your $plugins_dir to have to use
the PHP include path. Use an absolute pathname, or a path relative
to SMARTY_DIR or the cwd.
</para>
</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>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -5,9 +5,12 @@
<para>
This is the name of the default template directory. If you do
not supply a resource type when including files, they will be
found here. By default this is "./templates", meaning that it
will look for the templates directory in the same directory as
the executing php script.
found here. By default this is
<filename class="directory">"./templates"</filename>,
meaning that Smarty
will look for the
<filename class="directory">templates</filename> directory in
the same directory as the executing php script.
</para>
<note>
<title>Technical Note</title>

View File

@@ -23,8 +23,9 @@ nothing.
<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.
$use_sub_dirs=true doesn't work with
<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>
</note>
<note>

View File

@@ -4,12 +4,17 @@
<title>Controlling Cacheability of Plugins' Output</title>
<para>
Since Smarty-2.6.0 plugins the cacheability of plugins can be declared
when registering them. The third parameter to register_block,
register_compiler_function and register_function is called
when registering them. The third parameter to
<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
the behaviour of plugins in Smarty versions before 2.6.0
</para>
<para>
When registering a plugin with $cacheable=false the plugin is
called everytime the page is displayed, even if the page comes
@@ -18,7 +23,7 @@
</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
declared to be cached with the fourth parameter
<parameter>$cache_attrs</parameter>. <parameter>$cache_attrs</parameter>

View File

@@ -22,8 +22,9 @@ define('SMARTY_DIR','/usr/local/lib/php/Smarty/libs/');
// 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/');
// hack (not recommended) that works on both *nix and wind
// 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
require_once(SMARTY_DIR.'Smarty.class.php');