返回新闻列表

PbootCMSV3.2.5后台增加自定义字段搜索,可搜索标题和其他自定义字段

发布日期: 2024-05-24 | 来源: 智软设计工作室

我们在后台模型里面新增了自定义字段后,然后想要在后台搜索哪里。能搜索。需要处理下。

首先打开。

apps/admin/model/content/ContentModel.php

主要更改二个函数

// 查找指定分类及子类文章

    public function findContent($mcode, $scode, $keyword)


// 在全部栏目查找文章

    public function findContentAll($mcode, $keyword)


我下面贴出来。具体得修改。大家举一反三

 // 查找指定分类及子类文章
    public function findContent($mcode, $scode, $keyword)
    {
        $fields = array(
            'a.id',
            'b.name as sortname',
            'a.scode',
            'c.name as subsortname',
            'a.subscode',
            'a.title',
            'a.subtitle',
            'a.date',
            'a.sorting',
            'a.status',
            'a.istop',
            'a.isrecommend',
            'a.isheadline',
            'a.visits',
            'a.ico',
            'a.pics',
            'a.filename',
            'a.outlink',
            'd.urlname',
            'b.filename as sortfilename',
            'content_ext.ext_orderno'//这里增加要查询得自定义字段
        );
        $join = array(
            array(
                'ay_content_sort b',
                'a.scode=b.scode',
                'LEFT'
            ),
            array(
                'ay_content_sort c',
                'a.subscode=c.scode',
                'LEFT'
            ),
            array(
                'ay_model d',
                'b.mcode=d.mcode',
                'LEFT'
            ),
            array('ay_content_ext content_ext',
            'a.id=content_ext.contentid', 'LEFT') //这里增加要查询得自定义字段和表
        );
        $this->scodes = array(); // 先清空
        $scodes = $this->getSubScodes($scode);
        return parent::table('ay_content a')->field($fields)
            ->where("b.mcode='$mcode'")
            ->where('d.type=2 OR d.type is null ')
            ->where("a.acode='" . session('acode') . "'")
            ->in('a.scode', $scodes)
            ->like('a.title,content_ext.ext_orderno', $keyword)//这里加入查询得自定义字段
           
            ->join($join)
            ->order('a.sorting ASC,a.id DESC')
            ->page()
            ->select();
    }

    // 在全部栏目查找文章
    public function findContentAll($mcode, $keyword)
    {
        $fields = array(
            'a.id',
            'b.name as sortname',
            'a.scode',
            'c.name as subsortname',
            'a.subscode',
            'a.title',
            'a.subtitle',
            'a.date',
            'a.sorting',
            'a.status',
            'a.istop',
            'a.isrecommend',
            'a.isheadline',
            'a.visits',
            'a.ico',
            'a.pics',
            'a.filename',
            'a.outlink',
            'd.urlname',
            'b.filename as sortfilename',
            'content_ext.ext_orderno'//这里增加要查询得自定义字段
        );
        $join = array(
            array(
                'ay_content_sort b',
                'a.scode=b.scode',
                'LEFT'
            ),
            array(
                'ay_content_sort c',
                'a.subscode=c.scode',
                'LEFT'
            ),
            array(
                'ay_model d',
                'b.mcode=d.mcode',
                'LEFT'
            ),
            array('ay_content_ext content_ext',
            'a.id=content_ext.contentid', 'LEFT')//这里增加要查询得自定义字段
        );
        return parent::table('ay_content a')->field($fields)
            ->where("b.mcode='$mcode'")
            ->where('d.type=2 OR d.type is null ')
            ->where("a.acode='" . session('acode') . "'")
            //->like('a.title', $keyword)
            ->like('a.title,content_ext.ext_orderno', $keyword)//这里增加要查询得自定义字段
            ->join($join)
            ->order('a.sorting ASC,a.id DESC')
            ->page()
            ->select();
    }


推荐技术资料

解决苹果IOS、Android 以及各种浏览器 视频不能自动播放问题,data-wf-ignore="true"

2023-06-13

IOS 自动播放视频的简单解决方案,加入:data-wf-ignore="true"data-object-fit="cover"具体代码<videoid="myVideo"autoplay=""muted=""playsinline=""data-wf-ignore="true"data-object-f

阅读更多

PbootCMSV3.2.5后台增加自定义字段搜索,可搜索标题和其他自定义字段

2024-05-24

我们在后台模型里面新增了自定义字段后,然后想要在后台搜索哪里。能搜索。需要处理下。首先打开。apps/admin/model/content/ContentModel.php主要更改二个函数// 查找指定分类及子类文章 public function findContent($mcode, $scode, $keyword)// 在全部栏目查找文章 public function findCont

阅读更多

pbootcms后台自定义字段多图上传 不能多图拖动解决办法

2025-05-25

修改\apps\admin\view\default\content\content.html底部拖动js代码。如下。即可解决自定义上传多图不能拖动的问题,<scripttype="text/javascript">/*$("#pics_box").dragsort({dragSelector:"dl",dragSelect

阅读更多

2021 godaddy域名转出教程 最新版 转入阿里云 半个小时就能转出成功

2021-11-05

首页到域名列表找到要转移的域名。点击进去。先解锁域名转移限制,然后点击转出域名获取 转移密码。然后到阿里云,提交转入,到这一部后再次进入godaddy,点击转移,到里面点击批准转出。 如果当天看不到。就隔天去godaddy 批准。这样不用等5-7天。就能转入了。

阅读更多

网站中JS怎么实现禁用右键、禁用Ctrl+u、禁用Ctrl+s、禁用F12

2023-08-27

我们在做网站得时候,有时候会为了防止人家拿代码 复制 保存等功能。来做一点防御方法,但是这种只能仿菜鸟,没法彻底防御,下面是代码,vararr=[123,17,18];//先定义下要禁止哪些键,document.oncontextmenu=newFunction("event.returnValue=false;"),//禁用

阅读更多

ueditor去掉编辑器过滤功能,完成编写好的代码不被过滤,

2024-02-01

默认的ueditor编辑器会转换div为P,和过滤了一些style样式 以及一些自定义的标签,如aos="fade-up",下面告诉大家怎么设置。打开ueditor.config.js,如果已经有了一下代码,把他们的参数ture改成false,如果没有直接加入进去,// 允许进入编辑器的 div 标签自动变成 p 标签,allowDivTransToP:false,xxsFilt

阅读更多

pbootcms怎么判断分页是否在尾页

2024-05-09

{pboot:if('{page:current}'=='{page:count}')} 尾页 {else}不在尾页

阅读更多

pbootcms 左侧产品栏目 高亮判断方法

2021-12-02

主要是这段代码。官方演示的不行{pboot:if('[nav:scode]'=='{sort:scode}')}left_active{/pboot:if} {pboot:nav num=6 parent=2} <li><a class="biglink {pboot:if('[nav:scode]'=='{sort:scode}'

阅读更多

批量替换文件里的所有注释,正则表达式模式:

2024-01-07

当你使用EditPlus进行批量替换时,可以使用以下正则表达式来匹配和删除HTML文件中的注释:正则表达式模式:<!--[\s\S]*?-->上面用表达式可以批量替换文件里的所有注释

阅读更多