Clean up:

- domain.com => example.com, as suggested by RFC 2606
- fix and introduce more dockbook tags
- fix white spaces and use CDATA sections
- add some paras to make the text more reader friendly
This commit is contained in:
didou
2004-11-21 02:04:01 +00:00
parent 659563b570
commit 9d4d0c08a1
18 changed files with 810 additions and 787 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<chapter id="resources">
<chapter id="resources">
<title>Resources</title>
<para>
Smarty's homepage is located at <ulink

View File

@@ -240,22 +240,22 @@ function insert_header($params)
<!-- begin new wml deck -->
<wml>
<!-- begin first card -->
<card>
<do type="accept">
<go href="#two"/>
</do>
<p>
Welcome to WAP with Smarty!
Press OK to continue...
</p>
</card>
<!-- begin second card -->
<card id="two">
<p>
Pretty easy isn't it?
</p>
</card>
<!-- begin first card -->
<card>
<do type="accept">
<go href="#two"/>
</do>
<p>
Welcome to WAP with Smarty!
Press OK to continue...
</p>
</card>
<!-- begin second card -->
<card id="two">
<p>
Pretty easy isn't it?
</p>
</card>
</wml>
]]>
</programlisting>
@@ -307,10 +307,7 @@ function smarty_function_load_ticker($params, &$smarty)
</programlisting>
<programlisting>
<![CDATA[
index.tpl
---------
{* Smarty *}
{* in index.tpl *}
{load_ticker symbol="YHOO" assign="ticker"}
@@ -332,8 +329,7 @@ Stock Name: {$ticker.name} Stock Price: {$ticker.price}
<title>Example of Obfuscating an E-mail Address</title>
<programlisting>
<![CDATA[
index.tpl
---------
{* in index.tpl *}
Send inquiries to
{mailto address=$EmailAddress encode="javascript" subject="Hello"}

View File

@@ -4,10 +4,12 @@
<title>Smarty - the compiling PHP template engine</title>
<authorgroup id="authors">
<author>
<firstname>Monte</firstname><surname>Ohrt &lt;monte@ispi.net&gt;</surname>
<firstname>Monte</firstname>
<surname>Ohrt &lt;monte@ispi.net&gt;</surname>
</author>
<author>
<firstname>Andrei</firstname><surname>Zmievski &lt;andrei@php.net&gt;</surname>
<firstname>Andrei</firstname>
<surname>Zmievski &lt;andrei@php.net&gt;</surname>
</author>
</authorgroup>
<pubdate>&build-date;</pubdate>

View File

@@ -32,7 +32,7 @@ Intro = """This is a value that spans more
# hidden section
[.Database]
host=my.domain.com
host=my.example.com
db=ADDRESSBOOK
user=php-user
pass=foobar

View File

@@ -79,7 +79,7 @@
{* body of template goes here *}
{include file="footer.tpl" logo="http://my.domain.com/logo.gif"}</programlisting>
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}</programlisting>
</example>
<para>
Use the syntax for <link

View File

@@ -174,21 +174,21 @@ name: John Smith&lt;br&gt;
address: 253 N 45th&lt;br&gt;
home phone: 555-555-5555&lt;br&gt;
cell phone: 555-555-5555&lt;br&gt;
e-mail: john@mydomain.com&lt;br&gt;
e-mail: john@myexample.com&lt;br&gt;
&lt;p&gt;
id: 1001&lt;br&gt;
name: Jack Jones&lt;br&gt;
address: 417 Mulberry ln&lt;br&gt;
home phone: 555-555-5555&lt;br&gt;
cell phone: 555-555-5555&lt;br&gt;
e-mail: jack@mydomain.com&lt;br&gt;
e-mail: jack@myexample.com&lt;br&gt;
&lt;p&gt;
id: 1002&lt;br&gt;
name: Jane Munson&lt;br&gt;
address: 5605 apple st&lt;br&gt;
home phone: 555-555-5555&lt;br&gt;
cell phone: 555-555-5555&lt;br&gt;
e-mail: jane@mydomain.com&lt;br&gt;
e-mail: jane@myexample.com&lt;br&gt;
&lt;p&gt;</programlisting>
</example>
@@ -210,15 +210,15 @@ OUTPUT:
name: John Smith&lt;br&gt;
home: 555-555-5555&lt;br&gt;
cell: 555-555-5555&lt;br&gt;
e-mail: john@mydomain.com&lt;p&gt;
e-mail: john@myexample.com&lt;p&gt;
name: Jack Jones&lt;br&gt;
home phone: 555-555-5555&lt;br&gt;
cell phone: 555-555-5555&lt;br&gt;
e-mail: jack@mydomain.com&lt;p&gt;
e-mail: jack@myexample.com&lt;p&gt;
name: Jane Munson&lt;br&gt;
home phone: 555-555-5555&lt;br&gt;
cell phone: 555-555-5555&lt;br&gt;
e-mail: jane@mydomain.com&lt;p&gt;</programlisting>
e-mail: jane@myexample.com&lt;p&gt;</programlisting>
</example>

View File

@@ -44,7 +44,7 @@
OUTPUT:
<table border=0><tr><td><A HREF="http://my.domain.com"><font color="red">This is a test</font></A></td></tr></table>
<table border=0><tr><td><A HREF="http://my.example.com"><font color="red">This is a test</font></A></td></tr></table>
]]>
</programlisting>
</example>

View File

@@ -71,13 +71,13 @@
<programlisting>
<![CDATA[
{* include some javascript in your template *}
{fetch file="/export/httpd/www.domain.com/docs/navbar.js"}
{fetch file="/export/httpd/www.example.com/docs/navbar.js"}
{* embed some weather text in your template from another web site *}
{fetch file="http://www.myweather.com/68502/"}
{* fetch a news headline file via ftp *}
{fetch file="ftp://user:password@ftp.domain.com/path/to/currentheadlines.txt"}
{fetch file="ftp://user:password@ftp.example.com/path/to/currentheadlines.txt"}
{* assign the fetched contents to a template variable *}
{fetch file="http://www.myweather.com/68502/" assign="weather"}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.function.html.options">
<sect1 id="language.function.html.options">
<title>html_options</title>
<informaltable frame="all">
<tgroup cols="5">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.function.mailto">
<sect1 id="language.function.mailto">
<title>mailto</title>
<informaltable frame="all">
<tgroup cols="5">
@@ -31,25 +31,23 @@
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>the text to display, default is
the e-mail address</entry>
<entry>the text to display, default is the e-mail address</entry>
</row>
<row>
<entry>encode</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>none</emphasis></entry>
<entry>How to encode the e-mail.
Can be one of none,
hex or javascript.</entry>
<entry>How to encode the e-mail. Can be one of <literal>none</literal>,
<literal>hex</literal> or <literal>javascript</literal>.</entry>
</row>
<row>
<entry>cc</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>e-mail addresses to carbon copy.
Separate entries by a comma.</entry>
<entry>e-mail addresses to carbon copy. Separate entries by a comma.
</entry>
</row>
<row>
<entry>bcc</entry>
@@ -71,24 +69,21 @@
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>newsgroups to post to.
Separate entries by a comma.</entry>
<entry>newsgroups to post to. Separate entries by a comma.</entry>
</row>
<row>
<entry>followupto</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>addresses to follow up to.
Separate entries by a comma.</entry>
<entry>addresses to follow up to. Separate entries by a comma.</entry>
</row>
<row>
<entry>extra</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>any extra information you
want passed to the link, such
<entry>any extra information you want passed to the link, such
as style sheet classes</entry>
</row>
</tbody>
@@ -106,29 +101,29 @@
encoding, although you can use hex encoding too.
</para>
</note>
<example>
<title>mailto</title>
<programlisting>
{mailto address="me@domain.com"}
{mailto address="me@domain.com" text="send me some mail"}
{mailto address="me@domain.com" encode="javascript"}
{mailto address="me@domain.com" encode="hex"}
{mailto address="me@domain.com" subject="Hello to you!"}
{mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
{mailto address="me@domain.com" extra='class="email"'}
<example>
<title>mailto</title>
<programlisting>
{mailto address="me@example.com"}
{mailto address="me@example.com" text="send me some mail"}
{mailto address="me@example.com" encode="javascript"}
{mailto address="me@example.com" encode="hex"}
{mailto address="me@example.com" subject="Hello to you!"}
{mailto address="me@example.com" cc="you@example.com,they@example.com"}
{mailto address="me@example.com" extra='class="email"'}
OUTPUT:
&lt;a href="mailto:me@domain.com" &gt;me@domain.com&lt;/a&gt;
&lt;a href="mailto:me@domain.com" &gt;send me some mail&lt;/a&gt;
&lt;a href="mailto:me@example.com" &gt;me@example.com&lt;/a&gt;
&lt;a href="mailto:me@example.com" &gt;send me some mail&lt;/a&gt;
&lt;script type="text/javascript" language="javascript"&gt;eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%6
9%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%
61%69%6e%2e%63%6f%6d%22%20%3e%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%3c%2f%61%3e
%27%29%3b'))&lt;/script&gt;
&lt;a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" &gt;&#x6d;&#x65;&#x40;&#x64;&#x6f;&#x6d;&#x61;&#x69;&#x6e;&#x2e;&#x63;&#x6f;&#x6d;&lt;/a&gt;
&lt;a href="mailto:me@domain.com?subject=Hello%20to%20you%21" &gt;me@domain.com&lt;/a&gt;
&lt;a href="mailto:me@domain.com?cc=you@domain.com%2Cthey@domain.com" &gt;me@domain.com&lt;/a&gt;
&lt;a href="mailto:me@domain.com" class="email"&gt;me@domain.com&lt;/a&gt;</programlisting>
&lt;a href="mailto:me@example.com?subject=Hello%20to%20you%21" &gt;me@example.com&lt;/a&gt;
&lt;a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" &gt;me@example.com&lt;/a&gt;
&lt;a href="mailto:me@example.com" class="email"&gt;me@example.com&lt;/a&gt;</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.function.popup">
<sect1 id="language.function.popup">
<title>popup</title>
<informaltable frame="all">
<tgroup cols="5">
@@ -393,19 +393,23 @@
<para>
popup is used to create javascript popup windows.
</para>
<example>
<title>popup</title>
<programlisting>
<example>
<title>popup</title>
<programlisting>
<![CDATA[
{* popup_init must be called once at the top of the page *}
{popup_init src="/javascripts/overlib.js"}
{* create a link with a popup window when you move your mouse over *}
&lt;A href="mypage.html" {popup text="This link takes you to my page!"}&gt;mypage&lt;/A&gt;
<a href="mypage.html" {popup text="This link takes you to my page!"}>mypage</a>
{* you can use html, links, etc in your popup text *}
&lt;A href="mypage.html" {popup sticky=true caption="mypage contents"
text="&lt;UL&gt;&lt;LI&gt;links&lt;LI&gt;pages&lt;LI&gt;images&lt;/UL&gt;" snapx=10 snapy=10}&gt;mypage&lt;/A&gt;</programlisting>
</example>
<a href="mypage.html" {popup sticky=true caption="mypage contents"
text="<ul><li>links</li><li>pages</li><li>images</li></ul>" snapx=10
snapy=10}>mypage</a>
]]>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:

View File

@@ -18,7 +18,7 @@
<title>displaying request variables</title>
<programlisting>
<![CDATA[
{* display value of page from URL (GET) http://www.domain.com/index.php?page=foo *}
{* display value of page from URL (GET) http://www.example.com/index.php?page=foo *}
{$smarty.get.page}
{* display the variable "page" from a form (POST) *}

View File

@@ -9,12 +9,15 @@
Smarty is a template engine for PHP. More specifically, it facilitates a
manageable way to separate application logic and content from its
presentation. This is best described in a situation where the application
programmer and the template designer play different roles, or in most cases
are not the same person. For example, let's say you are creating a web page
that is displaying a newspaper article. The article headline, tagline,
author and body are content elements, they contain no information about how
they will be presented. They are passed into Smarty by the application,
then the template designer edits the templates and uses a combination of
programmer and the template designer play different roles, or in most
cases are not the same person.
</para>
<para>
For example, let's say you are creating a web page that is displaying a
newspaper article. The article headline, tagline, author and body are
content elements, they contain no information about how they will be
presented. They are passed into Smarty by the application, then the
template designer edits the templates and uses a combination of
HTML tags and template tags to format the presentation of these elements
(HTML tables, background colors, font sizes, style sheets, etc.) One day
the programmer needs to change the way the article content is retrieved (a
@@ -35,16 +38,16 @@
presentation logic. This does not mean that Smarty forces a separation of
business and presentation logic. Smarty has no knowledge of which is which,
so placing business logic in the template is your own doing. Also, if you
desire NO logic in your templates you certainly can do so by boiling the
content down to text and variables only.
desire <emphasis>no</emphasis> logic in your templates you certainly can
do so by boiling the content down to text and variables only.
</para>
<para>
One of the unique aspects about Smarty is the template compiling. This means
Smarty reads the template files and creates PHP scripts from them. Once
they are created, they are executed from then on. Therefore there is no
costly template file parsing for each request, and each template can take
full advantage of PHP compiler cache solutions such as Zend Accelerator
(<ulink url="&url.zend;">&url.zend;</ulink>) or PHP Accelerator
One of the unique aspects about Smarty is the template compiling. This
means Smarty reads the template files and creates PHP scripts from them.
Once they are created, they are executed from then on. Therefore there is
no costly template file parsing for each request, and each template can
take full advantage of PHP compiler cache solutions such as Zend
Accelerator (<ulink url="&url.zend;">&url.zend;</ulink>) or PHP Accelerator
(<ulink url="&url.php-accelerator;">&url.php-accelerator;</ulink>).
</para>
<para>
@@ -73,8 +76,10 @@
</listitem>
<listitem>
<para>
You can make <link linkend="language.custom.functions">custom functions</link>
and custom <link linkend="language.modifiers">variable modifiers</link>, so the
You can make <link
linkend="language.custom.functions">custom functions</link>
and custom <link
linkend="language.modifiers">variable modifiers</link>, so the
template language is extremely extensible.
</para>
</listitem>
@@ -87,8 +92,8 @@
<listitem>
<para>
The if/elseif/else/endif constructs are passed to the
PHP parser, so the {if ...} expression syntax can be as simple or as complex
as you like.
PHP parser, so the {if ...} expression syntax can be as simple or as
complex as you like.
</para>
</listitem>
<listitem>
@@ -98,9 +103,9 @@
</listitem>
<listitem>
<para>
It is possible to embed PHP code right in your template files,
although this may not be needed (nor recommended)
since the engine is so customizable.
It is possible to embed PHP code right in your template files, although
this may not be needed (nor recommended) since the engine is so
customizable.
</para>
</listitem>
<listitem>
@@ -160,9 +165,9 @@ debug.tpl
Smarty uses a PHP constant named <link
linkend="constant.smarty.dir">SMARTY_DIR</link> which is the system
filepath Smarty library directory. Basically, if your application can find
the <emphasis>Smarty.class.php</emphasis> file, you do not need to set
the <filename>Smarty.class.php</filename> file, you do not need to set
SMARTY_DIR, Smarty will figure it out on its own. Therefore, if
<emphasis>Smarty.class.php</emphasis> is not in your include_path, or you
<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
define SMARTY_DIR manually. SMARTY_DIR <emphasis>must</emphasis> include a
trailing slash.
@@ -185,7 +190,7 @@ $smarty = new Smarty;
<para>
Try running the above script. If you get an error saying the
<emphasis>Smarty.class.php</emphasis> file could not be found, you have to
<filename>Smarty.class.php</filename> file could not be found, you have to
do one of the following:
</para>
@@ -232,18 +237,20 @@ $smarty = new Smarty;
<para>
Now that the library files are in place, it's time to setup the Smarty
directories for your application. Smarty requires four directories which
are (by default) named <emphasis>templates</emphasis>,
<emphasis>templates_c</emphasis>, <emphasis>configs</emphasis> and
<emphasis>cache</emphasis>. Each of these are definable by the Smarty class
properties <emphasis>$template_dir</emphasis>,
<emphasis>$compile_dir</emphasis>, <emphasis>$config_dir</emphasis>, and
<emphasis>$cache_dir</emphasis> respectively. It is highly recommended
are (by default) named <filename class="directory">templates</filename>,
<filename class="directory">templates_c</filename>, <filename
class="directory">configs</filename> and <filename
class="directory">cache</filename>. Each of these are definable by the
Smarty class properties <varname>$template_dir</varname>,
<varname>$compile_dir</varname>, <varname>$config_dir</varname>, and
<varname>$cache_dir</varname> respectively. It is highly recommended
that you setup a separate set of these directories for each application
that will use Smarty.
</para>
<para>
Be sure you know the location of your web server document root. In our
example, the document root is "/web/www.mydomain.com/docs/". The Smarty
example, the document root is <filename
class="directory">/web/www.example.com/docs/</filename>. The Smarty
directories are only accessed by the Smarty library and never accessed
directly by the web browser. Therefore to avoid any security concerns, it
is recommended to place these directories <emphasis>outside</emphasis> of
@@ -255,13 +262,14 @@ $smarty = new Smarty;
of a directory naming convention. You can use the same environment for any
application, just replace "guestbook" with the name of your app. We'll
place our Smarty directories under
"/web/www.mydomain.com/smarty/guestbook/".
<filename
class="directory">/web/www.example.com/smarty/guestbook/</filename>.
</para>
<para>
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 "index.php",
and place it in a subdirectory under the document root called
"/guestbook/".
script accessed by the web browser. We will call our script
<filename>index.php</filename>, and place it in a subdirectory under the
document root called <filename class="directory">/guestbook/</filename>.
</para>
<note>
@@ -269,7 +277,7 @@ $smarty = new Smarty;
<para>
It is convenient to setup the web server so that "index.php" can be
identified as the default directory index, so if you access
"http://www.mydomain.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
"index.php" onto the end of your DirectoryIndex setting (separate each
entry with a space.)
@@ -291,12 +299,12 @@ $smarty = new Smarty;
/usr/local/lib/php/Smarty/internals/*.php
/usr/local/lib/php/Smarty/plugins/*.php
/web/www.mydomain.com/smarty/guestbook/templates/
/web/www.mydomain.com/smarty/guestbook/templates_c/
/web/www.mydomain.com/smarty/guestbook/configs/
/web/www.mydomain.com/smarty/guestbook/cache/
/web/www.example.com/smarty/guestbook/templates/
/web/www.example.com/smarty/guestbook/templates_c/
/web/www.example.com/smarty/guestbook/configs/
/web/www.example.com/smarty/guestbook/cache/
/web/www.mydomain.com/docs/guestbook/index.php
/web/www.example.com/docs/guestbook/index.php
]]>
</screen>
</example>
@@ -314,11 +322,11 @@ $smarty = new Smarty;
<title>Setting file permissions</title>
<programlisting role="shell">
<![CDATA[
chown nobody:nobody /web/www.mydomain.com/smarty/guestbook/templates_c/
chmod 770 /web/www.mydomain.com/smarty/guestbook/templates_c/
chown nobody:nobody /web/www.example.com/smarty/guestbook/templates_c/
chmod 770 /web/www.example.com/smarty/guestbook/templates_c/
chown nobody:nobody /web/www.mydomain.com/smarty/guestbook/cache/
chmod 770 /web/www.mydomain.com/smarty/guestbook/cache/
chown nobody:nobody /web/www.example.com/smarty/guestbook/cache/
chmod 770 /web/www.example.com/smarty/guestbook/cache/
]]>
</programlisting>
</example>
@@ -339,7 +347,7 @@ chmod 770 /web/www.mydomain.com/smarty/guestbook/cache/
</para>
<example>
<title>Editing /web/www.mydomain.com/smarty/guestbook/templates/index.tpl</title>
<title>Editing /web/www.example.com/smarty/guestbook/templates/index.tpl</title>
<screen>
<![CDATA[
@@ -369,7 +377,7 @@ Hello, {$name}!
</para>
<example>
<title>Editing /web/www.mydomain.com/docs/guestbook/index.php</title>
<title>Editing /web/www.example.com/docs/guestbook/index.php</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -379,10 +387,10 @@ require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = '/web/www.mydomain.com/smarty/guestbook/templates/';
$smarty->compile_dir = '/web/www.mydomain.com/smarty/guestbook/templates_c/';
$smarty->config_dir = '/web/www.mydomain.com/smarty/guestbook/configs/';
$smarty->cache_dir = '/web/www.mydomain.com/smarty/guestbook/cache/';
$smarty->template_dir = '/web/www.example.com/smarty/guestbook/templates/';
$smarty->compile_dir = '/web/www.example.com/smarty/guestbook/templates_c/';
$smarty->config_dir = '/web/www.example.com/smarty/guestbook/configs/';
$smarty->cache_dir = '/web/www.example.com/smarty/guestbook/cache/';
$smarty->assign('name','Ned');
@@ -396,17 +404,18 @@ $smarty->display('index.tpl');
<title>Technical Note</title>
<para>
In our example, we are setting absolute paths to all of the Smarty
directories. If '/web/www.mydomain.com/smarty/guestbook/' is within your
PHP include_path, then these settings are not necessary. However, it is
more efficient and (from experience) less error-prone to set them to
absolute paths. This ensures that Smarty is getting files from the
directories you intended.
directories. If <filename
class="directory">/web/www.example.com/smarty/guestbook/</filename> is
within your PHP include_path, then these settings are not necessary.
However, it is more efficient and (from experience) less error-prone to
set them to absolute paths. This ensures that Smarty is getting files
from the directories you intended.
</para>
</note>
<para>
Now load the index.php file from your web browser. You should see "Hello,
Ned!"
Now load the <filename>index.php</filename> file from your web browser.
You should see "Hello, Ned!"
</para>
<para>
You have completed the basic setup for Smarty!
@@ -425,8 +434,9 @@ $smarty->display('index.tpl');
initialize your Smarty environment. So instead of repeatedly setting
directory paths, assigning the same vars, etc., we can do that in one place.
Lets create a new directory "/php/includes/guestbook/" and make a new file
called "setup.php". In our example environment, "/php/includes" is in our
include_path. Be sure you set this up too, or use absolute file paths.
called <filename>setup.php</filename>. In our example environment,
"/php/includes" is in our include_path. Be sure you set this up too, or
use absolute file paths.
</para>
<example>
@@ -448,17 +458,18 @@ class Smarty_GuestBook extends Smarty {
function Smarty_GuestBook()
{
// Class Constructor. These automatically get set with each new instance.
// Class Constructor.
// These automatically get set with each new instance.
$this->Smarty();
$this->template_dir = '/web/www.mydomain.com/smarty/guestbook/templates/';
$this->compile_dir = '/web/www.mydomain.com/smarty/guestbook/templates_c/';
$this->config_dir = '/web/www.mydomain.com/smarty/guestbook/configs/';
$this->cache_dir = '/web/www.mydomain.com/smarty/guestbook/cache/';
$this->template_dir = '/web/www.example.com/smarty/guestbook/templates/';
$this->compile_dir = '/web/www.example.com/smarty/guestbook/templates_c/';
$this->config_dir = '/web/www.example.com/smarty/guestbook/configs/';
$this->cache_dir = '/web/www.example.com/smarty/guestbook/cache/';
$this->caching = true;
$this->assign('app_name','Guest Book');
$this->assign('app_name', 'Guest Book');
}
}
@@ -472,7 +483,7 @@ class Smarty_GuestBook extends Smarty {
</para>
<example>
<title>Editing /web/www.mydomain.com/docs/guestbook/index.php</title>
<title>Editing /web/www.example.com/docs/guestbook/index.php</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -491,7 +502,8 @@ $smarty->display('index.tpl');
<para>
Now you see it is quite simple to bring up an instance of Smarty, just use
Smarty_GuestBook which automatically initializes everything for our application.
Smarty_GuestBook which automatically initializes everything for our
application.
</para>
</sect1>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="advanced.features.objects">
<sect1 id="advanced.features.objects">
<title>Objects</title>
<para>
Smarty allows access to PHP objects through the templates. There are
@@ -47,7 +47,7 @@
</para>
<example>
<title>using a registered or assigned object</title>
<programlisting role="php">
<programlisting role="php">
<![CDATA[
<?php
// the object
@@ -71,9 +71,13 @@ $smarty->assign_by_ref("myobj", $myobj);
$smarty->display("index.tpl");
?>
TEMPLATE:
]]>
</programlisting>
<para>
And here's how to access your objects in index.tpl:
</para>
<programlisting>
<![CDATA[
{* access our registered object *}
{foobar->meth1 p1="foo" p2=$bar}
@@ -84,7 +88,7 @@ the output was {$output}
{* access our assigned object *}
{$myobj->meth1("foo",$bar)}
]]>
</programlisting>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -42,7 +42,7 @@ $smarty->display("index.tpl");
// a simple protection against spambots
?>
]]>
</programlisting>
</programlisting>
</example>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="advanced.features.postfilters">
<sect1 id="advanced.features.postfilters">
<title>Postfilters</title>
<para>
Template postfilters are PHP functions that your templates are ran through
@@ -29,12 +29,17 @@ function add_header_comment($tpl_source, &$smarty)
$smarty->register_postfilter("add_header_comment");
$smarty->display("index.tpl");
?>
{* compiled Smarty template index.tpl *}
]]>
</programlisting>
<para>
This will make the compiled Smarty template index.tpl look like:
</para>
<screen>
<![CDATA[
<!-- Created by Smarty! -->
{* rest of template content... *}
]]>
</programlisting>
</screen>
</example>
</sect1>
<!-- Keep this comment at the end of the file

View File

@@ -1,23 +1,28 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="advanced.features.prefilters">
<sect1 id="advanced.features.prefilters">
<title>Prefilters</title>
<para>
Template prefilters are PHP functions that your templates are ran through
before they are compiled. This is good for preprocessing your templates
to remove unwanted comments, keeping an eye on what people are putting
in their templates, etc. Prefilters can be either
<link linkend="api.register.prefilter">registered</link> or loaded from
the plugins directory by using
<link linkend="api.load.filter">load_filter()</link> function or by
setting
<link linkend="variable.autoload.filters">$autoload_filters</link> variable.
in their templates, etc.
</para>
<para>
Prefilters can be either <link
linkend="api.register.prefilter">registered</link> or loaded from
the plugins directory by using <link
linkend="api.load.filter">load_filter()</link> function or by setting
the <link linkend="variable.autoload.filters">$autoload_filters</link>
variable.
</para>
<para>
Smarty will pass the template source code as the first argument, and
expect the function to return the resulting template source code.
</para>
<example>
<title>using a template prefilter</title>
<programlisting role="php">
<programlisting role="php">
<![CDATA[
<?php
// put this in your application
@@ -30,11 +35,11 @@ function remove_dw_comments($tpl_source, &$smarty)
$smarty->register_prefilter("remove_dw_comments");
$smarty->display("index.tpl");
?>
{* Smarty template index.tpl *}
<!--# this line will get removed by the prefilter -->
]]>
</programlisting>
</programlisting>
<para>
This will remove all the comments in the template source.
</para>
</example>
</sect1>
<!-- Keep this comment at the end of the file