*** empty log message ***

This commit is contained in:
andrey
2002-02-26 22:31:18 +00:00
parent 629a7a5069
commit 279acbf01b
4 changed files with 230 additions and 167 deletions

View File

@@ -88,7 +88,7 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
If a variable is used frequently throughout your templates, applying
the default modifier every time it is mentioned can get a bit ugly. You
can remedy this by assigning the variable its default value with the
<link linkend="language.functions.assign">assign</link> function.
<link linkend="language.function.assign">assign</link> function.
</para>
<example>
<title>Assigning a template variable its default value</title>

View File

@@ -1,24 +1,29 @@
<part>
<title>Smarty For Template Designers</title>
<part>
<title>Smarty For Template Designers</title>
<chapter id="language">
<title>Template Language</title>
<para>
The templates are the heart of Smarty. These are the files that the designers
The templates are the language of Smarty. These are the files that the designers
work with. They're basically pages made up of static content interspersed with
template markup tags. These tags are placeholders for variables or blocks of logic.
</para>
<sect1 id="language.basic.syntax">
<title>Basic Syntax</title>
<para>
All Smarty template tags are enclosed within delimiters. By
default, these delimiters are <literal>{</literal> and
<literal>}</literal>, but they can be changed.
</para>
<para>
For these examples, we will assume that you are using the default
template tag delimiters, which are "{" and "}". In Smarty, all content
outside of delimiter tags is displayed as static content, or unchanged.
When Smarty encounters template tags {}, it attempts to interpret what is
between the tags, and displays the appropriate output in place of them.
delimiters. In Smarty, all content outside of delimiters is displayed as
static content, or unchanged. When Smarty encounters template tags, it
attempts to interpret them, and displays the appropriate output in their
place.
</para>
<sect2 id="language.basic.syntax.comments">
<sect2 id="language.syntax.comments">
<title>Comments</title>
<para>
Template comments are surrounded by asterisks, and that is surrounded
@@ -44,38 +49,19 @@
&lt;/SELECT&gt;</programlisting>
</example>
</sect2>
<sect2>
<title>Attributes</title>
<para>
Attributes to functions are much like HTML attributes. Static
values don't have to be enclosed in quotes, but it is recommended
for literal strings. If not quoted, you may use a syntax that Smarty may confuse
with another function, such as a boolean value. Variables may
also be used, and should not be in quotes.
</para>
<example>
<title>function attribute syntax</title>
<programlisting>
{include file="header.tpl"}
{include file=$includeFile}
{include file=#includeFile#}
&lt;SELECT name=company&gt;
{html_options values=$vals selected=$selected output=$output}
&lt;/SELECT&gt;</programlisting>
</example>
</sect2>
<sect2>
<title>blah</title>
<para>
Functions are processed and displayed by enclosing the function and its
attributes into delimiters like so: {funcname attr1="val" attr2="val"}
</para>
<example>
<title>function syntax</title>
<programlisting>
<sect2 id="language.syntax.functions">
<title>Functions</title>
<para>
Each Smarty tag either prints a
<link linkend="language.variables">variable</link> or invokes some sort
of function. Functions are processed and displayed by enclosing the
function and its attributes into delimiters like so: {funcname
attr1="val" attr2="val"}.
</para>
<example>
<title>function syntax</title>
<programlisting>
{config_load file="colors.conf"}
{include file="header.tpl"}
@@ -87,22 +73,51 @@
{/if}
{include file="footer.tpl"}</programlisting>
</example>
<para>
Both built-in functions and custom functions have the same syntax in
the templates. Built-in functions are the inner workings of Smarty,
such as <command>if</command>, <command>section</command> and
<command>strip</command>. They cannot be modified. Custom functions are
additional functions implemented via plugins. They can be modified to
your liking, or you can add new ones. <command>html_options</command> and
<command>html_select_date</command> are examples of custom functions.
</para>
</sect2>
<sect2 id="language.syntax.attributes">
<title>Attributes</title>
<para>
Most of the functions take attributes that specify or modify
their behavior. Attributes to Smarty functions are much like HTML
attributes. Static values don't have to be enclosed in quotes, but it
is recommended for literal strings. Variables may also be used, and
should not be in quotes.
</para>
<para>
Some attributes require boolean values (true or false). These can be
specified as either unquoted <literal>true</literal>,
<literal>on</literal>, and <literal>yes</literal>, or
<literal>false</literal>, <literal>off</literal>, and
<literal>no</literal>.
</para>
<example>
<title>function attribute syntax</title>
<programlisting>
{include file="header.tpl"}
{include file=$includeFile}
{include file=#includeFile#}
{html_select_date display_days=yes}
&lt;SELECT name=company&gt;
{html_options values=$vals selected=$selected output=$output}
&lt;/SELECT&gt;</programlisting>
</example>
<para>
Both built-in functions and custom functions have the same syntax
in the templates. Built-in functions are the inner workings of
Smarty, such as {if}, {section} and {strip}. They cannot be
modified. Custom functions are located in the Smarty.addons.class
file. They can be modified to your liking, or add new ones.
{html_options} and {html_select_date} are examples of custom
functions.
</para>
<para>
Custom functions in Smarty work much the same as the built-in functions,
except that built-in functions cannot be modified. Custom functions are
located in Smarty.addons.php, built-in functions are not.
</para>
</sect2>
</sect2>
</sect1>
<sect1 id="language.variables">
@@ -1194,14 +1209,14 @@ s m o k e r s a r e p. . .</programlisting>
</sect2>
</sect1>
<sect1 id="language.commands">
<sect1 id="language.builtin.functions">
<title>Built-in Functions</title>
<para>
Smarty comes with several built-in functions. Built-in functions
are integral to the template language. You cannot create custom
functions with the same names, nor can you modify built-in functions.
</para>
<sect2 id="builtin.functions.capture">
<sect2 id="language.function.capture">
<title>capture</title>
<para>
capture is used to collect the output of the template into a
@@ -1246,7 +1261,7 @@ s m o k e r s a r e p. . .</programlisting>
</example>
</para>
</sect2>
<sect2 id="builtin.functions.configload">
<sect2 id="language.function.config.load">
<title>config_load</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -1364,7 +1379,7 @@ s m o k e r s a r e p. . .</programlisting>
&lt;/html&gt;</programlisting>
</example>
</sect2>
<sect2 id="builtin.functions.include">
<sect2 id="language.function.include">
<title>include</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -1466,7 +1481,7 @@ s m o k e r s a r e p. . .</programlisting>
{include file="db:header.tpl"}</programlisting>
</example>
</sect2>
<sect2 id="builtin.functions.include.php">
<sect2 id="language.function.include.php">
<title>include_php</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -1557,7 +1572,7 @@ index.tpl
{/foreach}</programlisting>
</example>
</sect2>
<sect2 id="builtin.functions.insert">
<sect2 id="language.function.insert">
<title>insert</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -1673,7 +1688,7 @@ index.tpl
weather, search results, user feedback areas, etc.
</para>
</sect2>
<sect2>
<sect2 id="language.function.if">
<title>if,elseif,else</title>
<para>
if statements in Smarty have much the same flexibility as php if
@@ -1753,7 +1768,7 @@ index.tpl
{/if}</programlisting>
</example>
</sect2>
<sect2>
<sect2 id="language.function.ldelim">
<title>ldelim,rdelim</title>
<para>
ldelim and rdelim are used for displaying the literal delimiter, in
@@ -1773,7 +1788,7 @@ OUTPUT:
{funcname} is how functions look in Smarty!</programlisting>
</example>
</sect2>
<sect2 id="builtin.functions.literal">
<sect2 id="language.function.literal">
<title>literal</title>
<para>
Literal tags allow a block of data to be taken literally,
@@ -1805,7 +1820,7 @@ OUTPUT:
{/literal}</programlisting>
</example>
</sect2>
<sect2 id="builtin.functions.php">
<sect2 id="language.function.php">
<title>php</title>
<para>
php tags allow php to be embedded directly into the template. They
@@ -1824,7 +1839,7 @@ OUTPUT:
{/php}</programlisting>
</example>
</sect2>
<sect2 id="builtin.functions.section">
<sect2 id="language.function.section">
<title>section,sectionelse</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -2370,7 +2385,7 @@ e-mail: jane@mydomain.com&lt;p&gt;</programlisting>
</example>
</sect3>
</sect2>
<sect2 id="builtin.functions.foreach">
<sect2 id="language.function.foreach">
<title>foreach,foreachelse</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -2484,7 +2499,7 @@ fax: 555-3333&lt;br&gt;
cell: 760-1234&lt;br&gt;</programlisting>
</example>
</sect2>
<sect2>
<sect2 id="language.function.strip">
<title>strip</title>
<para>
Many times web designers
@@ -2531,16 +2546,16 @@ OUTPUT:
</sect2>
</sect1>
<sect1 id="language.additional.functions">
<title>Additional Functions</title>
<sect1 id="language.more.functions">
<title>Custom Functions</title>
<para>
Smarty comes with several additional functions that you can
use in the templates.
</para>
<sect2 id="language.available.functions">
<title>Available Functions</title>
<sect3 id="language.functions.assign">
<sect2 id="language.custom.functions">
<title>Additional Functions</title>
<sect3 id="language.function.assign">
<title>assign</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -2595,7 +2610,7 @@ OUTPUT:
The value of $name is Bob.</programlisting>
</example>
</sect3>
<sect3>
<sect3 id="language.function.counter">
<title>counter</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -2692,7 +2707,7 @@ OUTPUT:
8&lt;br&gt;</programlisting>
</example>
</sect3>
<sect3>
<sect3 id="language.function.fetch">
<title>fetch</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -2771,7 +2786,7 @@ OUTPUT:
{/if}</programlisting>
</example>
</sect3>
<sect3 id="language.functions.html.options">
<sect3 id="language.function.html.options">
<title>html_options</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -2861,7 +2876,7 @@ OUTPUT:
&lt;/select&gt;</programlisting>
</example>
</sect3>
<sect3 id="language.functions.html.select.date">
<sect3 id="language.function.html.select.date">
<title>html_select_date</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -3141,7 +3156,7 @@ OUTPUT:
&lt;/select&gt;</programlisting>
</example>
</sect3>
<sect3 id="language.functions.html.select.time">
<sect3 id="language.function.html.select.time">
<title>html_select_time</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -3402,7 +3417,7 @@ OUTPUT:
&lt;/select&gt;</programlisting>
</example>
</sect3>
<sect3 id="language.functions.math">
<sect3 id="language.function.math">
<title>math</title>
<informaltable frame=all>
<tgroup cols=5>
@@ -3516,14 +3531,14 @@ OUTPUT:
9.44</programlisting>
</example>
</sect3>
<sect3 id="language.functions.popup.init">
<sect3 id="language.function.popup.init">
<title>popup_init</title>
<para>
popup is an integration of overLib, a library used for popup
windows. These are used for context sensitive information, such as
help windows or tooltips. popup_init must be called once at the
top of any page you plan on using the <link
linkend="language.functions.popup">popup</link> function. overLib
linkend="language.function.popup">popup</link> function. overLib
was written by Erik Bosrup, and the homepage is located at
http://www.bosrup.com/web/overlib/.
</para>
@@ -3531,7 +3546,7 @@ OUTPUT:
This was added to Smarty 1.4.4.
</para>
</sect3>
<sect3 id="language.functions.popup">
<sect3 id="language.function.popup">
<title>popup</title>
<informaltable frame=all>
<tgroup cols=5>

View File

@@ -1,5 +1,6 @@
<part id="getting.started">
<title>Getting Started</title>
<part id="getting.started">
<title>Getting Started</title>
<chapter id="overview">
<title>Overview</title>
<sect1 id="what.is.smarty">
@@ -95,67 +96,67 @@
</chapter>
<chapter id="installation">
<title>Installation</title>
<title>Installation</title>
<sect1 id="installation.requirements">
<title>Requirements</title>
<para>
Smarty requires PHP 4.0.4pl1 or later. See the
<link linkend="bugs">BUGS</link> section for caveats.
</para>
</sect1>
<sect1 id="installation.requirements">
<title>Requirements</title>
<para>
Smarty requires PHP 4.0.4pl1 or later. See the
<link linkend="bugs">BUGS</link> section for caveats.
</para>
</sect1>
<sect1 id="installation.smarty">
<title>Installing Smarty</title>
<para>
Installing Smarty is fairly straightforward, there are a few things to
be aware of. Smarty creates PHP scripts from the templates. This
usually means allowing user "nobody" (or whomever the web server runs
as) to have permission to write the files. Each installation of a
Smarty application minimally needs a templates directory and a compiled
templates directory. If you use configuration files you will also need
a directory for those. By default these are named "templates",
"templates_c" and "configs" respectively. If you plan on using caching,
you will need to create a "cache" directory, also with permission to
write files.
</para>
<para>
TECHNICAL NOTE: You can get around the need to allow the web server
user write access to compile templates. Smarty needs to compile the
templates only once. This can be done from the command line, using the
CGI version of PHP. example: "php -q index.php". Once the templates are
compiled, they should run fine from the web environment. If you change
a template, you must recompile from the command line again. If you do
not have the CGI version of PHP available and you are concerned about
world-writable directory access, you can chmod 777 the compile_dir, let
the templates compile once as the web server user, then change the
directory mode to 755. If you are using the caching feature of Smarty,
the cache directory must always have write access for the web server
user.
</para>
<para>
TECHNICAL NOTE: If you do not have access to the php.ini file, you can
change non-server settings (such as your include_path) with the
ini_set() command (available in PHP 4.0.4 or later.) example:
ini_set("include_path",".:/usr/local/lib/php");
</para>
<para>
Copy the Smarty.class.php, Smarty.addons.php and Config_File.class.php
scripts to a directory that is in your PHP include_path. NOTE: PHP will
try to create a directory alongside the executing script called
"templates_c". Be sure that directory permissions allow this to happen.
You will see PHP error messages if this fails. You can also create the
directory yourself before hand, and change the file ownership
accordingly. See below.
</para>
<para>
TECHNICAL NOTE: If you don't want to use include_path to find the
Smarty files, you can set the SMARTY_DIR constant to the full path to
your Smarty library files. Be sure the path ends with a slash!
</para>
<example>
<title>Example of installing Smarty</title>
<screen>
<sect1 id="installing.smarty">
<title>Installing Smarty</title>
<para>
Installing Smarty is fairly straightforward, there are a few things to
be aware of. Smarty creates PHP scripts from the templates. This
usually means allowing user "nobody" (or whomever the web server runs
as) to have permission to write the files. Each installation of a
Smarty application minimally needs a templates directory and a compiled
templates directory. If you use configuration files you will also need
a directory for those. By default these are named "templates",
"templates_c" and "configs" respectively. If you plan on using caching,
you will need to create a "cache" directory, also with permission to
write files.
</para>
<para>
TECHNICAL NOTE: You can get around the need to allow the web server
user write access to compile templates. Smarty needs to compile the
templates only once. This can be done from the command line, using the
CGI version of PHP. example: "php -q index.php". Once the templates are
compiled, they should run fine from the web environment. If you change
a template, you must recompile from the command line again. If you do
not have the CGI version of PHP available and you are concerned about
world-writable directory access, you can chmod 777 the compile_dir, let
the templates compile once as the web server user, then change the
directory mode to 755. If you are using the caching feature of Smarty,
the cache directory must always have write access for the web server
user.
</para>
<para>
TECHNICAL NOTE: If you do not have access to the php.ini file, you can
change non-server settings (such as your include_path) with the
ini_set() command (available in PHP 4.0.4 or later.) example:
ini_set("include_path",".:/usr/local/lib/php");
</para>
<para>
Copy the Smarty.class.php, Smarty.addons.php and Config_File.class.php
scripts to a directory that is in your PHP include_path. NOTE: PHP will
try to create a directory alongside the executing script called
"templates_c". Be sure that directory permissions allow this to happen.
You will see PHP error messages if this fails. You can also create the
directory yourself before hand, and change the file ownership
accordingly. See below.
</para>
<para>
TECHNICAL NOTE: If you don't want to use include_path to find the
Smarty files, you can set the SMARTY_DIR constant to the full path to
your Smarty library files. Be sure the path ends with a slash!
</para>
<example>
<title>Example of installing Smarty</title>
<screen>
# be sure you are in the web server document tree
# this assumes your web server runs as user "nobody"
# and you are in a un*x environment
@@ -167,32 +168,33 @@ chmod 700 templates_c
mkdir cache
chown nobody:nobody cache
chmod 700 cache</screen>
</example>
<para>
Next, try running the index.php script from your web browser.
</para>
</sect1>
<sect1 id="smarty.constants">
<title>Constants</title>
<para></para>
</example>
<para>
Next, try running the index.php script from your web browser.
</para>
</sect1>
<sect2 id="constant.smarty.dir">
<title>SMARTY_DIR</title>
<para>
This should be the full system path to the location of the Smarty
class files. If this is not defined, then Smarty will attempt to
determine the appropriate value automatically. If defined, the path
must end with a slash.
</para>
<example>
<title>SMARTY_DIR</title>
<programlisting>
<sect1 id="smarty.constants">
<title>Constants</title>
<para></para>
<sect2 id="constant.smarty.dir">
<title>SMARTY_DIR</title>
<para>
This should be the full system path to the location of the Smarty
class files. If this is not defined, then Smarty will attempt to
determine the appropriate value automatically. If defined, the path
must end with a slash.
</para>
<example>
<title>SMARTY_DIR</title>
<programlisting>
// set path to Smarty directory
define("SMARTY_DIR","/usr/local/lib/php/Smarty/");
require_once(SMARTY_DIR."Smarty.class.php");</programlisting>
</example>
</sect2>
</sect1>
</chapter>
</part>
</example>
</sect2>
</sect1>
</chapter>
</part>

View File

@@ -181,6 +181,52 @@
)
(literal "()"))))))))
(element command
(let* ((command-name (data (current-node)))
(linkend
(string-append
"language.function."
(string-replace
(string-replace command-name "_" ".")
"::" ".")))
(target (element-with-id linkend))
(parent-gi (gi (parent))))
(cond
;; function names should be plain in FUNCDEF
((equal? parent-gi "funcdef")
(process-children))
;; if a valid ID for the target function is not found, or if the
;; FUNCTION tag is within the definition of the same function,
;; make it bold, add (), but don't make a link
((or (node-list-empty? target)
(equal? (case-fold-down
(data (node-list-first
(select-elements
(node-list-first
(children
(select-elements
(children
(ancestor-member (parent) (list "refentry")))
"refnamediv")))
"refname"))))
command-name))
($bold-seq$
(make sequence
(literal "{")
(process-children)
(literal "}"))))
;; else make a link to the function and add ()
(else
(make element gi: "A"
attributes: (list
(list "HREF" (href-to target)))
($bold-seq$
(make sequence
(literal "{")
(process-children)
(literal "}"))))))))
(element classname
(let* ((class-name (data (current-node)))