统计 0 / 1197

[使用交流] 扩展一下标签调用!!加上按栏目调用!!

...

熊猫小大王

普通会员

楼主 发布时间:2017-12-20 19:23:10 IP:120.194.188.103

    // 获取某个属性下面的文章
    public function attrlist($attr,$limit=10,$channel_id=0){
        $content_ids = \think\Db::name('content_attr') -> where('attr',$attr) -> order('sort desc,content_id desc') -> column('content_id');
        $where = [
            'id'        =>  ['in',$content_ids],
            'status'    =>  1
        ];
        if (!empty($channel_id)) { $where['channel_id'] = ['in',$channel_id]; }
        $tmp2 = [];
        $tmp = \app\content\model\Content::where($where) -> select();
        foreach ($tmp as $key => $value) {
            $tmp2[$value['id']] = $value;
        }
        $res = [];
        foreach ($content_ids as $key => $value) {
            if (isset($tmp2[$value])) {
                $res[] = $tmp2[$value];
            }
        }
        return array_slice($res, 0, $limit);
    }

代码

...

游客

54.92.163.105

请遵守当地法律法规!


Back to top

© 2014 EBtech, Inc. · Privacy · EB Terms