Destoon Two development templates and call syntax Rollup _php instances

Source: Internet
Author: User

First, the template storage and call rules

The template is stored in the System template directory, a directory under the template directory
For example: template/default/is a set of templates

Template files are extended with. htm and can be stored directly in the template directory
such as Template/default/index.htm
can also be stored in a subdirectory of the template directory
For example: template/default/member/index.htm

In the PHP file, use the template syntax for

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

Or

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

If the current default template sleeve is defaulted:

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

Indicates the use of the template/default/header.htm template file

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

Indicates the use of the template/default/member/header.htm template file

In the template directory under these.name.php is the template alias profile, the template alias can be modified in the background template management.

The cached files after the template resolution are saved in the cache/tpl/directory with the extension. tpl.php

Second, the template syntax

1, include template : {Template ' header '} or {template ' header ', ' member '}

{Template ' header '} is resolved as

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

Indicates the use of the template/default/header.htm template file

{Template ' header ', ' member '}

is resolved to:

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

Indicates the use of the template/default/member/header.htm template file

2, variable or constant means:

The variable {$destoon} is resolved to:

<?php
 echo $destoon;
? >

The constant {Destoon} is resolved to:

<?php
 echo destoon;
? >

For arrays, the standard notation should be for example {$destoon [' Index ']}, which can be abbreviated to {$destoon [index]}, and the template will automatically append quotes when parsing.

3. Function {Func_name ($par 1, $par 2)}

{Func_name ($par 1, $par 2)} is resolved to

<?php
 Func_name ($par 1, $par 2);
>

4. PHP expression {PHP expression}

{PHP expression} is resolved as

<?php
 expression 
?>

5, conditional statement {if $a = = ' B '} do a {/if} or {if $a = = ' B '} do an {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 resolved to

<?php
 if ($a = = ' B ') {do
 a
 }
?>

{if $a = = ' B '} does a {else} do b {/if} is resolved to

<?php
 if ($a = = ' B ') {do
 a 
 } else {do
 b
 } 
?>

{if $a = = ' B '} do a {elseif $b = = ' C '} do c {else} does B {/if} is resolved to

<?php
 if ($a = = ' B ') {do
 a 
 } else if ($b = = ' C ') {do
 C
 } else {do
 b
 } 
?>

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
 if (Is_array ($var)) {
 foreach ($var as $k => $v) {
 ...}}
? >

Third, special use

1, variables or expressions can be HTML annotations , such as <!--{$destoon}--> is still resolved to <?php echo $destoon;?> (this type of annotation can be automatically filtered)

2, you can write PHP code directly in the template , the direct writing of PHP code and Destoon template syntax is compatible.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.