xml标签库标签-Request类-链式操作-博客实战分类搜索

xml标签库标签-Request类-链式操作-博客实战分类搜索

1、练习视图的XML 标签 2、练习请求Request类 3、练习数据库链式操作 4、博客实战,分类和搜索功能完成

  • 安装多应用(tpboke目录)
  1. composer require topthink/think-multi-app

1. 练习视图的XML

  • app\index\controller\index.php
  1. namespace app\index\controller;
  2. use think\facade\Db;
  3. use app\BaseController;
  4. use think\facade\View;
  5. use think\facade\Request;
  6. class Index extends BaseController
  7. {
  8. public function index()
  9. {
  10. view::assign('list_name', [
  11. ['id' => 1, 'name' => 'one'],
  12. ['id' => 2, 'name' => 'two'],
  13. ['id' => 3, 'name' => 'three']
  14. ]);
  15. view::assign('id', 2);
  16. return view::fetch('demo');
  17. }
  18. }
  • app\index\view\demo.html body 添加
  1. foreach $list_name as $key => $vo<br />
  2. {foreach $list_name as $key => $vo}
  3. key={$key} id={$vo.id} name={$vo.name}<br />
  4. {/foreach}
  5. <br />
  6. volist name='list_name' id='vo' key='key' empty='nothing' offset='1' length='1'<br />
  7. {volist name='list_name' id='vo' key='key' empty='nothing' offset='1' length='1'}
  8. key={$key} id={$vo.id} name={$vo.name}<br />
  9. {/volist}
  10. <br />
  11. for<br />
  12. {for start='1' end='5' step='2' name='i'}
  13. {$i}
  14. {/for}
  15. <br /><br />
  16. if<br />
  17. {if in_array('two', array_column($list_name, 'name'))}
  18. has two
  19. {elseif in_array('three', array_column($list_name, 'name')) /}
  20. has three
  21. {else /}
  22. no two
  23. {/if}
  24. <br /><br />
  25. empty<br />
  26. {empty name='list_name'}
  27. yes empty
  28. {else /}
  29. not empty
  30. {/empty}
  31. <br /><br />
  32. in<br />
  33. {in name='id' value='1,2,3'}
  34. {$id} in
  35. {else /}
  36. nothing
  37. {/in}
  38. <br /><br />
  39. present<br />
  40. {present name='ids'}
  41. $ids存在
  42. {else /}
  43. $ids不存在
  44. {/present}
  45. <br /><br />
  46. defined<br />
  47. {defined name='NAME'}
  48. NAME 常量已定义
  49. {else /}
  50. NAME 常量未定义
  51. {/defined}

标签练习

2. 练习请求Request类

  1. $req['id'] = Request::get('id', 'default');
  2. $req['name'] = Request::param('name', 'default');
  3. // a 转数组 d 整数 f 浮点 s 字符串 b 布尔
  4. $req['arr'] = Request::param('name/a', 'default');
  5. $req['get'] = Request::input();
  6. $req['post'] = Request::post();
  7. // 控制器和方法
  8. $req['controller'] = Request::controller();
  9. $req['action'] = Request::action();
  10. $req['baseUrl'] = Request::baseUrl();
  11. $req['baseFile'] = Request::baseFile();
  12. halt($req);

request类

3. 练习数据库链式操作

  1. $map = [];
  2. $map[] = ['status', '=', 1];
  3. $map[] = ['id', '<', 4];
  4. $map[] = ['img', 'like', '%/upload/%'];
  5. $res = Db::table('boke')->where($map)->field(['id', 'title', 'img'])->order('id', 'desc')->select()->toArray();
  6. halt($res);

链式操作

4. 博客实战,分类和搜索功能完成

1. 静态布局文件,博客实战

  1. 控制器和静态视图准备
  • 控制器 app\index\controller\index.php
  1. namespace app\index\controller;
  2. use think\facade\Db;
  3. use app\BaseController;
  4. use think\facade\View;
  5. use think\facade\Request;
  6. class Index extends BaseController
  7. {
  8. public function index()
  9. {
  10. return view::fetch();
  11. }
  12. }
  • 视图(继承基础模板) app\index\view\index\index.html
  1. {extend name='public/base'/}
  2. {block name='archive'}
  3. {__BLOCK__}
  4. {/block}
  5. <!-- 列表 -->
  6. {block name='list'}
  7. {__BLOCK__}
  8. {/block}
  9. <!-- 分页 -->
  10. {block name='pages'}
  11. {__BLOCK__}
  12. {/block}
  13. <!-- 侧栏模块 -->
  14. {block name='side'}
  15. {__BLOCK__}
  16. {/block}
  • app\index\view\public\base.html 基础模板
  1. {include file='public/header'/}
  2. <div class="container">
  3. <div class="row">
  4. <!-- 左侧列表 -->
  5. <div class="col-md-8">
  6. <div class="panel panel-default">
  7. {block name='archive'}
  8. <div class="panel-heading">Panel heading without title</div>
  9. {/block}
  10. <div class="panel-body">
  11. <!-- 列表 -->
  12. {block name='list'}
  13. <div class="row">
  14. <div class="col-md-12">
  15. <div class="panel panel-default">
  16. <div class="panel-body">
  17. <div class="row">
  18. <div class="col-sm-3 col-md-3">
  19. <a href="#" class="thumbnail">
  20. <img style="width:100%;max-height:110px;"
  21. src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTkyIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDE5MiAyMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzEwMCV4MjAwCkNyZWF0ZWQgd2l0aCBIb2xkZXIuanMgMi42LjAuCkxlYXJuIG1vcmUgYXQgaHR0cDovL2hvbGRlcmpzLmNvbQooYykgMjAxMi0yMDE1IEl2YW4gTWFsb3BpbnNreSAtIGh0dHA6Ly9pbXNreS5jbwotLT48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWyNob2xkZXJfMTc5YjM4ZDIyNTEgdGV4dCB7IGZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxMHB0IH0gXV0+PC9zdHlsZT48L2RlZnM+PGcgaWQ9ImhvbGRlcl8xNzliMzhkMjI1MSI+PHJlY3Qgd2lkdGg9IjE5MiIgaGVpZ2h0PSIyMDAiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSI3MC4wNDY4NzUiIHk9IjEwNC40NDM3NSI+MTkyeDIwMDwvdGV4dD48L2c+PC9nPjwvc3ZnPg=="
  22. alt="...">
  23. </a>
  24. </div>
  25. <div class="col-sm-9 col-md-9">
  26. <h3 style="margin-top: 0;">Thumbnail label</h3>
  27. <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id
  28. elit non mi porta gravida at eget metus. Nullam id dolor id nibh
  29. ultricies.</p>
  30. <p><a href="#" class="btn btn-primary" role="button">Button</a></p>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. {/block}
  38. <!-- 分页 -->
  39. {block name='pages'}
  40. <div class="row">
  41. <div class="col-md-12 text-center">
  42. <nav aria-label="Page navigation">
  43. <ul class="pagination">
  44. <li>
  45. <a href="#" aria-label="Previous">
  46. <span aria-hidden="true">&laquo;</span>
  47. </a>
  48. </li>
  49. <li><a href="#">1</a></li>
  50. <li><a href="#">2</a></li>
  51. <li><a href="#">3</a></li>
  52. <li><a href="#">4</a></li>
  53. <li><a href="#">5</a></li>
  54. <li>
  55. <a href="#" aria-label="Next">
  56. <span aria-hidden="true">&raquo;</span>
  57. </a>
  58. </li>
  59. </ul>
  60. </nav>
  61. </div>
  62. </div>
  63. {/block}
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 右侧侧栏 -->
  68. <div class="col-md-4">
  69. {block name='side'}
  70. <div class="panel panel-default">
  71. <div class="panel-heading">
  72. <h3 class="panel-title">Panel title</h3>
  73. </div>
  74. <div class="panel-body">
  75. <!-- Panel content -->
  76. <div class="list-group">
  77. <a href="#" class="list-group-item active">Cras justo odio<span class="badge"></span></a>
  78. <a href="#" class="list-group-item">Dapibus ac facilisis in<span class="badge"></span></a>
  79. <a href="#" class="list-group-item">Morbi leo risus<span class="badge"></span></a>
  80. <a href="#" class="list-group-item">Porta ac consectetur ac<span class="badge"></span></a>
  81. <a href="#" class="list-group-item">Vestibulum at eros<span class="badge"></span></a>
  82. </div>
  83. </div>
  84. </div>
  85. {/block}
  86. </div>
  87. </div>
  88. </div>
  89. {include file='public/footer'/}
  • app\index\view\public\header.html 公共头部
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>{$title|default="tpboke bootstrap"}</title>
  8. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
  9. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
  10. <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
  11. <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
  12. </head>
  13. <body>
  14. <!-- 导航 -->
  15. <nav class="navbar navbar-default navbar-static-top">
  16. <div class="container">
  17. <!-- Brand and toggle get grouped for better mobile display -->
  18. <div class="navbar-header">
  19. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  20. <span class="sr-only">Toggle navigation</span>
  21. <span class="icon-bar"></span>
  22. <span class="icon-bar"></span>
  23. <span class="icon-bar"></span>
  24. </button>
  25. <a class="navbar-brand" href="#">Brand</a>
  26. </div>
  27. <!-- Collect the nav links, forms, and other content for toggling -->
  28. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  29. <!-- 导航 -->
  30. <ul class="nav navbar-nav">
  31. <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
  32. <li><a href="#">Link</a></li>
  33. <li class="dropdown">
  34. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
  35. <ul class="dropdown-menu">
  36. <li><a href="#">Action</a></li>
  37. <li><a href="#">Another action</a></li>
  38. <li><a href="#">Something else here</a></li>
  39. <li role="separator" class="divider"></li>
  40. <li><a href="#">Separated link</a></li>
  41. <li role="separator" class="divider"></li>
  42. <li><a href="#">One more separated link</a></li>
  43. </ul>
  44. </li>
  45. </ul>
  46. <!-- 搜索 -->
  47. <form class="navbar-form navbar-right">
  48. <div class="form-group">
  49. <div class="input-group">
  50. <input type="text" class="form-control" placeholder="Search" name="search" value="" required="required" />
  51. <span class="input-group-btn"><button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
  52. </span>
  53. </div>
  54. </div>
  55. </form>
  56. </div>
  57. <!-- /.navbar-collapse -->
  58. </div>
  59. <!-- /.container-fluid -->
  60. </nav>
  61. <!-- 面包屑 -->
  62. <div class="container">
  63. <div class="row">
  64. <div class="col-md-12">
  65. <ol class="breadcrumb">
  66. <li><a href="#">Home</a></li>
  67. <li><a href="#">Library</a></li>
  68. <li class="active">Data</li>
  69. </ol>
  70. </div>
  71. </div>
  72. </div>
  • app\index\view\public\header.html 公共底部
  1. <div class="container">
  2. <div class="row">
  3. <div class="col-md-12">
  4. <p>&copy 2021 Company, Inc.</p>
  5. </div>
  6. </div>
  7. </div>
  8. </body>
  9. </html>
  1. 运行 bootstrap 完成静态布局博客图

静态模板

2. 分类和搜索功能完成

准备工作

  • 分类导入数据
  1. CREATE TABLE `cat` (
  2. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  3. `name` varchar(50) NOT NULL COMMENT '分类名',
  4. `sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
  5. `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态 1开启 0关闭',
  6. PRIMARY KEY (`id`)
  7. ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
  8. INSERT INTO `cat` VALUES ('1', 'Layui', '0', '1');
  9. INSERT INTO `cat` VALUES ('2', 'PHP', '0', '1');
  10. INSERT INTO `cat` VALUES ('3', 'ThinkPHP', '0', '1');
  11. INSERT INTO `cat` VALUES ('4', '前端', '0', '1');
  12. INSERT INTO `cat` VALUES ('5', '小程序', '0', '1');
  13. INSERT INTO `cat` VALUES ('6', '服务器', '0', '1');

导入分类

  1. 创建模型
  • 创建博客文章模型 app\index\model\Boke.php
  1. namespace app\index\model;
  2. use think\Model;
  3. class Boke extends Model
  4. {
  5. protected $pk = 'id';
  6. protected $name = 'boke';
  7. // 模型字段
  8. protected $schema = [
  9. 'id' => 'int',
  10. 'title' => 'string',
  11. 'img' => 'string',
  12. 'content' => 'string',
  13. 'date' => 'date',
  14. 'cat' => 'int',
  15. 'num' => 'int',
  16. 'hot' => 'int',
  17. 'status' => 'int'
  18. ];
  19. // 获取器
  20. public function getStatusAttr($value)
  21. {
  22. $status = [-1 => '删除', 0 => '禁用', 1 => '正常', 2 => '待审核'];
  23. return $status[$value];
  24. }
  25. }
  • 创建博客分类模型 app\index\model\Cat.php
  1. namespace app\index\model;
  2. use think\Model;
  3. class Cat extends Model
  4. {
  5. protected $pk = 'id';
  6. protected $name = 'cat';
  7. // 模型字段
  8. protected $schema = [
  9. 'id' => 'int',
  10. 'name' => 'string',
  11. 'sort' => 'int',
  12. 'status' => 'int'
  13. ];
  14. }
  1. 创建博客控制器 app\index\controller\index.php
  1. namespace app\index\controller;
  2. use think\facade\Db;
  3. use app\BaseController;
  4. use think\facade\View;
  5. use think\facade\Request;
  6. use app\index\model\Boke;
  7. use app\index\model\Cat;
  8. class Index extends BaseController
  9. {
  10. public function index()
  11. {
  12. $map[] = ['status', '=', 1];
  13. $archive = '最新文章';
  14. // 导航
  15. $catList = Cat::where($map)->select();
  16. view::assign('CatList', $catList);
  17. // 热门输出
  18. $hotList = Boke::where($map)->order('num', 'desc')->limit(5)->select();
  19. view::assign('hotList', $hotList);
  20. // 分类列表
  21. $cat = Request::get('cat/d', 0);
  22. view::assign('cat', $cat);
  23. if ($cat) {
  24. $map[] = ['cat', '=', $cat];
  25. $archive = Cat::where('id', $cat)->value('name');
  26. }
  27. // 搜索列表
  28. $search = Request::get('search', '');
  29. view::assign('search', $search);
  30. if ($search) {
  31. $map[] = ['title|content', 'like', "%{$search}%"];
  32. $archive = '搜索结果';
  33. }
  34. // 详情页
  35. $p = Request::get('p/d', 0);
  36. view::assign('p', $p);
  37. if ($p) {
  38. $map[] = ['id', '=', $p];
  39. $archive = '';
  40. // 阅读数自增
  41. Boke::where('id', $p)->inc('num')->update();
  42. }
  43. view::assign('archive', $archive);
  44. // 渲染输出
  45. $artList = Boke::where($map)->order('id', 'desc')->paginate([
  46. 'list_rows' => 2, // 分页2条每页
  47. 'query' => Request::param()
  48. ]);
  49. view::assign('artList', $artList);
  50. return view::fetch();
  51. }
  52. }
  1. 修改模型
  • 修改渲染分类 app\index\view\public\header.html
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>{$title|default="tpboke bootstrap"}</title>
  8. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
  9. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
  10. <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
  11. <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
  12. </head>
  13. <body>
  14. <!-- 导航 -->
  15. <nav class="navbar navbar-default navbar-static-top">
  16. <div class="container">
  17. <!-- Brand and toggle get grouped for better mobile display -->
  18. <div class="navbar-header">
  19. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  20. <span class="sr-only">Toggle navigation</span>
  21. <span class="icon-bar"></span>
  22. <span class="icon-bar"></span>
  23. <span class="icon-bar"></span>
  24. </button>
  25. <a class="navbar-brand" href="{:url('/')}">Brand</a>
  26. </div>
  27. <!-- Collect the nav links, forms, and other content for toggling -->
  28. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  29. <!-- 导航 -->
  30. <ul class="nav navbar-nav">
  31. {volist name='CatList' id='vo' key='k'}
  32. <li{if $vo.id === $cat || ($cat === 0 && $k === 1)} class="active"{/if}><a href="{:url('/', ['cat' => $vo.id])}">{$vo.name}</a></li>
  33. {/volist}
  34. <li class="dropdown">
  35. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
  36. <ul class="dropdown-menu">
  37. <li><a href="#">Action</a></li>
  38. <li><a href="#">Another action</a></li>
  39. <li><a href="#">Something else here</a></li>
  40. <li role="separator" class="divider"></li>
  41. <li><a href="#">Separated link</a></li>
  42. <li role="separator" class="divider"></li>
  43. <li><a href="#">One more separated link</a></li>
  44. </ul>
  45. </li>
  46. </ul>
  47. <!-- 搜索 -->
  48. <form class="navbar-form navbar-right">
  49. <div class="form-group">
  50. <div class="input-group">
  51. <input type="text" class="form-control" placeholder="Search" name="search" value="{$search}" required="required" />
  52. <span class="input-group-btn"><button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
  53. </span>
  54. </div>
  55. </div>
  56. </form>
  57. </div>
  58. <!-- /.navbar-collapse -->
  59. </div>
  60. <!-- /.container-fluid -->
  61. </nav>
  62. <!-- 面包屑 -->
  63. <div class="container">
  64. <div class="row">
  65. <div class="col-md-12">
  66. <ol class="breadcrumb">
  67. <li><a href="#">Home</a></li>
  68. <li><a href="#">Library</a></li>
  69. <li class="active">Data</li>
  70. </ol>
  71. </div>
  72. </div>
  73. </div>
  • 渲染主体,模板继承中实现 app\index\view\index\index.html
  1. {extend name='public/base'/}
  2. {block name='archive'}
  3. {if $archive}
  4. <div class="panel-heading">{$archive}</div>
  5. {/if}
  6. {/block}
  7. <!-- 列表 -->
  8. {block name='list'}
  9. {volist name='artList' id='vo' empty="暂无数据"}
  10. <div class="row">
  11. <div class="col-md-12">
  12. {if $p}
  13. <h1>{$vo.title}</h1>
  14. <p><span class="glyphicon glyphicon-time" aria-hidden="true"></span> {$vo.date} &nbsp; <span
  15. class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> {$vo.num}</p>
  16. <p>{$vo.content|raw}</p>
  17. {else /}
  18. <div class="panel panel-default">
  19. <div class="panel-body">
  20. <div class="row">
  21. {if $vo.img}
  22. <div class="col-sm-3 col-md-3">
  23. <a href="{:url('/', ['p' => $vo.id])}" title="{$vo.title}" class="thumbnail">
  24. <img alt="{$vo.title}" style="width:100%;max-height:110px;" src="{$vo.img}"
  25. alt="{$vo.title}">
  26. </a>
  27. </div>
  28. {/if}
  29. <div{if $vo.img} class="col-sm-9 col-md-9" {else/} class="col-sm-12 col-md-12" {/if}>
  30. <h3 style="margin-top: 0;"><a href="{:url('/', ['p' => $vo.id])}"
  31. title="{$vo.title}">{$vo.title}</a></h3>
  32. <p>{$vo.content|mb_strimwidth=0,110,'...','utf-8'}</p>
  33. <p><a href="{:url('/', ['p' => $vo.id])}" rel="nofollow" title="Reamd more"
  34. class="btn btn-primary" role="button">Read more...</a></p>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. {/if}
  40. </div>
  41. </div>
  42. {/volist}
  43. {/block}
  44. <!-- 分页 -->
  45. {block name='pages'}
  46. {empty name='p'}
  47. <div class="row">
  48. <div class="col-md-12 text-center">
  49. <nav aria-label="Page navigation">
  50. {$artList|raw}
  51. </nav>
  52. </div>
  53. </div>
  54. {/empty}
  55. {/block}
  56. <!-- 侧栏模块 -->
  57. {block name='side'}
  58. <div class="panel panel-default">
  59. <div class="panel-heading">
  60. <h3 class="panel-title">热门文章</h3>
  61. </div>
  62. <div class="panel-body">
  63. <!-- Panel content -->
  64. <div class="list-group">
  65. {volist name='hotList' id='vo' empty='暂无记录'}
  66. <a href="{:url('/', ['p' => $vo.id])}"
  67. class="list-group-item{if $p === $vo.id} active{/if}">{$vo.title}<span
  68. class="badge">{$vo.num}</span></a>
  69. {/volist}
  70. </div>
  71. </div>
  72. </div>
  73. {/block}
  1. 运行调试
  • 首页运行

实战博客

  • 分类页和分页

分类页和分页

  • 搜索和分页

搜索和分页

  • 内容页查看

内容页查看