文件缓存型时候轴归档,背景更新缓存或许宣布新文章的时刻会自动更新;本站这个代码是运用缓存体系的,是须要修正内核文件的。慎用!
1、修正include/lib/cache.php文件,增加归档缓存函数
private $logalias_cache;以后增加private $loglists_cache;增加在其他缓存函数位置增加归档缓存
/*** 文章归档列表缓存 */private function mc_loglists() {$query = $this->db->query('select gid,title,date from ' . DB_PREFIX . "blog WHERE hide='n' and checked='y' and type='blog' ORDER BY date DESC");$loglists_cache = array();while ($row = $this->db->fetch_array($query)) {$loglists_cache[]= $row;}$cacheData = serialize($loglists_cache);$this->cacheWrite($cacheData, 'loglists');}不懂的朋侪只请直接下载本文件掩盖include/lib/cache.php(请做好备份) cache.zip
博客开通时候太长的话,大概背面宣布的文章会显现不出来,可自定义时候:AND date > $time - 3*365*24*60*60(这个代码示意显现近来3年的文章)
2、此要领因差别的模板修正的有所差别,本站报告以默许模板为例,起首复制模板目录下的page.php并重新命名为guidang.php(ps:这个本身可自行修正),把个中的<?php echo $log_content; ?>更改成以下代码即可<div class="guidang"><?phpglobal $CACHE; $loglists_cache = $CACHE->readCache('loglists');$year_month = 0;foreach($loglists_cache as $value):if($year_month != 0&&$year_month != date("Y-m",$value['date'])){echo '</ul>';}if($year_month != date("Y-m",$value['date'])){$year_month = date("Y-m",$value['date']);echo '<h2 class="guidang-tt">'.$year_month.'</h3><ul>';}?><li><a href="<?php echo Url::log($value['gid']);?>" target="_blank" title="<?php echo $value['title']; ?>"><span><?php echo date("Y-m-d",$value['date']);?></span><div class="atitle"><?php echo $value['title'];?></div></a></li><?php endforeach;?></div>css文件以下
.guidang h2{font-size:150%;}.guidang li a{padding:8px 0;display:block}.guidang li a:hover .atitle:after{background:#ff5c43}.guidang li a span{display: inline-block;width:100px;font-size:12px;text-indent:20px}.guidang li a .atitle{display: inline-block;padding:0 15px;position:relative;width:550px;white-space:nowrap;text-overflow:ellipsis;}.guidang li a .atitle:after{position:absolute;left:-2px;background:#ccc;height:8px;width:8px;border-radius:6px;top:8px;content:""}.guidang li a .atitle:before{position:absolute;left:-4px;background:#fff;height:12px;width:12px;border-radius:6px;top:6px;content:""}.guidang{margin:10px;position:relative;padding:10px 0}.guidang:before{height:100%;width:4px;background:#eee;position:absolute;left:100px;content:"";top:0}.guidang-tt{position:relative;margin:10px 0;cursor:pointer} .guidang-tt:hover:after{background:#ff5c43}.guidang-tt:before{position:absolute;left:93px;background:#fff;height:18px;width:18px;border-radius:6px;top:3px;content:""}.guidang-tt:after{position:absolute;left:96px;background:#ccc;height:12px;width:12px;border-radius:6px;top:6px;content:""}

评论列表