dedecms织梦文章按年月日进行归档效果图:
思路
从文档表中取得年,月,日的归档文档,按年或月或日输出。
前端代码
- 文章归档
-
{$pubdate}
- {$row['title']} {$description}
TPL;
}
@me = $result;
[/field:date]
[field:date function=MyDate('Y年m月',strtotime(@me))/] [field:date runphp="yes"] global $dsql; $startTime = strtotime(@me.'-01'); $endTime = strtotime('+1 month',$startTime); $qtypeQuery = " WHERe arc.arcrank>=0 and arc.pubdate between $startTime AND $endTime ORDER BY arc.id desc limit 10"; $sql = "SELECt arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart, tp.moresite,tp.siteurl,tp.sitepath FROM `blog_archives` arc left join `blog_arctype` tp on arc.typeid=tp.id $qtypeQuery"; $dsql->SetQuery($sql); $dsql->Execute('t'); $result = ''; while($row = $dsql->GetArray('t')) { $arcurl = GetFileUrl($row['id'],$row['typeid'],$row['senddate'],$row['title'],$row['ismake'],$row['arcrank'], $row['namerule'],$row['typedir'],$row['money'],$row['filename'],$row['moresite'],$row['siteurl'],$row['sitepath']); if(date("m-d",$row['pubdate'])==date("m-d")){ $pubdate = ''.MyDate('m-d',$row['pubdate']).''; } else { $pubdate = MyDate('m-d',$row['pubdate']); } $description = cn_substr($row['description'],100); $result .= <<< TPL
1、includetaglibarclist2.lib.php
CAttribute->Items,$attlist);
extract($ctag->CAttribute->Items, EXTR_SKIP);
$line = empty($row) ? 10 : $row;
$innertext = $ctag->GetInnerText();
if(trim($innertext)=='') $innertext = GetSysTemplets("arclist2.htm");
switch ($format) {
case 'y':
$format2 = '%Y';
break;
case 'm':
$format2 = '%Y-%m';
break;;
case 'd':
$format2 = '%Y-%m-%d';
break;
default:
$format2 = '%Y-%m-%d';
}
$ctp = new DedeTagParse();
$ctp->SetNameSpace('field', '[', ']');
if(!empty($start)) {
$qtypeQuery = ' WHERe '.$time.'>'.strtotime($start);
}
if(!empty($end)){
$qtypeQuery .= $qtypeQuery ? ' AND '.$time.'<'.strtotime($end) : ' WHERe '.$time.'<'.strtotime($end);
}
$solvingask = '';
$query = "select FROM_UNIXTIME($time, '$format2') AS date,count(*) AS count FROM `blog_archives` $qtypeQuery group by date order by date desc limit $line";
$dsql->Execute('me',$query);
while($rs = $dsql->GetArray('me'))
{
$ctp->LoadSource($innertext);
if($rs['date']) {
$rs['dateurl'] = '/plus/arcDate.php?time='.$time.'&date='.$rs['date'].'&format='.$format;
foreach($ctp->CTags as $tagid=>$ctag) {
if(!empty($rs[strtolower($ctag->GetName())])) {
$ctp->Assign($tagid,$rs[$ctag->GetName()]);
}
}
$solvingask .= $ctp->GetResult();
}
}
return $solvingask;
}
更多归档文件打包
链接: http://pan.baidu.com/s/1jIr4V0i 密码: jy3e



