首先,需要在ThinkPHP\Lib\Think\Template\TagLib\目录下增加一个文件名叫:TagLibZpass.class.php TagLibZpass.class.php:php
array('attr'=>'table,limit,order,where,field','level'=>3),);public function _select($attr,$content){static $_iterateParseCache = array();//如果已经解析过,则直接返回变量值$cacheIterateId = md5($attr.$content);if(isset($_iterateParseCache[$cacheIterateId])) return $_iterateParseCache[$cacheIterateId];$tag = $this->parseXmlAttr($attr,'table');$db=M($tag['table']);$list=$db->where($tag['where'])->order($tag['order'])->limit($tag['limit'])->field($tag['field'])->select();preg_match_all("/\[field\:\w*\]/",$content,$match);$match=$match[0];$match=array_unique($match);//去掉数组重复项foreach($match as $i=>$vo){$field[$i]=substr($vo,7,count($vo)-2);}foreach($list as $i=>$value){if($i==0){$parseStr=$content;}else{$parseStr=$parseStr.$content;}foreach($match as $j=>$vo){$parseStr=str_replace($vo,$value[$field[$j]],$parseStr);}}$_iterateParseCache[$cacheIterateId] = $parseStr;if(!emptyempty($parseStr)) {return $this->tpl->parse($parseStr);}return ;}}?>然后在视图上写上调用的方法是[field:title]这个很容易理解吧www.2cto.com我这个只是例子,代表可以自由扩展THINKPHP标签...做自己的特色标签以上标签例子实际是查询classes表里的内容