EZ Publish/EZ Publish 模板控制结构

来自站长百科
跳转至: 导航、​ 搜索

EZ Publish | EZ Publish安装与卸载 | EZ Publish的使用 | EZ Publish常见问题 | EZ Publish其他

eZ Publish 模板语言提供了以下的控制结构:

• IF-THEN-ELSE

SWITCH

WHILE

• DO...WHILE

• FOR

• FOREACH

IF-THEN-ELSE[ ]

参阅下例:

例1:

{if eq( $var, 128 )}
Hello world <br />
{else}
No world here, move along. <br />
{/if}

例2:

{if eq( $fruit, 'apples' )}
Apples 
{elseif eq( $fruit, 'oranges' )}
Oranges 
{else}
Bananas 
{/if}

SWITCH[ ]

{switch match=$fruits}
{case match='apples'}
Apples
{/case}
{case match='oranges'}
Oranges
{/case}
{case}
Unidentified fruit!
{/case}
{/switch}

如果$fruits 初始值为'oranges',则输出:

Oranges

WHILE[ ]

{while ne( $counter, 8 )}
Print this line eight times ({$counter}) <br />
{set $counter=inc( $counter )}
{/while}

如果$counter 初始值为0,则输出:

Print this line eight times (0)
Print this line eight times (1)
Print this line eight times (2)
Print this line eight times (3)
Print this line eight times (4)
Print this line eight times (5)
Print this line eight times (6)
Print this line eight times (7)

DO...WHILE[ ]

{do}
Keep printing this line ({$counter}) <br />
{set $counter=inc( $counter )}
{/do while ne( $counter, 8 )}

如果$counter 初始值为0,则输出:

Keep printing this line (0)
Keep printing this line (1)
Keep printing this line (2)
Keep printing this line (3)
Keep printing this line (4)
Keep printing this line (5)
Keep printing this line (6)
Keep printing this line (7)
Keep printing this line (8)

FOR[ ]

{for 0 to 7 as $counter}
Value of counter: {$counter} <br />
{/for}

输出:

Value of counter: 0
Value of counter: 1
Value of counter: 2
Value of counter: 3
Value of counter: 4
Value of counter: 5
Value of counter: 6
Value of counter: 7

FOREACH[ ]

{foreach $objects as $object}
{$object.name}
{/foreach}

如果$objects 是一个数组,且包含4 个对象,对象名依次为:"Emmett Brown","Marty McFly","Lorraine Baines"和"Biff Tannen",则输出:

Emmett Brown
Marty McFly
Lorraine Baines
Biff Tannen

参考来源[ ]

EZ Publish使用手册导航

EZ Publish安装卸载

EZ Publish正常安装 | EZ Publish手动安装 | EZ Publish自动安装 | EZ Publish安装向导 | EZ Publish虚拟主机设置 | EZ Publish使用扩展 | EZ Publish的卸载

EZ Publish的使用

模板使用:

EZ Publish节点模板 | EZ Publish系统模板 | EZ Publish Pagelayout页头信息 | EZ Publish Pagelayout变量 | EZ Publish 模板注释 | EZ Publish 模板变量类型 | EZ Publish 模板变量用法 | EZ Publish 调查数组和对象 | EZ Publish 模板控制结构 | EZ Publish 函数与操作符 | EZ Publish URL处理 | EZ Publish 内容提取 | EZ Publish 模板重设系统
系统功能: EZ Publish 系统记帐 | EZ Publish 策略功能 | EZ Publish 多语言使用(一) | EZ Publish 多语言使用(二) | EZ Publish 集群的使用 | EZ Publish 安装包的使用 | EZ Publish Cronjob脚本的使用 | EZ Publish 多货币功能 | EZ Publish 通知功能
其他功能: EZ Publish 增值税(VAT)系统 | EZ Publish 改进的商品配送系统 | EZ Publish 多语言URL别名 | EZ Publish 登录后高级重定向 | EZ Publish 检索引擎 | EZ Publish WebDAV | EZ Publish 视图缓存

EZ Publish常见问题

EZ Publish 安装常见问题 | EZ Publish 使用常见问题

EZ Publish其他

EZ Publish内部结构 | EZ Publish内容与界面 | EZ Publish内容管理(一) | EZ Publish内容管理(二) | EZ Publish配置模型 | EZ Publish模块与视图 | EZ Publish URL 翻译 | EZ Publish 界面 | EZ Publish访问控制 | EZ Publish网络商店 | EZ Publish工作流