超越信息欢迎您,12年专注国内外网络营销,为您提供全链路服务方案!

  • 河北省沧州市运河区人防(人民防空)大厦11层07号

images_not_found

pbootcsm后台添加自字义字段搜索实现方法

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

首先打开。

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

Tags:

没有了

评论:(暂无)

留下评论

沧州网站建设