Destoon template storage rules and syntax reference

Source: Internet
Author: User

Destoon template storage rules and syntax reference. If you have any need, refer.

 

Because templates are similar to the tipask, they are stored for research.

========================================================== ==========

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.
For 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 the template {template 'header'} or {template 'head', 'member '}


{Template 'header'} is parsed
<? PHP Include template ('header');?>
Template/default/header.htm Template File
{Template 'header', 'member '}
Parsed as <? PHP Include template ('header', 'member');?>
Template/default/member/header.htm Template File


2. variable or constant representation


The variable {$ destoon} is parsed as <? PHP echo $ destoon;?>
The constant {destoon} is parsed as <? 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. Function {func_name ($ par1, $ par2 )}


{Func_name ($ par1, $ par2)} is parsed
<? PHP func_name ($ par1, $ par2);?>


4. php expression {PHP expression}


{PHP expression} is parsed as <? PHP expression?>


5. Condition Statement {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) lawn price {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 directly written in the template, and PHP code can be directly written in the destoon template syntax.

Destoon template storage rules and syntax reference

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.