易优CMS按年月日来调用文章排行函数

wdzsjl 2周前 (10-10) 阅读数 4 #HTML
网站根目录extend/function.php“文件内写入   if (!function_exists('diy_archives_list')) {   // 获取指定天数的文档列表   function diy_archives_list($channel = 0, $day = 0, $orderby = 'aid', $limit = 10) {       $where = [];       !empty($channel) && $where['a.channel'] = $channel;       if ($day > 0) {          switch ($day) {             Case 1:                $t = mktime(0,0,0,date('m'),date('d'),date('Y'));                break;             Case 7:                $t = mktime(0,0,0,date('m'),date('d')-date('w')+1,date('y'));                break;             Case 28:             Case 29:             Case 30:             Case 31:                $t = mktime(0,0,0,date('m'),1,date('Y'));                break             Case 90:                $t = strtotime(date('Y-m-d', strtotime("-3 month")));                break;             Case 365:             Case 366:                $t = strtotime(date('Y-01-01'));                break;             default:                # code...                break;           }           $where['a.add_time'] = ['gt', $t];        }        $where2 = [           'a.arcrank' => ['gt', -1],           'a.status'  => 1,           'a.is_del'  => 0,           'a.lang'    => get_home_lang(),        ];        $where = array_merge($where, $where2);        $orderby = getOrderBy($orderby, 'desc');        $result = \think\Db::name('archives')->alias('a')            ->field('b.*, a.*')            ->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')            ->where($where)            ->limit($limit)            ->select();         // 获取查询的控制器名         $ctl_name_list = model('Channeltype')->getAll('id,ctl_name', array(), 'id');         foreach ($result as $key => $val) {            $val['litpic'] = get_default_pic($val['litpic']); // 默认封面图            /*文档链接*/            if ($val['is_jump'] == 1) {               $val['arcurl'] = $val['jumplinks'];            } else {               $controller_name = $ctl_name_list[$val['channel']]['ctl_name'];               $val['arcurl'] = arcurl('home/'.$controller_name.'/view', $val);            }            /*--end*/            $result[$key] = $val;         }         return $result;     } }

 

wx.jpg ywfw.jpg
热门