需要寫入的php函數(shù),請(qǐng)?jiān)?ldquo;網(wǎng)站根目錄extend/function.php”文件內(nèi)寫入
if (!function_exists('diy_archives_list'))
{
// 獲取指定天數(shù)的文檔列表
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']); // 默認(rèn)封面圖
/*文檔鏈接*/
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;
}
}
模板內(nèi)調(diào)用代碼
{eyou:volist name=":diy_archives_list(1,1,'click',10)"}
<li><i>{$i}</i>
<p><a class="u-class" href="{$field.typeurl}">[ {$field.typename} ]</a><a class="u-title" href="{$field.arcurl}">{$field.title}</a></p>
<strong>({$field.click})人閱讀</strong><span>發(fā)布時(shí)間:{$field.add_time|MyDate='Y-m-d',###}</span></li>
{/eyou:volist}
(1,1,'click',10)l綠色
1為頻道模型
全部:0
文章:1
產(chǎn)品:2
圖集:3
下載:4
(1,1,'click',10)中的藍(lán)色
1為天數(shù):
今日:1
本周:7
本月:30
三個(gè)月:90
本年:365
全部:0
(1,1,'click',10)中的
click為排序方式:
new: 按發(fā)布時(shí)間排序
click: 按點(diǎn)擊數(shù)排序
sort_order:按排序號(hào)排序
rand: 按隨機(jī)排序