在archiver目录建立以下代码:
<?php
define('DT_REWRITE', true);
require '../common.inc.php';
$EXT['archiver_enable'] or dheader(DT_PATH);
//$DT_BOT or dheader(DT_PATH);
$N = $M = $T = array();
$mid or $mid = 5;
$vmid = $list = 0;
foreach($MODULE as $k=>$v) {
if(!$v['islink'] && $v['ismenu'] && $v['moduleid'] > 4) {
if($k == $mid) $vmid = 1;
$v['url'] = $DT['rewrite'] ? rewrite('index.php?mid='.$k) : '?mid-'.$k.'.html';
$N[] = $v;
}
}
$vmid or $mid = $N[0]['moduleid'];
$table = get_table($mid);
$t = $db->get_one("SELECT MIN(addtime) AS mintime,MAX(addtime) AS maxtime FROM {$table} WHERE status=3", 'CACHE');
$fromtime = $t['mintime'];
$fromyear = timetodate($fromtime, 'Y');
if($fromyear < 1990) $fromyear = 1990;
$frommonth = timetodate($fromtime, 'n');
$totime = $t['maxtime'] > $DT_TIME ? $DT_TIME : $t['maxtime'];
$toyear = timetodate($totime, 'Y');
$tomonth = timetodate($totime, 'n');
for($i = $toyear; $i >= $fromyear; $i--) {
for($j = ($i == $toyear ? $tomonth : 12); $j >= ($i == $fromyear ? $frommonth : 1); $j--) {
$r = array();
$r['title'] = $MODULE[$mid]['name'].$i.'年'.($j < 10 ? '0' : '').$j.'月归档';
$r['month'] = $i.($j < 10 ? '0' : '').$j;
$r['url'] = $DT['rewrite'] ? rewrite('index.php?mid='.$mid.'&month='.$r['month']) : '?mid-'.$mid.'-month-'.$r['month'].'.html';
$M[$r['month']] = $r;
}
}
$head_title = $MODULE[$mid]['name'].'归档';
if(isset($month) && isset($M[$month])) {
$list = 1;
$y = substr($month, 0, 4);
$m = substr($month, 4, 2);
$ym = $y.'-'.$m;
$t = timetodate(datetotime($ym.'-01'), 't');
$ftime = datetotime($ym.'-01 00:00:00');
$ttime = datetotime($ym.'-'.$t.' 23:59:59');
$condition = "status=3 AND addtime>$ftime AND addtime<$ttime";
$num = $db->count($table, $condition, $CFG['db_expires']);
$demo_url = $DT['rewrite'] ? rewrite($MODULE[1]['linkurl'].'archiver/index.php?mid='.$mid.'&month='.$month.'&page={destoon_page}') : '?mid-'.$mid.'-month-'.$month.'-page-{destoon_page}.html';
$pages = pages($num, $page, $pagesize, $demo_url);
$tmp = explode('<input type="text"', $pages);
$pages = $tmp[0];
if($num) {
$result = $db->query("SELECT title,linkurl,addtime FROM {$table} WHERE $condition ORDER BY addtime DESC LIMIT $offset,$pagesize");
while($r = $db->fetch_array($result)) {
$r['adddate'] = timetodate($r['addtime'], 5);
if(strpos($r['linkurl'], '://') === false) $r['linkurl'] = $MODULE[$mid]['linkurl'].$r['linkurl'];
$T[] = $r;
}
}
$head_title = $MODULE[$mid]['name'].$y.'年'.$m.'月归档'.($page > 1 ? '第'.$page.'页' : '');
}
include template('archiver', 'extend');
?>
然后在模板目录extend下建立:
<!doctype html>
<html>
<head>
<meta charset="{DT_CHARSET}"/>
<title>{$head_title}{$DT[seo_delimiter]}{$DT[sitename]}</title>
<link rel="stylesheet" type="text/css" href="{DT_SKIN}archiver.css?v={if DT_DEBUG}{DT_TIME}{else}{DT_REFRESH}{/if}"/>
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width"/>
</head>
<body>
<div id="nav">
{loop $N $i $m}
<div{if $mid==$m[moduleid]} class="on"{/if}><a href="{$EXT[archiver_url]}{$m[url]}"><span>{$m[name]}</span></a></div>
{/loop}
</div>
<div id="title"><strong>{$head_title}</strong></div>
<div id="content">
<ul>
{if $list}
{if $T}
{loop $T $t}
<li><em>{$t[adddate]}</em><a href="{$t[linkurl]}" target="_blank">{$t[title]}</a></li>
{/loop}
{if $pages}<div class="pages">{$pages}</div>{/if}
{else}
<li>暂无归档内容</li>
{/if}
{else}
{loop $M $t}
<li><a href="{$EXT[archiver_url]}{$t[url]}">{$t[title]}</a></li>
{/loop}
{/if}
</ul>
</div>
{if $DT[stats]}
<script type="text/javascript">
function Dstats() {}
{php include DT_ROOT.'/api/stats.inc.php';}
</script>
{/if}
</body>
</html>
这样效果就好了。
演示地址:教育资讯归档_醉学网 (nongpin88.com)http://www.nongpin88.com/archiver/