Syntax rules used in templates:
Example: templates/default/content/show.html
1. Variable representation
{$title} 被解析成 <?php echo $title;?>
Final value: I am the title
2. Constant representation
{R} 被解析成 <?php echo R;?>
Final value:/HTTP//My domain/res/
For example:
<link href="{R}t3/css/bootstrap.css" rel="stylesheet"><link href="{R}t3/css/style.css" rel="stylesheet"><link href="{R}t3/css/hover.css" rel="stylesheet">
3. Condition Judgment
{if condition} content to display 1 {else} content to display 2 {else} content to display 3{/if}
or {if condition} to display the contents {/if}
For example:
{if $title!=‘‘}{$title}{/if}
4. Circulation
$a $b} * {/loop}
is parsed into:
<?phpforeach($a as $b) {}?>
At the same time, $n variables are added automatically, such as:
<?php$n=1;foreach($a as $b) { $n++;}?>
Instance:
{loop $rs $r} 排名:{$n},标题:{$r[‘title‘]}{/loop}
{loop $res $key $value}主键:{$key}, 值{$value}{/loop}
resolves to:
<?phpforeach($res as $key=>$value) {?>主键:<?php echo $key;?>, 值<?php echo $value;?><?php }?>
5. The template contains
{T ‘模块目录名‘,‘文件名‘}
For example:
{T "content","head",TPLID}
6. Self-increment, self-reduction
For example:
{php $i=10;}{loop $a $b}<li>{$i}</li>{$i++}{/loop}
参数:自减 {$i--} {--$i} 自增 {$i++} {++$i}
7. Single-line PHP parsing:
$i=1;} 解析为:<?php echo $i=1;?>
$string = date(‘Y-m-d‘);} 解析为:<?php $string = date(‘Y-m-d‘);?>
Wuzhicms template Syntax