thinkphp 使用标签库的步骤
利用标签库生成列表;
步骤一:
在项目配置文件Conf文件夹下,新建一个taglibs.php文件,将
return array ( 'html' => '@.TagLib.TagLibHtml' , // 使用import方法支持的路径格式 );拷贝进去,这是定义本项目使用哪个标签库;
步骤二:
在Lib目录下,新建 TagLib 文件夹;
Lib/TagLib/Tags/html.xml 标签库的定义文件;
Lib/TagLib/TagLibHtml.class.php 标签库的解析类;
步骤三:
拷贝 CommonAction.class.php 在Action 目录下;
拷贝 CommonModel.class.php 在Model 目录下;
步骤四:
lib/Action目录下,新建一个类,例如,ProductsAction.class.php
class ProductsAction extends CommonAction {
}
如果写成:
class FormAction extends CommonAction { //过滤查询字段 function _filter(& $map ){ $map [ 'title' ] = array ( 'like' , "%" . $_POST [ 'name' ]. "%" ); } }_filter函数是用来传递查询条件的;
这个地方需要注意:Products必须是对应的数据库的表名;
步骤五:
在模板中新建一个 Products文件夹;
index.html 需要包含;
基本的JS文件.
<load href= "__PUBLIC__/Js/Base.js" /> <load href= "__PUBLIC__/Js/prototype.js" /> <load href= "__PUBLIC__/Js/mootools.js" /> <load href= "__PUBLIC__/Js/Ajax/ThinkAjax.js" /> <load href= "__PUBLIC__/Js/common.js" /> <load href= "__PUBLIC__/Js/Util/ImageLoader.js" /> <script language= "JavaScript" > <!-- //指定当前组模块URL地址 var URL = '__URL__' ; var APP = '__APP__' ; var PUBLIC = '__PUBLIC__' ; ThinkAjax.image = [ '__PUBLIC__/images/loading2.gif' , '__PUBLIC__/images/ok.gif' , '__PUBLIC__/images/update.gif' ] ImageLoader.add( "__PUBLIC__/images/bgline.gif" , "__PUBLIC__/images/bgcolor.gif" , "__PUBLIC__/images/titlebg.gif" ); ImageLoader.startLoad(); //--> </script>载入标签库:
<tagLib name= "html" /> <!-- 列表显示区域 --> <div > <html:list id= "checkList" style= "list" checkbox= "true" action= "true" datasource= "list" show= "id:编号|8%,name:信息标题:edit,upload_time|toDate='y-m-d':发布日期,checkstatus|getStatus:审核是否通过" actionlist= "foreverdel:删除:id,edit:编辑:id" /> </div> <!-- 分页显示区域 --> <div class = "page" >{ $page }</div>查看更多关于thinkphp 使用标签库的步骤 - Thinkphp的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did6352