织梦dedecms文章怎么按年月日进行归档

92建站   2021-04-18   收藏本文

本文介绍了织梦dedecms文章怎么按年月日进行归档,解决思路:从文档表中取得年,月,日的归档文档,按年或月或日输出就可以了。教程最后给出了压缩包,里面的文件下载后上传覆盖就可以了。提醒:修改前做好备份。

织梦dedecms文章怎么按年月日进行归档?一起来看看处理方法。

先来看效果图:

织梦文章归档

再来看实现方法:

前端代码

<div class="newbody">

<!-- 代码 开始 -->

<div class="head-warp">

<div class="head">

<div class="nav-box">

<ul>

<li class="cur" style="text-align:center; font-size:22px; font-family:'微软雅黑', '宋体';">文章归档</li>

</ul>

</div>

</div>

</div>

<div class="main">

<div class="history">

{dede:arclist2 row=12 format=m time=pubdate}

<div class="history-date">

<ul>

<h2 class="first"><a href="#nogo">[field:date function=MyDate('Y年m月',strtotime(@me))/]</a></h2> [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 = '<font color="#FF0000">'.MyDate('m-d',$row['pubdate']).'</font>';

}

else

{

$pubdate = MyDate('m-d',$row['pubdate']);

}

$description = cn_substr($row['description'],100); $result .= <<< TPL

<li>

<h3>{$pubdate}</h3>

<dl>

<dt><a href="{$arcurl}" target="_blank">{$row['title']}</a>

<span>{$description}</span>

</dt>

</dl>

</li> TPL; } @me = $result; [/field:date]

</ul>

</div>

{/dede:arclist2}

</div>

</div> </div>

1、\include\taglib\arclist2.lib.php

<?php if(!defined('DEDEINC')) exit('Request Error!'); /**  * 文章归档标签  *  * @package

DedeCMS.Dedediy  * @copyright

Copyright (c) 2013 - 2016  * @link

http://www.dedediy.com  */   function lib_arclist2(&$ctag,&$refObj) {

global $dsql;

//属性处理

$attlist="format|y,start|,end|,time|pubdate,row|10";

FillAttsDefault($ctag->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; }

更多归档文件打包下载(做好备份再使用):https://pan.baidu.com/s/1DVoHEVYwkv-wBvH82K8A0w 提取码:vuwg 

上面就是织梦文章归档的介绍,若有疑问可以找小编进一步探讨交流~

TAG标签: 织梦文章归档
展开