Summary of destoon Secondary Development Template and Call Syntax

  • 2021-07-01 06:57:28
  • OfStack

1. Template storage and calling rules

Templates are stored in one directory under template directory and template directory of the system
For example: template/default/ is a set of templates

Template file with. htm extension can be directly stored in the template directory
E.g. template/default/index. htm
It can also be stored in a subdirectory of the template directory
For example: template/default/member/index. htm

In the PHP file, the template syntax is


<?php
 include template('index');
?>

Or


<?php
 include template('index', 'member');
?>

If the current default template set is default, then:


<?php
 include template('header');
?>

Indicates using the template/default/header. htm template file


<?php
 include template('header', 'member');
?>

Indicates using the template/default/member/header. htm template file

Template directory in these. name. php is the template alias configuration file, template alias can be modified in the background template management.

The parsed cache file is stored in the cache/tpl/directory with the extension. tpl. php

2. Template syntax

1. Include templates: {template 'header'} or {template 'header', 'member'}

{template 'header'} is resolved to


<?php
 include template('header');
?>

Indicates using the template/default/header. htm template file

{template 'header', 'member'}

Is parsed as:


<?php
 include template('header','member');
?>

Indicates using the template/default/member/header. htm template file

2. Variable or constant representation:

The variable {$destoon} is resolved to:


<?php
 echo $destoon;
?>

The constant {DESTOON} is resolved to:


<?php
 echo DESTOON;
?>

For arrays, the standard form should be, for example, {$destoon ['index']}, which can be shortened to {$destoon [index]}, and quotation marks are automatically appended when the template is parsed.

3. Function {func_name ($par1, $par2)}

{func_name ($par1, $par2)} is resolved to


<?php
 func_name($par1, $par2);
?>

4. PHP Expression {php expression}

{php expression} is resolved to


<?php
 expression 
?>

5. Conditional statements {if $a = = 'b'} do A {/if} or {if $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 to


<?php
 include template('index', 'member');
?>

0

{if $a== 'b'} do A {else} do B {/if} is parsed to


<?php
 include template('index', 'member');
?>

1

{if $a== 'b'} do A {elseif $b== 'c'} do C {else} do B {/if} is parsed as


<?php
 include template('index', 'member');
?>

2

6. LOOP loop {loop $var $v}... {loop} or

{loop $var $k $v}...{loop}

{loop $var $v}... {loop} is resolved to


<?php
 if(is_array($var)) {
 foreach($var as $v) {
 ... }
 }
?>

{loop $var $k $v}... {loop} is resolved to


<?php
 include template('index', 'member');
?>

4

3. Special usage

1. Variables or expressions can be annotated with HTML, for example < !--{$destoon}-- > Is still resolved to < ?php echo $destoon; ? > (This type of comment can be filtered automatically)

2. PHP code can be written directly in the template. Writing PHP code directly is compatible with DESTOON template syntax.


Related articles: