I. template storage and calling rules
The template is stored in the system template Directory, which is a directory under the template directory.
For example, template/default/is a set of templates.
The template file uses the. htm extension and can be directly stored in the template directory.
For example, template/default/index.htm
It can also be stored in the subdirectory of the template directory.
Example: template/default/member/index.htm
In the PHP file, use the template syntax
<?php include template('index');?>
Or
<?php include template('index', 'member');?>
If the current default template is set to default, then:
<?php include template('header');?>
Template/default/header.htm template File
<?php include template('header', 'member');?>
Template/default/member/header.htm template File
In the template directory, these. name. php is the configuration file of the template alias. The template alias can be managed and modified in the background template.
The cached files parsed by the template are stored in the cache/tpl/directory. The extension is. tpl. php.
Ii. template syntax
1. include templates: {Template 'header'} or {template 'header', 'member '}
{Template 'header'} is parsed
<?php include template('header');?>
Template/default/header.htm template File
{Template 'header', 'member '}
Resolved:
<?php include template('header','member');?>
Template/default/member/header.htm template File
2. variables or constants:
The variable {$ destoon} is parsed:
<?php echo $destoon;?>
The constant {DESTOON} is parsed:
<?php echo DESTOON;?>
For arrays, the standard format should be {$ destoon ['index']}, which can be abbreviated as {$ destoon [index]}. The template will automatically append quotation marks when parsing.
3. Functions{Func_name ($ par1, $ par2 )}
{Func_name ($ par1, $ par2)} is parsed
<?php func_name($par1, $par2);?>
4. PHP expressions{Php expression}
{Php expression} is parsed
<?php expression ?>
5. conditional statements{If $ a = 'B'} do A {/if} or {if $ a = 'B'} do A {else} do B {/if} or {if $ a = 'B'} do A {elseif $ B = 'C'} do c {else} do B {/if}
{If $ a = 'B'} do A {/if} is parsed
<?php if($a=='b') { do A }?>
{If $ a = 'B'} do A {else} do B {/if} is parsed
<?php if($a=='b') { do A } else { do B } ?>
{If $ a = 'B'} do A {elseif $ B = 'C'} do c {else} do B {/if} is parsed
<?php if($a=='b') { do A } else if($b=='c') { do C } else { do B } ?>
6. LOOP{Loop $ var $ v}... {loop} or
{Loop $ var $ k $ v}... {loop}
{Loop $ var $ v}... {loop} is parsed
<?php if(is_array($var)) { foreach($var as $v) { ... } }?>
{Loop $ var $ k $ v}... {loop} is parsed
<?php if(is_array($var)) { foreach($var as $k=>$v) { ... } }?>
Iii. Special usage
1. variables or expressions can be annotated in HTML., For example, <! -- {$ Destoon} --> is still parsed as <? Php echo $ destoon;?> (This annotation can be automatically filtered)
2. PHP code can be written directly in the template.Directly Writing PHP code is compatible with the DESTOON template syntax.