3.2.3自定义标签通用代码(新手第一次发)
标签库代码:<?php <br />
namespace Think\Template\TagLib;<br>
use Think\Template\TagLib;<br>
<br>
class lx extends TagLib {<br>
protected $tags = array(<br>
'list' => array('attr' => 'type,order,limit,where','close' => 1),<br>
);<br>
public function _list($attr,$content) {<br>
$type = $attr['type']; //要查询的数据表<br>
$order = $attr['order']; //排序<br>
$limit = $attr['limit']; //多少条数据<br>
$where = $attr['where']; //查询条件<br>
$str = '<?php ';<br />
$str .= '$result = M("' . $type . '")->where("' . $where . '")->order("' . $order . '")->limit(' . $limit . ')->select();';<br>
$str .= 'foreach ($result as $v):';<br>
$str .= '?>';<br>
$str .= $content;<br>
$str .= '<?php endforeach ?>';<br>
return $str;<br>
}<br>
}
调用代码:<list><br>
{$v[id]} -- {$v[user]}<br><br>
</list>
注意:where 的条件字符串要有单引号,另外{$v[id]}要这样写,如果写成{$v:id}无效.该文件与Cx标签库放在同一个文件夹下...修改THINKPHP文件夹下通用配置文件. 新手第一次发,研究了三天,如果有任何BUG,请及时告知..谢谢.
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.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
