Wuzhicms template Syntax

Source: Internet
Author: User

Syntax rules used in templates:

Example: templates/default/content/show.html

1. Variable representation

{$title} is parsed into <?php echo $title;? >

Final value: I am the title

2. Constant representation

{R} is parsed into <?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

{Loop $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} rank: {$n}, Title: {$r [' title ']}{/loop}

{Loop $res $key $value} primary key: {$key}, value {$value}{/loop}

resolves to:

<?phpforeach ($res as $key = $value) {?> primary key: <?php echo $key;? , Value <?php echo $value;? ><?php}?>

5. The template contains

{T ' module directory name ', ' filename '}

For example:

{T "content", "Head", Tplid}

6. Self-increment, self-reduction

For example:

{php $i = 10;} {loop $a $b}<li>{$i}</li>{$i ++}{/loop}
Parameter: auto-subtract {$i--} {--$i} increment {$i + +} {+ + $i}

7. Single-line PHP parsing:

For example: {php $i = 1;} is resolved to: <?php echo $i = 1;? >
For example: {php $string = date (' y-m-d '),} resolves to: <?php $string = Date (' y-m-d ');? >


Wuzhicms template Syntax

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.