mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
update documenatation, template examples
This commit is contained in:
7
NEWS
7
NEWS
@@ -1,12 +1,13 @@
|
|||||||
|
- numerous documentation updates. (Monte)
|
||||||
|
- added ENT_QUOTES to escapement of html (Monte, Sam Beckwith)
|
||||||
- implemented access to request variables via auto-assigned $smarty
|
- implemented access to request variables via auto-assigned $smarty
|
||||||
template variable. (Andrei)
|
template variable. (Andrei)
|
||||||
- fixed a bug with parsing function arguments inside {if} tags if a comma
|
- fixed a bug with parsing function arguments inside {if} tags if a comma
|
||||||
was present. (Andrei)
|
was present. (Andrei)
|
||||||
- updated debug console with config file vars. (Monte)
|
- updated debug console with config file vars. (Monte)
|
||||||
- numerous documentation updates. (Monte)
|
- added SMARTY_DIR constant as an alternative to relying on include_path
|
||||||
- added SMARTY_DIR constant which indicating location of Smarty files.
|
|
||||||
(Monte)
|
(Monte)
|
||||||
- added popup_init and popup functions. (Monte)
|
- added popup_init and popup functions, (requires overlib.js) (Monte)
|
||||||
- updated debug console with config file vars. (Monte)
|
- updated debug console with config file vars. (Monte)
|
||||||
- added debugging url control. (Monte)
|
- added debugging url control. (Monte)
|
||||||
- added 'quotes' type to escape modifier. (Monte, Mike Krus)
|
- added 'quotes' type to escape modifier. (Monte, Mike Krus)
|
||||||
|
@@ -83,7 +83,7 @@ function smarty_mod_escape($string, $esc_type = 'html')
|
|||||||
{
|
{
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
return htmlspecialchars($string);
|
return htmlspecialchars($string, ENT_QUOTES);
|
||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
return urlencode($string);
|
return urlencode($string);
|
||||||
|
@@ -514,7 +514,6 @@ class Smarty_Compiler extends Smarty {
|
|||||||
)/x', $tag_args, $match);
|
)/x', $tag_args, $match);
|
||||||
$tokens = $match[0];
|
$tokens = $match[0];
|
||||||
|
|
||||||
var_dump($tokens);
|
|
||||||
$this->_parse_vars_props($tokens);
|
$this->_parse_vars_props($tokens);
|
||||||
|
|
||||||
$is_arg_stack = array();
|
$is_arg_stack = array();
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
{tooltip_init}
|
{popup_init}
|
||||||
{tooltip_element id="help" width="200" text="This is an example of a tooltip. Tooltips are handy for context sensitive information."}
|
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY bgcolor="#ffffff">
|
<BODY bgcolor="#ffffff">
|
||||||
<TITLE>{$title} - {$Name}</TITLE>
|
<TITLE>{$title} - {$Name}</TITLE>
|
||||||
|
@@ -9,14 +9,21 @@
|
|||||||
Title: {#title#|capitalize}
|
Title: {#title#|capitalize}
|
||||||
{if #bold#}</b>{/if}
|
{if #bold#}</b>{/if}
|
||||||
|
|
||||||
Tooltip example: Move your mouse over the <A HREF="" {tooltip id="help"} onclick="return false;">Help</A> link to see a tooltip pop-up.
|
Tooltip example: Move your mouse over the <A HREF="" {popup sticky=true caption="Smarty pop-up text" delay=400 text="This is an example of a tooltip. Tooltips are handy for context sensitive information, and extremely easy to add to your templates with Smarty and the integration of <a href='http://www.bosrup.com/web/overlib/'>overLIB</a> by Erik Bosrup"} onclick="return false;">Help</A> link to see an example of a tooltip using Smarty's popup function.
|
||||||
|
|
||||||
the value of $SCRIPT_NAME is {$SCRIPT_NAME}
|
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||||
|
|
||||||
{* A simple variable test. print $Name in uppercase *}
|
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||||
hello, my name is {$Name}
|
|
||||||
|
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||||
|
|
||||||
|
variable modifier example of {ldelim}$Name|upper{rdelim}
|
||||||
|
|
||||||
|
<b>{$Name|upper}</b>
|
||||||
|
|
||||||
|
|
||||||
|
An example of a section loop:
|
||||||
|
|
||||||
My interests are:
|
|
||||||
{section name=outer loop=$FirstName}
|
{section name=outer loop=$FirstName}
|
||||||
{if %outer.index% is odd by 2}
|
{if %outer.index% is odd by 2}
|
||||||
{%outer.rownum%} . {$FirstName[outer]} {$LastName[outer]}
|
{%outer.rownum%} . {$FirstName[outer]} {$LastName[outer]}
|
||||||
@@ -27,7 +34,8 @@ My interests are:
|
|||||||
none
|
none
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
testing section looped key values<br>
|
An example of section looped key values:
|
||||||
|
|
||||||
{section name=sec1 loop=$contacts}
|
{section name=sec1 loop=$contacts}
|
||||||
phone: {$contacts[sec1].phone}<br>
|
phone: {$contacts[sec1].phone}<br>
|
||||||
fax: {$contacts[sec1].fax}<br>
|
fax: {$contacts[sec1].fax}<br>
|
||||||
|
441
docs.sgml
441
docs.sgml
@@ -249,6 +249,17 @@ chmod 700 cache
|
|||||||
used to locate the files. If defined, the path must end with a
|
used to locate the files. If defined, the path must end with a
|
||||||
slash.
|
slash.
|
||||||
</para>
|
</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>
|
</sect2>
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1>
|
<sect1>
|
||||||
@@ -1400,18 +1411,12 @@ $smarty->display("index.tpl");
|
|||||||
between the tags, and displays the appropriate output in place of them.
|
between the tags, and displays the appropriate output in place of them.
|
||||||
</para>
|
</para>
|
||||||
<sect2>
|
<sect2>
|
||||||
<title>Variables</title>
|
<title>Variables assigned from PHP</title>
|
||||||
<para>
|
<para>
|
||||||
There are three basic types of variables in Smarty, each with their
|
Variables that are assigned from PHP are referenced by preceding
|
||||||
own unique syntax.
|
them with a dollar sign ($) and enclosing the variable in delimiters
|
||||||
|
like so: $varname
|
||||||
</para>
|
</para>
|
||||||
<sect3>
|
|
||||||
<title>Variables assigned from PHP</title>
|
|
||||||
<para>
|
|
||||||
Variables that are assigned from PHP are referenced by preceding
|
|
||||||
them with a dollar sign ($) and enclosing the variable in delimiters
|
|
||||||
like so: $varname
|
|
||||||
</para>
|
|
||||||
<example>
|
<example>
|
||||||
|
|
||||||
<title>displaying assigned variables</title>
|
<title>displaying assigned variables</title>
|
||||||
@@ -1428,15 +1433,14 @@ Hello Doug, glad to see you could make it.
|
|||||||
Your last login was on January 11th, 2001.
|
Your last login was on January 11th, 2001.
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
|
<sect2>
|
||||||
<sect3>
|
<title>Associative arrays</title>
|
||||||
<title>Associative arrays</title>
|
<para>
|
||||||
<para>
|
You can also reference associative array variables that are
|
||||||
You can also reference associative array variables that are
|
assigned from PHP by specifying the key after the '.' (period)
|
||||||
assigned from PHP by specifying the key after the '.' (period)
|
symbol.
|
||||||
symbol.
|
</para>
|
||||||
</para>
|
|
||||||
<example>
|
<example>
|
||||||
<title>displaying assigned associative array variables</title>
|
<title>displaying assigned associative array variables</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@@ -1458,14 +1462,13 @@ zaphod@slartibartfast.com<br>
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
|
<sect2>
|
||||||
<sect3>
|
<title>Objects</title>
|
||||||
<title>Objects</title>
|
<para>
|
||||||
<para>
|
Properties of objects assigned from PHP can be referenced
|
||||||
Properties of objects assigned from PHP can be referenced
|
by specifying the property name after the '->' symbol.
|
||||||
by specifying the property name after the '->' symbol.
|
</para>
|
||||||
</para>
|
|
||||||
<example>
|
<example>
|
||||||
<title>displaying object properties</title>
|
<title>displaying object properties</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@@ -1480,15 +1483,15 @@ email: zaphod@slartibartfast.com<br>
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
|
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>Variables passed from config files</title>
|
<title>Variables passed from config files</title>
|
||||||
<para>
|
<para>
|
||||||
Variables that are passed in from config files are displayed by enclosing
|
Variables that are passed in from config files are displayed by enclosing
|
||||||
them with hash marks (#) and enclosing the variable in delimiters
|
them with hash marks (#) and enclosing the variable in delimiters
|
||||||
like so: {#varname#}
|
like so: {#varname#}
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
|
|
||||||
|
|
||||||
@@ -1499,33 +1502,71 @@ email: zaphod@slartibartfast.com<br>
|
|||||||
<title>{#pageTitle#}</title>
|
<title>{#pageTitle#}</title>
|
||||||
<body bgcolor="{#bodyBgColor#}">
|
<body bgcolor="{#bodyBgColor#}">
|
||||||
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
||||||
<tr bgcolor="{#rowBgColor#}">
|
<tr bgcolor="{#rowBgColor#}">
|
||||||
<td>First</td>
|
<td>First</td>
|
||||||
<td>Last</td>
|
<td>Last</td>
|
||||||
<td>Address</td>
|
<td>Address</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
<para>
|
<para>
|
||||||
Config file variables cannot be displayed until
|
Config file variables cannot be displayed until
|
||||||
after they are loaded in from a config file. This procedure is
|
after they are loaded in from a config file. This procedure is
|
||||||
explained later in this document under
|
explained later in this document under
|
||||||
<link linkend="builtin.functions.configload">config_load</link>.
|
<link linkend="builtin.functions.configload">config_load</link>.
|
||||||
</para>
|
</para>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>Variables internal to template</title>
|
<title>Variables internal to template</title>
|
||||||
<para>
|
<para>
|
||||||
Variables that are internal to the templates are displayed by enclosing
|
Variables that are internal to the templates are displayed by enclosing
|
||||||
them with percent signs (%) and enclosing the variable in delimiters
|
them with percent signs (%) and enclosing the variable in delimiters
|
||||||
like so: {%varname%} So far, section properties are the only internal
|
like so: {%varname%} So far, section properties are the only internal
|
||||||
variables used in Smarty, which can be found later in this document under
|
variables used in Smarty, which can be found later in this document under
|
||||||
<link linkend="builtin.functions.section">section</link>.
|
<link linkend="builtin.functions.section">section</link>.
|
||||||
</para>
|
</para>
|
||||||
</sect3>
|
</sect2>
|
||||||
|
<sect2>
|
||||||
|
<title>Request Variables</title>
|
||||||
|
<para>
|
||||||
|
You can access request variables in Smarty via the special variable
|
||||||
|
{$smarty}. You can access get, post, cookies, server, env and
|
||||||
|
session variables with the syntax in the following examples.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Request variable access was added to Smarty 1.4.4.
|
||||||
|
</para>
|
||||||
|
<example>
|
||||||
|
|
||||||
|
<title>displaying request variables</title>
|
||||||
|
<programlisting>
|
||||||
|
|
||||||
|
{* display the variable "page" given in the URL, or from a form using the GET method *}
|
||||||
|
{$smarty.get.page}
|
||||||
|
|
||||||
|
{* display the variable "page" from a form using the POST method *}
|
||||||
|
{$smarty.post.page}
|
||||||
|
|
||||||
|
{* display the value of the cookie "username" *}
|
||||||
|
{$smarty.cookies.username}
|
||||||
|
|
||||||
|
{* display the server variable "SERVER_NAME" *}
|
||||||
|
{$smarty.server.SERVER_NAME}
|
||||||
|
|
||||||
|
{* display the system environment variable "PATH" *}
|
||||||
|
{$smarty.env.PATH}
|
||||||
|
|
||||||
|
{* display the php session variable "id" *}
|
||||||
|
{$smarty.session.id}
|
||||||
|
|
||||||
|
{* display the variable "username" from merged get/post/cookies/server/env *}
|
||||||
|
{$smarty.request.username}
|
||||||
|
|
||||||
|
</programlisting>
|
||||||
|
</example>
|
||||||
</sect2>
|
</sect2>
|
||||||
<sect2>
|
<sect2>
|
||||||
<title>Functions</title>
|
<title>Functions</title>
|
||||||
@@ -2402,23 +2443,24 @@ e-mail: jane@mydomain.com<p>
|
|||||||
These are indicated by percent signs around the variable name, like so:
|
These are indicated by percent signs around the variable name, like so:
|
||||||
%sectionname.varname%
|
%sectionname.varname%
|
||||||
</para>
|
</para>
|
||||||
<sect3>
|
</sect2>
|
||||||
<title>index</title>
|
<sect2>
|
||||||
<para>
|
<title>index</title>
|
||||||
index is used to display the current loop index, starting with zero
|
<para>
|
||||||
(or the start attribute if given), and incrementing by one (or by
|
index is used to display the current loop index, starting with zero
|
||||||
the step attribute if given.)
|
(or the start attribute if given), and incrementing by one (or by
|
||||||
</para>
|
the step attribute if given.)
|
||||||
<para>
|
</para>
|
||||||
TECHNICAL NOTE: If the step and start section properties are not
|
<para>
|
||||||
modified, then this works the same as the iteration section
|
TECHNICAL NOTE: If the step and start section properties are not
|
||||||
property.
|
modified, then this works the same as the iteration section
|
||||||
</para>
|
property.
|
||||||
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property index</title>
|
<title>section property index</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{%customer.index%} id: {$custid[customer]}<br>
|
{%customer.index%} id: {$custid[customer]}<br>
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
@@ -2430,90 +2472,90 @@ OUTPUT:
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>index_prev</title>
|
<title>index_prev</title>
|
||||||
<para>
|
<para>
|
||||||
index_prev is used to display the previous loop index.
|
index_prev is used to display the previous loop index.
|
||||||
on the first loop, this is set to -1.
|
on the first loop, this is set to -1.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property index_prev</title>
|
<title>section property index_prev</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{%customer.index%} id: {$custid[customer]}<br>
|
{%customer.index%} id: {$custid[customer]}<br>
|
||||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||||
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
||||||
The customer id changed<br>
|
The customer id changed<br>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
|
|
||||||
0 id: 1000<br>
|
0 id: 1000<br>
|
||||||
The customer id changed<br>
|
The customer id changed<br>
|
||||||
1 id: 1001<br>
|
1 id: 1001<br>
|
||||||
The customer id changed<br>
|
The customer id changed<br>
|
||||||
2 id: 1002<br>
|
2 id: 1002<br>
|
||||||
The customer id changed<br>
|
The customer id changed<br>
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>index_next</title>
|
<title>index_next</title>
|
||||||
<para>
|
<para>
|
||||||
index_next is used to display the next loop index. On the last
|
index_next is used to display the next loop index. On the last
|
||||||
loop, this is still one more than the current index (respecting the
|
loop, this is still one more than the current index (respecting the
|
||||||
setting of the step attribute, if given.)
|
setting of the step attribute, if given.)
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property index_next</title>
|
<title>section property index_next</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{%customer.index%} id: {$custid[customer]}<br>
|
{%customer.index%} id: {$custid[customer]}<br>
|
||||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
|
|
||||||
0 id: 1000<br>
|
0 id: 1000<br>
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
1 id: 1001<br>
|
1 id: 1001<br>
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
2 id: 1002<br>
|
2 id: 1002<br>
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>iteration</title>
|
<title>iteration</title>
|
||||||
<para>
|
<para>
|
||||||
iteration is used to display the current loop iteration.
|
iteration is used to display the current loop iteration.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
NOTE: This is not affected by the section properties start, step and
|
NOTE: This is not affected by the section properties start, step and
|
||||||
max, unlike the index property.
|
max, unlike the index property.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
This was added to Smarty 1.4.4.
|
This was added to Smarty 1.4.4.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property iteration</title>
|
<title>section property iteration</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid start=5 step=2}
|
{section name=customer loop=$custid start=5 step=2}
|
||||||
current loop iteration: {%customer.iteration%}<br>
|
current loop iteration: {%customer.iteration%}<br>
|
||||||
{%customer.index%} id: {$custid[customer]}<br>
|
{%customer.index%} id: {$custid[customer]}<br>
|
||||||
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
||||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
@@ -2521,96 +2563,96 @@ OUTPUT:
|
|||||||
|
|
||||||
current loop iteration: 1
|
current loop iteration: 1
|
||||||
5 id: 1000<br>
|
5 id: 1000<br>
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
current loop iteration: 2
|
current loop iteration: 2
|
||||||
7 id: 1001<br>
|
7 id: 1001<br>
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
current loop iteration: 3
|
current loop iteration: 3
|
||||||
9 id: 1002<br>
|
9 id: 1002<br>
|
||||||
The customer id will change<br>
|
The customer id will change<br>
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>first</title>
|
<title>first</title>
|
||||||
<para>
|
<para>
|
||||||
first is set to true if the current section iteration is the first
|
first is set to true if the current section iteration is the first
|
||||||
one.
|
one.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property first</title>
|
<title>section property first</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{if %customer.first%}
|
{if %customer.first%}
|
||||||
<table>
|
<table>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<tr><td>{%customer.index%} id:
|
<tr><td>{%customer.index%} id:
|
||||||
{$custid[customer]}</td></tr>
|
{$custid[customer]}</td></tr>
|
||||||
|
|
||||||
{if %customer.last%}
|
{if %customer.last%}
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr><td>0 id: 1000</td></tr>
|
<tr><td>0 id: 1000</td></tr>
|
||||||
<tr><td>1 id: 1001</td></tr>
|
<tr><td>1 id: 1001</td></tr>
|
||||||
<tr><td>2 id: 1002</td></tr>
|
<tr><td>2 id: 1002</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>last</title>
|
<title>last</title>
|
||||||
<para>
|
<para>
|
||||||
last is set to true if the current section iteration is the last
|
last is set to true if the current section iteration is the last
|
||||||
one.
|
one.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property last</title>
|
<title>section property last</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{if %customer.first%}
|
{if %customer.first%}
|
||||||
<table>
|
<table>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<tr><td>{%customer.index%} id:
|
<tr><td>{%customer.index%} id:
|
||||||
{$custid[customer]}</td></tr>
|
{$custid[customer]}</td></tr>
|
||||||
|
|
||||||
{if %customer.last%}
|
{if %customer.last%}
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr><td>0 id: 1000</td></tr>
|
<tr><td>0 id: 1000</td></tr>
|
||||||
<tr><td>1 id: 1001</td></tr>
|
<tr><td>1 id: 1001</td></tr>
|
||||||
<tr><td>2 id: 1002</td></tr>
|
<tr><td>2 id: 1002</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>rownum</title>
|
<title>rownum</title>
|
||||||
<para>
|
<para>
|
||||||
rownum is used to display the current loop iteration,
|
rownum is used to display the current loop iteration,
|
||||||
starting with one.
|
starting with one.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property rownum</title>
|
<title>section property rownum</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{%customer.rownum%} id: {$custid[customer]}<br>
|
{%customer.rownum%} id: {$custid[customer]}<br>
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
|
|
||||||
@@ -2622,18 +2664,18 @@ OUTPUT:
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>loop</title>
|
<title>loop</title>
|
||||||
<para>
|
<para>
|
||||||
loop is used to display the last index number that this section
|
loop is used to display the last index number that this section
|
||||||
looped. This can be used inside or after the section.
|
looped. This can be used inside or after the section.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property index</title>
|
<title>section property index</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid}
|
{section name=customer loop=$custid}
|
||||||
{%customer.index%} id: {$custid[customer]}<br>
|
{%customer.index%} id: {$custid[customer]}<br>
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
There were {%customer.loop%} customers shown above.
|
There were {%customer.loop%} customers shown above.
|
||||||
@@ -2648,28 +2690,28 @@ There were 3 customers shown above.
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>show</title>
|
<title>show</title>
|
||||||
<para>
|
<para>
|
||||||
<emphasis>show</emphasis> is used as a parameter to section.
|
<emphasis>show</emphasis> is used as a parameter to section.
|
||||||
<emphasis>show</emphasis> is a boolean value, true or false. If
|
<emphasis>show</emphasis> is a boolean value, true or false. If
|
||||||
false, the section will not be displayed. If there is a sectionelse
|
false, the section will not be displayed. If there is a sectionelse
|
||||||
present, that will be alternately displayed.
|
present, that will be alternately displayed.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section attribute show</title>
|
<title>section attribute show</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{* $show_customer_info may have been passed from the PHP
|
{* $show_customer_info may have been passed from the PHP
|
||||||
application, to regulate whether or not this section shows *}
|
application, to regulate whether or not this section shows *}
|
||||||
{section name=customer loop=$custid show=$show_customer_info}
|
{section name=customer loop=$custid show=$show_customer_info}
|
||||||
{%customer.rownum%} id: {$custid[customer]}<br>
|
{%customer.rownum%} id: {$custid[customer]}<br>
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
{if %customer.show%}
|
{if %customer.show%}
|
||||||
the section was shown.
|
the section was shown.
|
||||||
{else}
|
{else}
|
||||||
the section was not shown.
|
the section was not shown.
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
@@ -2683,21 +2725,21 @@ the section was shown.
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
</sect2>
|
||||||
<sect3>
|
<sect2>
|
||||||
<title>total</title>
|
<title>total</title>
|
||||||
<para>
|
<para>
|
||||||
total is used to display the number of iterations that this section
|
total is used to display the number of iterations that this section
|
||||||
will loop. This can be used inside or after the section.
|
will loop. This can be used inside or after the section.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
This was added to Smarty 1.4.4.
|
This was added to Smarty 1.4.4.
|
||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<title>section property total</title>
|
<title>section property total</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
{section name=customer loop=$custid step=2}
|
{section name=customer loop=$custid step=2}
|
||||||
{%customer.index%} id: {$custid[customer]}<br>
|
{%customer.index%} id: {$custid[customer]}<br>
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
There were {%customer.total%} customers shown above.
|
There were {%customer.total%} customers shown above.
|
||||||
@@ -2712,7 +2754,6 @@ There were 3 customers shown above.
|
|||||||
|
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</sect3>
|
|
||||||
</sect2>
|
</sect2>
|
||||||
<sect2>
|
<sect2>
|
||||||
<title>strip</title>
|
<title>strip</title>
|
||||||
|
@@ -514,7 +514,6 @@ class Smarty_Compiler extends Smarty {
|
|||||||
)/x', $tag_args, $match);
|
)/x', $tag_args, $match);
|
||||||
$tokens = $match[0];
|
$tokens = $match[0];
|
||||||
|
|
||||||
var_dump($tokens);
|
|
||||||
$this->_parse_vars_props($tokens);
|
$this->_parse_vars_props($tokens);
|
||||||
|
|
||||||
$is_arg_stack = array();
|
$is_arg_stack = array();
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
{tooltip_init}
|
{popup_init}
|
||||||
{tooltip_element id="help" width="200" text="This is an example of a tooltip. Tooltips are handy for context sensitive information."}
|
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY bgcolor="#ffffff">
|
<BODY bgcolor="#ffffff">
|
||||||
<TITLE>{$title} - {$Name}</TITLE>
|
<TITLE>{$title} - {$Name}</TITLE>
|
||||||
|
@@ -9,14 +9,21 @@
|
|||||||
Title: {#title#|capitalize}
|
Title: {#title#|capitalize}
|
||||||
{if #bold#}</b>{/if}
|
{if #bold#}</b>{/if}
|
||||||
|
|
||||||
Tooltip example: Move your mouse over the <A HREF="" {tooltip id="help"} onclick="return false;">Help</A> link to see a tooltip pop-up.
|
Tooltip example: Move your mouse over the <A HREF="" {popup sticky=true caption="Smarty pop-up text" delay=400 text="This is an example of a tooltip. Tooltips are handy for context sensitive information, and extremely easy to add to your templates with Smarty and the integration of <a href='http://www.bosrup.com/web/overlib/'>overLIB</a> by Erik Bosrup"} onclick="return false;">Help</A> link to see an example of a tooltip using Smarty's popup function.
|
||||||
|
|
||||||
the value of $SCRIPT_NAME is {$SCRIPT_NAME}
|
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
|
||||||
|
|
||||||
{* A simple variable test. print $Name in uppercase *}
|
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
|
||||||
hello, my name is {$Name}
|
|
||||||
|
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
|
||||||
|
|
||||||
|
variable modifier example of {ldelim}$Name|upper{rdelim}
|
||||||
|
|
||||||
|
<b>{$Name|upper}</b>
|
||||||
|
|
||||||
|
|
||||||
|
An example of a section loop:
|
||||||
|
|
||||||
My interests are:
|
|
||||||
{section name=outer loop=$FirstName}
|
{section name=outer loop=$FirstName}
|
||||||
{if %outer.index% is odd by 2}
|
{if %outer.index% is odd by 2}
|
||||||
{%outer.rownum%} . {$FirstName[outer]} {$LastName[outer]}
|
{%outer.rownum%} . {$FirstName[outer]} {$LastName[outer]}
|
||||||
@@ -27,7 +34,8 @@ My interests are:
|
|||||||
none
|
none
|
||||||
{/section}
|
{/section}
|
||||||
|
|
||||||
testing section looped key values<br>
|
An example of section looped key values:
|
||||||
|
|
||||||
{section name=sec1 loop=$contacts}
|
{section name=sec1 loop=$contacts}
|
||||||
phone: {$contacts[sec1].phone}<br>
|
phone: {$contacts[sec1].phone}<br>
|
||||||
fax: {$contacts[sec1].fax}<br>
|
fax: {$contacts[sec1].fax}<br>
|
||||||
|
Reference in New Issue
Block a user