当前位置:首页 > 网站制作 > 帝国cms

帝国cms实用型网站检索框教程,不用系统自带的搜索功能

帝国cms实用型网站检索框教程,不用系统自带的搜索功能,此功能是不借助帝国cms自带搜索功能。

其实很简单,绑定多个栏目id,搜索绑定栏目id下所有的文章标题,进行检索出现

帝国cms傻瓜式网站检索框教程,不用系统自带的搜索功能

表单代码如下

<form action="[!--news.url--]e/action/ListInfo.php" method="get">
  <input type="hidden" name="classid" value="1,2" />  <!--所需要搜索的栏目id-->
  <input type="hidden" name="tempid" value="10" />  <!--所需要承接页面的列表模板-->
  <input type="hidden" name="ph" value="1" />
  <input name="titles" type="text" value="请输入关键词搜索" class="so" onFocus="if (this.value==this.defaultValue) {this.value='';} " onblur="if (this.value=='') {this.value=this.defaultValue;}"/>
  <input type="submit" name="submit" value="搜索" class="submit"/>
</form>

然后就是修改文件 /e/action/ListInfo.php 需要加入一些代码配合实现搜索的效果

帝国cms傻瓜式网站检索框教程,不用系统自带的搜索功能

表单代码如下

$title=trim($_GET['titles']);
if(!empty($title))
{
         $add.=" and title like '%".$title."%'";
         $search.='&titles='.$title;
}

以上都修改好之后,先 更新数据库缓存 然后就可以测试效果了

标签:帝国CMS

你觉得文章内容怎么样

阿里云代金券 100 云产品通用

有效期30天 首购用户

立即领取
推荐宝塔面板 0 安全高效的

服务器运维面板

立即领取