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

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>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/24afd361d2e05fc1b6dcb5d04e158035.html