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 = thinkDb::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);
}
/*–end*/
$result[$key] = $val;
}
return $result;
}
}
模板内调用代码
{eyou:volist name=”:diy_archives_list(1,1,’click’,10)”}
{$i}
[ {$field.typename} ]{$field.title}
({$field.click})人阅读发布时间:{$field.add_time|MyDate=’Y-m-d’,###}
{/eyou:volist}
(1,1,’click’,10)l绿色1为频道模型版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
转载请注明: 易优CMS文章排行调用如何按年月日来调用