返回新闻列表

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();
    }


推荐技术资料

PC端页面在手机端100%完整显示标签

2022-08-14

<meta name="viewport" content="width=device-width,user-scalable=yes,initial-scale=0.3,maximum-scale=0.3,shrink-to-fit=no">初始缩放比和最大缩放比例设为0.3

阅读更多

google maps地图不用api调用,用js动态调用目前测试可用,2023年05月

2023-05-04

<divid="dituchor"></div><script>window.addEventListener("load",function(){variDiv=document.createElement('iframe');iDiv.id='iframe1&

阅读更多

滚动倒退后保留 wow.js 动画效果 解决办法

2023-06-30

如果你希望在滚动倒退后保留 wow.js 动画效果,可以尝试将 resetAnimation 设置为 false。varwow=newWOW({resetAnimation:false,})wow.init();

阅读更多

好用的独立响应式css

2024-03-10

好用的独立响应式css,网站制作的时候很方便,@media响应式也也好了。在配合独立的格栅系统 ,就好用了。不用加载其他css框架梁https://www.002t.cn/jishuwenzhang/108.html 如果要用rem布局。在加载一个js响应式设置html字体大小。 https://www.002t.cn/jishuwenzhang/109.html/*重置标签*/html{-ms-text-s

阅读更多

pbootcms导出所有会员信息为表格,可指定字段

2023-07-10

改动:/apps/admin/controller/member/Membercontroller.php增加一个函数/*导出所有会员为表格 */ public function export() { $this->assign('Member', $this->model->getListall()); header("Content-Type:application/vnd.ms-excel"); &nb

阅读更多

c盘老是满,怎么解决了!不一样的解决方法,

2023-05-19

c盘老是满,怎么解决了!网上可能会告诉你,清理temp目录一些缓存,但是你会发现效果其实没多大用处,来看看我是怎么解决的,首先我们要找到底是什么目录在天天增加大小,先进入:C:\Users\Administrator\AppData你会看到。有二个目录特别的大,分别是Local和Roaming,这二个其实都是缓存,然后在逐一看看那个目录大,一般都

阅读更多

css字体自适应屏幕设置,CSS中字体响应式的设置

2022-06-20

现在我们在做网站的时候,都按照响应式制作。但是又时候字体怎么设置都屏幕不一样。效果感觉有点不太一样。今天就来研究一下响应式字体是怎么实现了。看了一些资料。想要响应式主要是字体设置单位不一样,单位主要如下:1vw = viewport宽度的1%1vh = viewport高度的1%1vmin = 1vw或者1vh中较小的值1vmax = 1vw或者1vh中较大

阅读更多

pbootcms 判断电脑版和手机版 ,直接程序判断增加自定义标签函数

2024-08-19

修改文件/apps/home/controller/ExtLabelController.php1,找到代码$this->test();在下方添加代码$this->ismobile();2,新增ismobile()函数//判断是否移动端设备privatefunctionismobile(){&nbs

阅读更多

html5 video 去除下载和画中画 和全屏按钮

2022-10-20

css/*所有控件video::-webkit-media-controls-enclosure{display: none;}*/video::-webkit-media-controls-fullscreen-button {display: none;}controlsList='nodownload' 去除下载disablePictureInPicture 去除画中画<video width="100%" height="100%" preload="

阅读更多