PHP - Smarty模板引擎 - Manual手册 - 中文版 - Chapter 8. Custom Functions第8章自定义函数 - {assign}用于在模板执行过程中设置模板变量
{assign}
{assign} is used for assigning template variables during the execution of a template.
{assign}用于在模板执行过程中设置模板变量.
Attribute Name
属性名
Type
类型
Required
必填
Default
默认值
Description
描述
var string
字符串
Yes
是
n/a
无
The name of the variable being assigned
被设置的变量的名称
value string
字符串
Yes
是
n/a
无
The value being assigned
被设置的值
Example 8-1. {assign}
示例 8阅读全文>
发表于 @ 2008年07月11日 16:56:00|评论(loading...)|收藏
PHP - Smarty模板引擎 - Manual手册 - 翻译中 - 第13章 Smarty类方法 - register_function()动态注册模板函数插件
register_function()
register_function() -- dynamically register template function plugins
register_function() -- 动态注册模板函数插件
Description
描述
void register_function ( string name, mixed impl [, bool cacheable [, mixed cache_attrs]])
Pass in the template function name, followed by the PHP function name that implements it.
The php-function callback function can be either:
*
A string containi阅读全文>
发表于 @ 2008年07月10日 14:40:00|评论(loading...)|收藏
PHP - Smarty模板引擎 - Manual手册 - Chapter 7. Built-in Functions第7章 内建函数 - {config_load}用于从一个配置文件加载配置变量到模板中
{config_load}
{config_load} is used for loading config #variables# from a configuration file into the template.
Attribute Name Type Required Default Description
file string Yes n/a The name of the config file to include
section string No n/a The name of the section to load
scope string no local How the scope of the loaded variables are treated, which must be one of local, parent or glob阅读全文>
发表于 @ 2008年07月10日 14:19:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 3. Basic Syntax第3章 基础语法 - Comments注释
Comments
注释
Template comments are surrounded by asterisks, and that is surrounded by the delimiter tags like so:
模板注释被星号包围,然后被分隔标记包围,例如:
{* this is a comment *}
Smarty comments are NOT displayed in the final output of the template, unlike . These are useful for making internal notes in the templates which no one will see ;-)
在最终模板的输出中不显示Smarty注释,与不同,非常适合作为模板的内部注释,而不会被看到。
Example 3-1. Comments within a template
阅读全文>
发表于 @ 2007年12月30日 20:55:00|评论(loading...)|收藏
Smarty - Manua手册 - Chapter 7. Built-in Functions第7章 内建函数 - {foreach},{foreachelse}用于像访问序数数组一样访问关联数组
{foreach},{foreachelse}
{foreach} is used to loop over an associative array as well a numerically-indexed array, unlike {section} which is for looping over numerically-indexed arrays only. The syntax for {foreach} is much easier than {section}, but as a tradeoff it can only be used for a single array. Every {foreach} tag must be paired with a closing {/foreach} tag.
{foreach} 用于像循环访问一个数字索引阅读全文>
发表于 @ 2007年12月30日 20:26:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 7. Built-in Functions内建函数 - {strip}在显示之前删除每行前后多余的空格和回车字符
{strip}
Many times web designers run into the issue where white space and carriage returns affect the output of the rendered HTML (browser "features"), so you must run all your tags together in the template to get the desired results. This usually ends up in unreadable or unmanageable templates.
很多时候,网页设计者纠缠于空白和回车换行影响HTML输出效果(浏览器的“特性”)的问题,为了实现所需的结果不得不在模板中把所有的标记挤在一起。这又导致模板不便于阅读和管理。
Anything within {str阅读全文>
发表于 @ 2007年12月24日 17:11:00|评论(loading...)|收藏
Smarty - 下载
Download
下载
Note: The Smarty Template Engine requires PHP Version 4.0.6 or later.
注意:Smarty模板引擎要求PHP 4.0.6或更高版本。
Latest Stable Release
最新稳定版本
* Smarty 2.6.18 Source March 7th, 2007
Previous Releases
过去的版本
* Smarty 2.6.17 Source March 5th, 2007
* Smarty 2.6.16 Source Dec 1st, 2006
* Smarty 2.6.15 Source Nov 30th, 2006
* Smarty 2.6.14 Source May 28th, 2006
* Smarty 2.6.13 Source March 9th, 2006
* Smarty 2.6.12 Source January 18th, 2006
阅读全文>
发表于 @ 2007年12月24日 16:51:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 13. Smarty Class Methods第13章 Smarty类方法 - assign_by_ref()按引用赋值
assign_by_ref()
assign_by_ref() -- assign values by reference
按引用赋值
Description
描述
void assign_by_ref ( string varname, mixed var)
This is used to assign() values to the templates by reference instead of making a copy. See the PHP manual on variable referencing for an explanation.
本函数用于通过引用而不是复制向模板assign()值,参考PHP手册中变量引用获得更详细的说明。
Technical Note: This is used to assign values to the templa阅读全文>
发表于 @ 2007年12月24日 16:29:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 3. Basic Syntax第3章 基础语法 - Math数学运算
Math
数学运算
Math can be applied directly to variable values.
变量值可以使用使用数学运算。
Example 3-7. math examples
例 307. 数学运算示例
{$foo+1}
{$foo*$bar}
{* some more complicated examples *}
{$foo->bar-$bar[1]*$baz->foo->bar()-3*7}
{if ($foo+$bar.test%$baz*134232+10+$b+10)}
{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}
{assign var="foo" value="`$foo+$bar`"}
See also the {math} function for complex equation阅读全文>
发表于 @ 2007年12月24日 16:17:00|评论(loading...)|收藏
Smarty - 官方网站
[Smarty - 官方网站]
http://smarty.php.net/
[Smarty - 下载地址]
当前版本 2.6.18, http://smarty.php.net/do_download.php?download_file=Smarty-2.6.18.tar.gz
全部列表, http://smarty.php.net/download.php
[Smarty - 相关论坛]
http://php.board.newsmth.net/
http://forum.csdn.net/SList/PHP/
http://www.phpinsider.com/smarty-forum/
http://news.php.net/php.smarty.general
http://news.php.net/php.smarty.dev
http://news.php.net/php.smarty.cvs
[Smarty - 关键词]
smarty
[Smarty - Manual手册]
借助cycle实现循环阅读全文>
发表于 @ 2007年12月24日 16:06:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 8. Custom Functions第8章 自定义函数 - {counter}计数器
{counter}
{counter} is used to print out a count. {counter} will remember the count on each iteration. You can adjust the number, the interval and the direction of the count, as well as determine whether or not to print the value. You can run multiple counters concurrently by supplying a unique name for each one. If you do not supply a name, the name "default" will be used.
If you supply the assign attribute, the out阅读全文>
发表于 @ 2007年12月24日 16:02:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 5. Variable Modifiers第5章 变量修饰符 - escape转义修饰符
escape
escape is used to encode or escape a variable to for example html, url, single quotes, hex, hexentity, javascript and mail. By default its html.
Parameter Position Type Required Possible Values Default Description
1 string No html, htmlall, url, urlpathinfo, quotes, hex, hexentity, javascript, mail html This is the escape format to use.
2 string No ISO-8859-1, UTF-8, and any character set supported by htmlen阅读全文>
发表于 @ 2007年12月02日 19:50:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 5. Variable Modifiers第5章 变量修饰符 - upper将字符串转换成大写字母
upper
This is used to uppercase a variable. This is equivalent to the PHP strtoupper() function.
Example 5-22. upper
assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
?>
Where template is:
{$articleTitle}
{$articleTitle|upper}
Will output:
If Strike isn't Settled Quickly it may Last a While.
IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
See also lower and 阅读全文>
发表于 @ 2007年11月18日 20:45:00|评论(loading...)|收藏
Smarty - Manual手册 - Chapter 5. Variable Modifiers第5章 变量修饰符 - cat将值连接到给定变量之后
cat
This value is concatenated to the given variable.
Parameter Position Type Required Default Description
1 string No empty This value to catenate to the given variable.
Example 5-3. cat
assign('articleTitle', "Psychics predict world didn't end");
?>
Where template is:
{$articleTitle|cat:' yesterday.'}
Will output:
Psychics predict world didn't end yesterday.
[cat将值连接到给定变量之后 - 文档]
阅读全文>
发表于 @ 2007年11月18日 00:19:00|评论(loading...)|收藏
Smarty - 手册 - 第8章 自定义函数 - {cycle}循环
{cycle}
{cycle} is used to alternate a set of values. This makes it easy to for example, alternate between two or more colors in a table, or cycle through an array of values.
{cycle} 用于在值集合中轮换。便于实现下述情况,在一个表格中交替输出两种或多种颜色,在值数组中循环。
Attribute Name Type Required Default Description
name string No default The name of the cycle
values mixed Yes N/A The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values
阅读全文>
发表于 @ 2007年10月23日 12:39:00|评论(loading...)|收藏