Thinkphp3.2 official template tag Extension

Source: Internet
Author: User
Provides various official and user-released code examples, code reference, you are welcome to exchange and learn. The template supports {if} {elseif} {else} {/if} {for} {/for} {loop} {/loop} type labels.
I was just using thinkphp for development. It was crazy to have built-in labels when embedding templates. Although it was very powerful, it was too cumbersome. So I added several new labels based on simple and practical principles, it is easy for you to use.

Usage:
Condition judgment {If *} * {else} * {/if}
Or {if *} * {elseif *} * {else} * {/if}
Or {if *} * {/if}
* In {if *} is the condition expression of the judgment statement, which complies with the php expression.
Example:
{If! Empty ($ c) | $ a> 10 & $ B <10}
{$ C}
{Elseif $ a> 10}
{$}
{Else}
{$ B}
{/If}
Foreach Traversal {Loop $ a $ B} * {/loop} or {loop $ a $ B $ c} * {/loop}
Example:
{Loop $ a $ B $ c}
Entry {$ n}: {$ B }=>{ $ c}
{/Loop}
For Loop {for $i=0;$i<10;$i++}*{/for} Auto-increment or auto-subtraction example Auto increment {$ I --} {-- $ I} {$ I ++ $ I} Single-line PHP parsing syntax {Php $ I = 1;} is parsed:
{Php $ string = date ('Y-m-d');} resolved:
Add method:
This is a step-by-step manual for adding behavior extensions.
1. Place the file in the attachment in the Common \ Behavior folder of the project.
2. Behavior definition Configuration: 'template_filter'=>array('Common\\Behavior\\SimpleTemplate')3.2.1 The code for changing the behavior definition configuration is as follows: 'template_filter'=>array('Common\\Behavior\\SimpleTemplateBehavior')3. Add the Enable identifier to the project configuration file: 'STPL_SWITCH_ON'=>TRUEThis code is extracted from phpcms

SimpleTemplateBehavior.class.rar (765 B download: 85 times)

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

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.