pbootcms 列表页加入标题搜索功能,pboot:list添加列表直接搜索 -不用跳转到搜索页面
2023-07-10 10:54:32
最近制作网站的时候。因为搜索的地方比较多。比如常见问题和经销商,产品,都得搜索,用传统得{pboot:scaction} 他都会到统一得页面去,当然页可以用 <input type="hidden" name="searchtpl" value="1.html" >,置顶不同模板,但是置顶后。有些问题。比如栏目封面和当前位置,都会到搜索哪里。当然你页可以定死,但是不太灵活,万一后面又有其他栏目就又要做个模板了。下面是pboot:list列表页直接搜索得解决方法:
先找到:apps/home/controller/ParserController.php
找到:
// 解析内容列表标签
public function parserListLabel($content, $cscode = '')
然后:
$count = count($matches[0]);
下面添加:
/*添加列表直接搜索 */ $keyword = request('keyword', 'vars'); /*end */
然后在
// 扩展字段数据筛选
foreach ($_GET as $key => $value) {
if (preg_match('/^ext_[w-]+$/', $key)) { // 其他字段不加入
$where3[$key] = get($key, 'vars');
}
}
}
下面添加:
// 采取keyword方式 if ($keyword) { if (strpos($field, '|')) { // 匹配多字段的关键字搜索 $field = explode('|', $field); foreach ($field as $value) { if ($value == 'title') { $value = 'a.title'; } if ($fuzzy) { $like = " like '%" . $keyword . "%'"; // 前面已经转义过 } else { $like = " like '" . $keyword . "'"; // 前面已经转义过 } if (isset($where3[0])) { $where3[0] .= ' OR ' . $value . $like; } else { $where3[0] = $value . $like; } } if (count($field) > 1) { $where3[0] = '(' . $where3[0] . ')'; } } else { // 匹配单一字段的关键字搜索 if ($field) { if ($field == 'title') { $field = 'a.title'; } $where3[$field] = $keyword; } else { $where3['a.title'] = $keyword; } } } // 数据接收 if ($_POST) { $receive = $_POST; } else { $receive = $_GET; } foreach ($receive as $key => $value) { if (! ! $value = request($key, 'vars')) { if ($key == 'title') { $key = 'a.title'; } if (preg_match('/^[w-.]+$/', $key)) { // 带有违规字符时不带入查询 $where3[$key] = $value; } } } // 去除特殊键值 unset($where3['keyword']); unset($where3['field']); unset($where3['scode']); unset($where3['page']); unset($where3['from']); unset($where3['isappinstalled']); unset($where3['tdsourcetag']); unset($where3['x']); unset($where3['y']); unset($where3['searchtpl']); unset($where3['p']); unset($where3['s']); // 无任何条件不显示内容 /* 取消。不然进入没条件,列表页不显示内容, if (! $where3) { $content = str_replace($matches[0][$i], '', $content); continue; } /* end */
然后还要找到:IndexController.php
在44行左右:
if(stripos(URL,'?') !== false && stripos(URL,'/?tag=')
//加入列表页直接搜索?keyword条件,不然会出现您访问的内容不存在,请核对后重试 if(stripos(URL,'?') !== false && stripos(URL,'/?tag=') == false && stripos(URL,'/?page=') == false && stripos(URL,'/?ext_') == false && stripos(URL,'/?keyword') == false){ _404('您访问的内容不存在,请核对后重试!'); }
ParserController文件在里面,pbootcms3.2.5
加入list标签直接keyword搜索,ParserController.rar
【责任编辑:超级管理员】
关键字: pbootcms常见问题
pbootcms搜索页面设置不同模板 pbootcms导出所有会员信息为表格,可指定字段最新文章
2021-05-10 09:29
- pbootcms首页或者内容详情页开启分页
- pbootcms怎么判断分页是否在尾页
- dede 电脑端和手机端首页同步生成方法,
- excel表格导入access中不换行解决办法-
- dede完美上下篇 英文版替换标签 dede:prenext 中英
- dede中英文网站栏目条调用方法
- dede双语站 面包导航{dede:field name='position'}
- PS: 无法完成请求,因为某种原因阻止文本引擎进行
- dede企业网站常见左侧固定大小类二级菜单调用代码
- 栏目页dede:channelartlist调用下级子类并dede:arcl
- dede:channelartlis 判断是否有子类栏目
- 更换织梦后台图集上传flash插件为layui上传模块
相关文章
2021-05-10 09:29