Ver código fonte

添加自定义taglib

huwhois 2 anos atrás
pai
commit
3fa3386ebf

+ 1 - 0
app/common.php

@@ -73,3 +73,4 @@ function generate_stochastic_string($length = 16)
     $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
     $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
     return substr(str_shuffle($permitted_chars), 0, $length);
     return substr(str_shuffle($permitted_chars), 0, $length);
 }
 }
+

+ 12 - 12
app/common/model/Article.php

@@ -96,12 +96,12 @@ class Article extends Base
         $list = self::where($where)
         $list = self::where($where)
             ->field('id,cid,title,titlepic,username,summary,content_type,hits,sort,status,create_time')
             ->field('id,cid,title,titlepic,username,summary,content_type,hits,sort,status,create_time')
             ->with(['category'])
             ->with(['category'])
-            ->order($order)->paginate($limit, false, ['query' => $params]);
+            ->order($order)->paginate(['list_rows'=>$limit, 'query' => $params]);
 
 
         return $list;
         return $list;
     }
     }
 
 
-    public static function getListByCid($cid = 0, $limit = 10, $order = [])
+    public static function getListByCid($cid = 0, $limit = 10, $order = "")
     {
     {
         $where = [];
         $where = [];
 
 
@@ -112,10 +112,12 @@ class Article extends Base
                 $where[] = ['cid', '=', $cid];
                 $where[] = ['cid', '=', $cid];
             }
             }
         }
         }
+        
+        $where[] = ['status', '=', 1];
 
 
-        $order = !empty($order) ? array_merge($order, ['id' => 'desc']) : ['id' => 'desc'];
+        $order = $order ?? "sort ASC,id DESC";
 
 
-        return self::where($where)
+        return self::with('category')->where($where)
             ->field('id,cid,title,titlepic,username,summary,hits,sort,status,create_time')
             ->field('id,cid,title,titlepic,username,summary,hits,sort,status,create_time')
             ->order($order)->limit($limit)->select();
             ->order($order)->limit($limit)->select();
     }
     }
@@ -123,7 +125,7 @@ class Article extends Base
     public static function getTop($limit)
     public static function getTop($limit)
     {
     {
         return self::with('category')->field('id,cid,title,titlepic,summary,username,hits,sort,status,create_time')
         return self::with('category')->field('id,cid,title,titlepic,summary,username,hits,sort,status,create_time')
-            ->order('sort desc')->limit($limit)->select();
+            ->order('sort ASC, id DESC')->limit($limit)->select();
     }
     }
 
 
     public static function getOne($id)
     public static function getOne($id)
@@ -169,15 +171,13 @@ class Article extends Base
         return ['prev' => $data_p, 'next' => $data_N];
         return ['prev' => $data_p, 'next' => $data_N];
     }
     }
 
 
-    public static function createTimeArchive()
+    public static function createTimeArchive($limit = 0)
     {
     {
-        $create_times = self::order('create_time desc')->column('create_time');
-        $timeList = [];
-        foreach ($create_times as $value) {
-            $yearAndMonth = date("Y-m", $value);
-            $timeList[] = $yearAndMonth;
+        if ($limit == 0) {
+            $timeList = self::distinct(true)->fieldRaw("FROM_UNIXTIME(`create_time`, '%Y-%m') as pubmonth")->order('pubmonth desc')->select();
+        } else {
+            $timeList = self::distinct(true)->fieldRaw("FROM_UNIXTIME(`create_time`, '%Y-%m') as pubmonth")->order('pubmonth desc')->limit($limit)->select();
         }
         }
-        $timeList = array_unique($timeList);
 
 
         return $timeList;
         return $timeList;
     }
     }

+ 20 - 4
app/common/model/Category.php

@@ -1,12 +1,16 @@
 <?php
 <?php
+declare(strict_types=1);
 
 
 namespace app\common\model;
 namespace app\common\model;
 
 
+/**
+ * 栏目模型
+ */
 class Category extends Base
 class Category extends Base
 {
 {
     protected $schema = [
     protected $schema = [
         "id"          => "int",
         "id"          => "int",
-        "parent_id"         => "int",
+        "parent_id"   => "int",
         "name"        => "varchar",
         "name"        => "varchar",
         "url"         => "varchar",
         "url"         => "varchar",
         "route"       => "varchar",
         "route"       => "varchar",
@@ -14,8 +18,9 @@ class Category extends Base
         "template"    => "varchar",
         "template"    => "varchar",
         "type"        => "int",
         "type"        => "int",
         "is_nav"      => "int",
         "is_nav"      => "int",
-        "remark"        => "varchar",
+        "remark"       => "varchar",
         "sort"        => "int",
         "sort"        => "int",
+        'status'      => "varchar",
         "title"       => "varchar",
         "title"       => "varchar",
         "keywords"    => "varchar",
         "keywords"    => "varchar",
         "description" => "varchar",
         "description" => "varchar",
@@ -25,8 +30,19 @@ class Category extends Base
     ];
     ];
 
 
     // 获取列表
     // 获取列表
-    public static function getList()
+    public static function getList(array $param = [])
     {
     {
-        return self::order(['id' => 'desc'])->select();
+        $where = [];
+
+        if (isset($param['is_nav']) ) {
+            $where[] = ['is_nav', '=', (int) $param['is_nav']];
+        }
+
+        if (isset($param['type']) ) {
+            $where[] = ['type', '=', (int) $param['type']];
+        }
+
+        return self::where($where)->field("id,parent_id,name,url,route,tablename,template,type,is_nav,remark,sort,title,keywords,
+            description,is_blank,create_time,update_time")->order(['sort' => 'ASC', 'id' => 'desc'])->select();
     }
     }
 }
 }

+ 90 - 0
app/common/taglib/Tp.php

@@ -0,0 +1,90 @@
+<?php
+
+declare(strict_types=1);
+
+namespace app\common\taglib;
+
+use think\template\TagLib;
+
+/**
+ * 标签扩展
+ */
+class Tp extends TagLib
+{
+    /**
+     * 标签定义
+     *  attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次
+     * @var array
+     */
+    protected $tags = array(
+        'close'    => ['attr' => 'time,format', 'close' => 0],                          // 闭合标签,默认为不闭合
+        'open'     => ['attr' => 'name,type', 'close' => 1],
+        'nav'      => ['attr' => 'id,limit,name', 'close' => 1],                        // 通用导航信息
+        // 'cate'     => ['attr' => 'id,type,anchor', 'close' => 0],                    // 通用栏目信息
+        // 'position' => ['attr' => 'name', 'close' => 1],                              // 通用位置信息
+        // 'link'     => ['attr' => 'name', 'close' => 1],                              // 获取友情链接
+        // 'ad'       => ['attr' => 'name,id', 'close' => 1],                           // 获取广告信息
+        'listbycid'     => ['attr' => 'cid,name,limit', 'close' => 1],                  // 通用列表
+        'listtime'  => ['attr' => 'name,limit', 'close' => 1],                          // 时间归档
+    );
+
+    // 这是一个闭合标签的简单演示
+    public function tagClose($tag)
+    {
+        $format = empty($tag['format']) ? 'Y-m-d H:i:s' : $tag['format'];
+        $time   = empty($tag['time']) ? time() : $tag['time'];
+        $parse  = '<?php ';
+        $parse  .= 'echo date("' . $format . '",' . $time . ');';
+        $parse  .= ' ?>';
+        return $parse;
+    }
+
+    // 这是一个非闭合标签的简单演示
+    public function tagOpen($tag, $content)
+    {
+        $type  = empty($tag['type']) ? 0 : 1; // 这个type目的是为了区分类型,一般来源是数据库
+        $name  = $tag['name'];                // name是必填项,这里不做判断了
+        $parse = '<?php ';
+        $parse .= '$test_arr=[[1,3,5,7,9],[2,4,6,8,10]];'; // 这里是模拟数据
+        $parse .= '$__LIST__ = $test_arr[' . $type . '];';
+        $parse .= ' ?>';
+        $parse .= '{volist name="__LIST__" id="' . $name . '"}';
+        $parse .= $content;
+        $parse .= '{/volist}';
+        return $parse;
+    }
+
+    // 文章列表
+    public function tagListbycid($tag, $content)
+    {
+        $cid    = (int) $tag['cid'];                        // 不可以为空
+        $name   = (string) $tag['name'];                     // 不可为空
+        $order  =  isset($tag['order']) ? (string) $tag['order'] : 'sort ASC,id DESC';  // 可为空
+        $limit  = $tag['limit'] ? (int) $tag['limit'] :  10; // 多少条数据
+        
+        $parse = '<?php ';
+        $parse .= '$list = \app\common\model\Article::getListByCid(' . $cid . ', ' . $limit . ', "' . $order .'");';
+        $parse .= '?>';
+        $parse .= '{volist name="list" id="' . $name . '"}';
+        $parse .= $content;
+        $parse .= '{/volist}';
+        
+        return $parse;
+    }
+
+    // 
+    public function tagListtime($tag, $content)
+    {
+        $name   = (string) $tag['name'];                        // 不可为空
+        $limit  = $tag['limit'] ? (int) $tag['limit'] : 0;     // 多少条数据 0 不限制
+
+        $parse  = '<?php ';
+        $parse .= '$list = \app\common\model\Article::createTimeArchive(' . $limit . ');';
+        $parse .= '?>';
+        $parse .= '{volist name="list" id="' . $name . '"}';
+        $parse .= $content;
+        $parse .= '{/volist}';
+
+        return $parse;
+    }
+}

+ 2 - 0
app/index/config/view.php

@@ -6,4 +6,6 @@
 return [
 return [
     // 开启模板布局
     // 开启模板布局
     'layout_on'    => true,
     'layout_on'    => true,
+    // 自定义标签库
+    'taglib_pre_load' => 'app\common\taglib\Tp',
 ];
 ];

+ 6 - 32
app/index/controller/Base.php

@@ -75,38 +75,12 @@ abstract class Base
             View::assign('bdtongji', "");
             View::assign('bdtongji', "");
         }
         }
 
 
-        // 菜单
-        $categories = Category::where('is_nav', 1)->order(['sort desc'])->select();
-
+        // 栏目菜单(nav)
+        $categories = Category::getList(['is_nav'=>1]);
         View::assign('categories', $categories);
         View::assign('categories', $categories);
-
-        // 侧边栏
-        if ($this->request->has('_aside')==false) {
-            $this->aside();
-        }
-    }
-
-    /**
-     * 侧边栏
-     */
-    protected function aside()
-    {
-        $cate_lists = Category::where('template', 'article')->select();
-
-        $hits_lists = Article::getListByCid(0, 9, ['hits' => 'desc']);
-
-        $top_lists = Article::getTop(7);
-
-        $time_lists = Article::createTimeArchive();
-
-        $last_lists = Article::getListByCid(0, 9);
-
-        View::assign([
-            'cate_lists' => $cate_lists,
-            'hits_lists' => $hits_lists,
-            'top_lists'  => $top_lists,
-            'time_lists' => $time_lists,
-            'last_lists' => $last_lists,
-        ]);
+        
+        // 一般栏目
+        $cate_lists = Category::getList(['type'=>1]);
+        View::assign('cate_lists', $cate_lists);
     }
     }
 }
 }

+ 11 - 29
app/index/controller/Index.php

@@ -1,15 +1,17 @@
 <?php
 <?php
+
 declare(strict_types=1);
 declare(strict_types=1);
+
 /**
 /**
  * @file   Index.php
  * @file   Index.php
  * @date   2019-02-27 14:49:36
  * @date   2019-02-27 14:49:36
  * @author huwhis<huuwhois>
  * @author huwhis<huuwhois>
  * @version   0.0.6
  * @version   0.0.6
  */
  */
+
 namespace app\index\controller;
 namespace app\index\controller;
 
 
 use think\facade\View;
 use think\facade\View;
-use think\Request;
 
 
 use app\index\controller\Base;
 use app\index\controller\Base;
 use app\common\model\Article;
 use app\common\model\Article;
@@ -19,27 +21,8 @@ class Index extends Base
 {
 {
     public function index()
     public function index()
     {
     {
-        // PHP $cid = 1;
-        $php_data = Article::getListByCid(1, 7);
-
-        // 其他学习笔记 $cid != 1;
-        $other_data = Article::getListByCid(-1, 7);
-        
-        // Top文章
-        $top_data = Article::getTop(3);
-
-        // 所有文章
-        $all_data = Article::getListByCid(0, 9);
-        
-        View::assign([
-            'php_data' => $php_data,
-            'other_data' => $other_data,
-            'top_data' => $top_data,
-            'all_data' => $all_data,
-        ]);
-
         $html = View::fetch();
         $html = View::fetch();
-        
+
         return $html;
         return $html;
     }
     }
 
 
@@ -60,17 +43,17 @@ class Index extends Base
 
 
         return View::fetch();
         return View::fetch();
     }
     }
-    
+
     public function saveGuestBook()
     public function saveGuestBook()
     {
     {
-        $param = $this->request->param('','',['strip_tags','htmlspecialchars']);
-    
+        $param = $this->request->param('', '', ['strip_tags', 'htmlspecialchars']);
+
         if (empty($param['name']) or empty($param['contact'])) {
         if (empty($param['name']) or empty($param['contact'])) {
-            return json(['msg'=>"请填写必填字段(姓名,电子邮件)", 'code'=>1]);
+            return json(['msg' => "请填写必填字段(姓名,电子邮件)", 'code' => 1]);
         }
         }
 
 
         if (empty($param['content'])) {
         if (empty($param['content'])) {
-            return json(['msg'=>"请留下内容", 'code'=>1]);
+            return json(['msg' => "请留下内容", 'code' => 1]);
         }
         }
 
 
         try {
         try {
@@ -83,12 +66,11 @@ class Index extends Base
                 'time' => time(),
                 'time' => time(),
             ]);
             ]);
             $bgu->datetime = date("Y-m-d", $bgu->time);
             $bgu->datetime = date("Y-m-d", $bgu->time);
-            return json(['msg'=>"保存成功", 'code'=>0, 'data'=>$bgu]);
+            return json(['msg' => "保存成功", 'code' => 0, 'data' => $bgu]);
         } catch (\Exception $e) {
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $msg = $e->getMessage();
 
 
-            return json(['msg'=>$msg, 'code'=>1]);
+            return json(['msg' => $msg, 'code' => 1]);
         }
         }
-
     }
     }
 }
 }

+ 5 - 1
public/static/index/css/index.css

@@ -10,6 +10,8 @@ a:hover { text-decoration: none; color: #000; }
 .blank { height: 20px; overflow: hidden; width: 100%; margin: auto; clear: both }
 .blank { height: 20px; overflow: hidden; width: 100%; margin: auto; clear: both }
 .f_l { float: left }
 .f_l { float: left }
 .f_r { float: right }
 .f_r { float: right }
+.ml-20 { margin-left: 20px }
+.ml-10 { margin-left: 10px }
 .box { width: 1280px; margin: auto; overflow: hidden; clear: both; }
 .box { width: 1280px; margin: auto; overflow: hidden; clear: both; }
 @media(max-width:1400px) {
 @media(max-width:1400px) {
     .box {width: 1000px; }
     .box {width: 1000px; }
@@ -33,7 +35,7 @@ nav li { display: inline; line-height: 40px; padding: 0 20px }
 .sbox { width: 32%; background: #FFF; padding-bottom: 20px; position: relative; z-index: 2; }
 .sbox { width: 32%; background: #FFF; padding-bottom: 20px; position: relative; z-index: 2; }
 .sbox h2 { font-size: 16px; padding: 50px 0 20px; border-bottom: #CCC 1px solid; margin: 0 20px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
 .sbox h2 { font-size: 16px; padding: 50px 0 20px; border-bottom: #CCC 1px solid; margin: 0 20px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
 .sbox p { overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 3; line-height: 24px; height: 72px; padding: 20px 20px 0 20px }
 .sbox p { overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 3; line-height: 24px; height: 72px; padding: 20px 20px 0 20px }
-.sbox.ml { margin-left: 20px }
+.sbox.ml { margin-left: 2%; }
 .sbox span { width: 80px; height: 30px; line-height: 30px; text-align: center; margin: auto; display: block; background: #333; color: #FFF; position: absolute }
 .sbox span { width: 80px; height: 30px; line-height: 30px; text-align: center; margin: auto; display: block; background: #333; color: #FFF; position: absolute }
 .read { display: block; text-align: center; margin: 20px auto 0; width: 100px; border: #333 1px solid; line-height: 26px; position: relative; }
 .read { display: block; text-align: center; margin: 20px auto 0; width: 100px; border: #333 1px solid; line-height: 26px; position: relative; }
 .read:before { content: ''; position: absolute; top: 0; left: 0; width: 0; height: 26px; background: #333; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; -webkit-transition: 0.5s; transition: 0.5s; z-index: -1; }
 .read:before { content: ''; position: absolute; top: 0; left: 0; width: 0; height: 26px; background: #333; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; -webkit-transition: 0.5s; transition: 0.5s; z-index: -1; }
@@ -44,6 +46,8 @@ nav li { display: inline; line-height: 40px; padding: 0 20px }
 .bloglist h2 { font-size: 18px; position: relative }
 .bloglist h2 { font-size: 18px; position: relative }
 .bloglist h2:before { content: ""; width: 3px; height: 26px; position: absolute; left: -20px; top: 0; background: #333 }
 .bloglist h2:before { content: ""; width: 3px; height: 26px; position: absolute; left: -20px; top: 0; background: #333 }
 .bloglist p { overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 3; line-height: 24px; height: 72px; margin: 10px 0 0 }
 .bloglist p { overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 3; line-height: 24px; height: 72px; margin: 10px 0 0 }
+.blogs div.more { text-align: center; color: #666; width: 100%; clear: both; margin: 25px 0 10px 0; }
+.blogs div.more a { border: 1px solid #333; padding: 5px 10px; background: #333; color: #FFF }
 aside { width: 32%; float: right }
 aside { width: 32%; float: right }
 .ztbox { border: #000 1px solid; background: #fff; overflow: hidden; }
 .ztbox { border: #000 1px solid; background: #fff; overflow: hidden; }
 .ztbox li { border-bottom: #888 1px solid; line-height: 40px; height: 40px; padding-left: 70px; position: relative; }
 .ztbox li { border-bottom: #888 1px solid; line-height: 40px; height: 40px; padding-left: 70px; position: relative; }

+ 9 - 22
view/index/aside.html

@@ -1,47 +1,34 @@
 <aside>
 <aside>
-  <!-- <div class="ztbox">
-    <ul>
-      <li><a href=""></a></li>
-    </ul>
-  </div> -->
   <div class="paihang">
   <div class="paihang">
     <h2>最近更新</h2>
     <h2>最近更新</h2>
     <ul>
     <ul>
-      {foreach $last_lists as $value}
+      {tp:listbycid cid="0" name="value" limit="7" order="id DESC"}
       <li><a href="/index/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
       <li><a href="/index/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
-      {/foreach}
+      {/tp:listbycid}
     </ul>
     </ul>
   </div>
   </div>
   <div class="paihang">
   <div class="paihang">
     <h2>点击排行</h2>
     <h2>点击排行</h2>
     <ul>
     <ul>
-      {foreach $hits_lists as $value}
+      {tp:listbycid cid="0" name="value" limit="7" order="hits DESC"}
       <li><a href="/index/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
       <li><a href="/index/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
-      {/foreach}
+      {/tp:listbycid}
     </ul>
     </ul>
   </div>
   </div>
   <div class="paihang">
   <div class="paihang">
     <h2>博文推荐</h2>
     <h2>博文推荐</h2>
     <ul>
     <ul>
-      {foreach $top_lists as $value}
+      {tp:listbycid cid="0" name="value" limit="7"}
       <li><a href="/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
       <li><a href="/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
-      {/foreach}
+      {/tp:listbycid}
     </ul>
     </ul>
   </div>
   </div>
   <div class="paihang">
   <div class="paihang">
     <h2>归档</h2>
     <h2>归档</h2>
     <ul>
     <ul>
-      {foreach $time_lists as $value}
-      <li><a href="/{:str_replace('-','/',$value)}" title="{$value}">{:str_replace('-','年',$value)}月</a></li>
-      {/foreach}
+      {tp:listtime name="value" limit="5"}
+      <li><a href="/{:str_replace('-','/',$value->pubmonth)}" title="{$value->pubmonth}">{:str_replace('-','年',$value->pubmonth)}月</a></li>
+      {/tp:listtime}
     </ul>
     </ul>
   </div>
   </div>
-  <!-- <div class="paihang">
-    <h2>友情链接</h2>
-    <ul>
-      <li><a href="{//$Think.config.url_2048_root}">2048之陈小发</a></li>
-      <li><a href="{//$Think.config.url_blog_root}">huwhois个人博客</a></li>
-      <li><a href="{//$Think.config.url_1219_root}">1219fun</a></li>
-    </ul>
-  </div> -->
 </aside>
 </aside>

+ 20 - 16
view/index/index/index.html

@@ -3,32 +3,33 @@
   <div class="newsbox f_l ">
   <div class="newsbox f_l ">
     <div class="newstitle"><span><a href="/php.html">+</a></span><b>PHP</b></div>
     <div class="newstitle"><span><a href="/php.html">+</a></span><b>PHP</b></div>
     <ul class="newsli">
     <ul class="newsli">
-      {foreach $php_data as $val}
+      {tp:listbycid cid="1" name="val" limit="7"}
       <li><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></li>
       <li><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></li>
-      {/foreach}
+      {/tp:listbycid}
     </ul>
     </ul>
   </div>
   </div>
   <!-- notes_data -->
   <!-- notes_data -->
   <div class="newsbox f_r ">
   <div class="newsbox f_r ">
     <div class="newstitle"><span><a href="/all.html">+</a></span><b>其他</b></div>
     <div class="newstitle"><span><a href="/all.html">+</a></span><b>其他</b></div>
     <ul class="newsli">
     <ul class="newsli">
-      {foreach $other_data as $val}
+      {tp:listbycid cid="-1" name="val" limit="7"}
       <li><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></li>
       <li><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></li>
-      {/foreach}
+      {/tp:listbycid}
     </ul>
     </ul>
   </div>
   </div>
   <div class="blank"></div>
   <div class="blank"></div>
   <!-- top -->
   <!-- top -->
-  {foreach $top_data as  $key=> $val}
-  <div class="sbox  {switch name='key'}{case value='1'}f_l ml{/case}{case value='2'}f_r{/case}{default /}f_l{/switch}"> <span>{$val.category_name}</span>
+  {tp:listbycid cid="0" name="val" limit="3"}
+  <div class="sbox f_l {if $key!=0}ml{/if}">
+    <span>{$val.category_name}</span>
     <h2><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
     <h2><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
     <p>{$val.summary}</p>
     <p>{$val.summary}</p>
   </div>
   </div>
-  {/foreach}
+  {/tp:listbycid}
   <div class="blank"></div>
   <div class="blank"></div>
   <!-- all -->
   <!-- all -->
   <div class="blogs">
   <div class="blogs">
-    {foreach $all_data as $val}
+    {tp:listbycid cid="0" name="val" limit="15" order="id DESC"}
     <div class="bloglist">
     <div class="bloglist">
       <h2><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
       <h2><a href="/{$val.create_time|date='Y/m-d'}/{$val.id}.html" title="{$val.title}">{$val.title}</a></h2>
       <div class="bloginfo">
       <div class="bloginfo">
@@ -41,7 +42,10 @@
       </div>
       </div>
       <p>{$val.summary}</p>
       <p>{$val.summary}</p>
     </div>
     </div>
-    {/foreach}
+    {/tp:listbycid}
+    <div class="more">
+      <a href="/all.html">更多</a>
+    </div>
   </div>
   </div>
   <aside>
   <aside>
     <div class="ztbox">
     <div class="ztbox">
@@ -54,25 +58,25 @@
     <div class="paihang">
     <div class="paihang">
       <h2>点击排行</h2>
       <h2>点击排行</h2>
       <ul>
       <ul>
-        {foreach $hits_lists as $value}
+        {tp:listbycid cid="0" name="value" limit="7" order="hits DESC"}
         <li><a href="/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
         <li><a href="/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
-        {/foreach}
+        {/tp:listbycid}
       </ul>
       </ul>
     </div>
     </div>
     <div class="paihang">
     <div class="paihang">
       <h2>博文推荐</h2>
       <h2>博文推荐</h2>
       <ul>
       <ul>
-        {foreach $top_lists as $value}
+        {tp:listbycid cid="0" name="value" limit="7"}
         <li><a href="/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
         <li><a href="/{$value.create_time|date='Y/m-d'}/{$value.id}.html" title="{$value.title}">{$value.title}</a></li>
-        {/foreach}
+        {/tp:listbycid}
       </ul>
       </ul>
     </div>
     </div>
     <div class="paihang">
     <div class="paihang">
       <h2>归档</h2>
       <h2>归档</h2>
       <ul>
       <ul>
-        {foreach $time_lists as $value}
-        <li><a href="/{:str_replace('-','/',$value)}" title="{$value}">{:str_replace('-','年',$value)}月</a></li>
-        {/foreach}
+        {tp:listtime name="value" limit="5"}
+        <li><a href="/{:str_replace('-','/',$value->pubmonth)}" title="{$value->pubmonth}">{:str_replace('-','年',$value->pubmonth)}月</a></li>
+        {/tp:listtime}
       </ul>
       </ul>
     </div>
     </div>
     <!-- <div class="paihang">
     <!-- <div class="paihang">