让模版支持{if}{elseif}{else}{/if}{for}{/for}{loop}{/loop}类型的标签
刚刚使用thinkphp开发,在嵌入模版时差点被内置标签快疯了,虽然很强大,但是太繁琐,所以自己本着简单实用的原则新加了几个标签,方便自己使用,这里贡献出来方便大家
使用方法:
条件判断{if *} * {else} * {/if} <br>
或 {if *} * {elseif *} * {else} * {/if} <br>
或 {if *} * {/if}<br>
其中{if *}中的*就是此判断语句的条件表达式,符合php的表达式。<br>
例子:<br>
{if !empty($c) || $a>10 && $b
{$c}<br>
{elseif $a>10}<br>
{$a}<br>
{else}<br>
{$b}<br>
{/if}
foreach遍历{loop $a $b} * {/loop} 或者 {loop $a $b $c} * {/loop}<br>
例子:<br>
{loop $a $b $c}<br>
第{$n}条:{$b}=>{$c}<br>
{/loop}
for循环 {for $i=0;$i<b>自增、自减例如</b> <code class="prettyprint linenums lang-php">自减 {$i--} {--$i} 自增 {$i++} {++$i}
单行PHP解析语法 {php $i=1;}解析为:<?php $i=1;?> <br>
{php $string = date('Y-m-d');} 解析为:<?php $string = date('Y-m-d');?>
添加方法:
这个是使用行为扩展添加,不知道什么是行为扩展的移步手册
1.将附件中的文件放在项目Common\Behavior文件夹中
2.行为定义配置:'template_filter'=>array('Common\\Behavior\\SimpleTemplate')
3.2.1行为定义配置有变化代码为:'template_filter'=>array('Common\\Behavior\\SimpleTemplateBehavior')
3.在项目配置文件中加入启用标识:'STPL_SWITCH_ON'=>TRUE
该代码是从phpcms中扒出来的
SimpleTemplateBehavior.class.rar
( 765 B 下载:85 次 )
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools
