帮助

在线免费看三级片网站 文章排行调用如何按年月日来调用

2020-02-25 09:59 易优技巧
需要写入的php函数,请在“网站根目录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)
            ->order($orderby)
            ->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);
            }
           
            $result[$key] = $val;
        }
 
        return $result;
    }
}



模板内调用代码
{eyou:volist name=":diy_archives_list(1,1,'click',10)"}
     
  • {$i}
  •         ({$field.click})人阅读发布时间:{$field.add_time|MyDate='Y-m-d',###}
    {/eyou:volist}

    (1,1,'click',10)l绿色1为频道模型
    全部:0
    文章:1
    产品:2
    图集:3
    下载:4

    (1,1,'click',10)中的蓝色1为天数:
    今日:1
    本周:7
    本月:30
    三个月:90
    本年:365
    全部:0


    (1,1,'click',10)中的click为排序方式:
    new: 按发布时间排序
    click: 按点击数排序
    sort_order:按排序号排序
    rand: 按随机排序



    (1,1,'click',10)中的10为调用条数:
    数值可以自定义填写




    效果展示:
     


    工作日 8:30-12:00 14:30-18:00
    周六及部分节假日提供值班服务

    联系我们
    QQ在线咨询
    • 业务客服
    • 付费修改
    • 加入Q群
    • 微信客服

      工作日 8:30-12:00 14:30-18:30

    AI智能客服 ×