应用实例:在 商务中心的 管理供求信息 页面:利用标签库生成列表;
步骤一:
在项目配置文件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文件;
载入标签库:
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号