if (!function_exists(‘diy_archives_list’))
{
// 獲取指定天數(shù)的文檔列表
function diy_archives_list($channel = 0, $day = 0, $orderby = ‘a(chǎn)id’, $limit = 10) {
$where = [];
!empty($channel) && $where[‘a(chǎn).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(chǎn).add_time’] = [‘gt’, $t];
}
$where2 = [
‘a(chǎn).arcrank’ => [‘gt’, -1],
‘a(chǎn).status’ => 1,
‘a(chǎn).is_del’ => 0,
‘a(chǎn).lang’ => get_home_lang(),
];
$where = array_merge($where, $where2);
$orderby = getOrderBy($orderby, ‘desc’);
$result = thinkDb::name(‘a(chǎn)rchives’)->alias(‘a(chǎn)’)
->field(‘b.*, a.*’)
->join(‘__ARCTYPE__ b’, ‘a(chǎn).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’]); // 默認(rèn)封面圖
/*文檔鏈接*/
if ($val[‘is_jump’] == 1) {
$val[‘a(chǎn)rcurl’] = $val[‘jumplinks’];
} else {
$controller_name = $ctl_name_list[$val[‘channel’]][‘ctl_name’];
$val[‘a(chǎn)rcurl’] = arcurl(‘home/’.$controller_name.’/view’, $val);
}
/*–end*/
$result[$key] = $val;
}
return $result;
}
}
模板內(nèi)調(diào)用代碼
{eyou:volist name=”:diy_archives_list(1,1,’click’,10)”}
{$i}
[ {$field.typename} ]{$field.title}
({$field.click})人閱讀發(fā)布時(shí)間:{$field.add_time|MyDate=’Y-m-d’,###}
{/eyou:volist}
(1,1,’click’,10)l綠色1為頻道模型版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 易優(yōu)CMS文章排行調(diào)用如何按年月日來調(diào)用