ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 知识点 1、准备工作 2、列表页添加链接 3、内容页:当前位置 4、内容页:具体内容 [TOC] ## 一、准备工作 ### 1、新建模板article_info.html 位置:application\index\view\default\index\article_info.html ### 2、控制器 ~~~ public function info(){ $id = input('id',0); return view('../application/index/view/default/index/article_info.html'); } ~~~ ### 3、模板加链接地址 #### 文章链接 ~~~ <a href="{:url('info',['id'=>$vo.id])}" rel="bookmark">{$vo.title}</a> ~~~ #### 分类链接 ~~~ <a href="{:url('category',['id'=>$vo.catid])}">{$vo.catname}</a> ~~~ ## 二、列表页添加链接 ### 文章链接 ~~~ {:url('info',['id'=>$vo.id])} ~~~ ### 分类链接 ~~~ {:url('category',['id'=>$vo.catid])} ~~~ ## 三、内容页:当前位置 ### (一)控制器:获取文章信息 ~~~ public function info(){ $id = input('id',0); $info = Db::name('article')->where('id',$id)->find(); $catinfo = getCatInfoById($info['catid']); $p_catname = getCatInfoById($catinfo['parentid'],'catname'); $this->assign('info',$info); $this->assign('catid',$info['catid']); $this->assign('catname',$catinfo['catname']); $this->assign('p_catname',$p_catname); return view('../application/index/view/default/index/article_info.html'); } ~~~ ### (二)内容页:模板 #### 1、当前位置(导航) ~~~ {block name="notice"} <nav class="breadcrumb"> <a href="/">首页</a>&nbsp;>&nbsp; <a href="javascript:(0)">{$p_catname}</a>&nbsp;>&nbsp; <a href="{:url('category',['id'=>$catid])}">{$catname}</a> </nav> {/block} ~~~ ## 四、内容页:具体内容 ### 1、模板布局 ~~~ {block name="main"} 左侧内容 {/block} {block name="sidebar"} 右侧边栏 {/block} ~~~ ### 2、模板左侧 ~~~ {block name="main"} <article class="post type-post status-publish format-standard hentry category-ality-original tag-ality-original tag-wordpress"> <header class="entry-header"><h1>{$info.title}</h1></header> <div class="entry-content"> <div class="single-content">{$info.content}</div> <div class="clear"></div> <footer class="single-footer"> <ul class="single-meta"> <li class="comment"><a href="#">查看评论</a></li> <li class="views">阅读 {$info.views}</li> <li class="r-hide"><a href="javascript:pr()" onclick="javascript:this.innerHTML=(this.innerHTML=='隐藏边栏'?'显示边栏':'隐藏边栏');">隐藏边栏</a></li> </ul> </footer> <div class="clear"></div> </div> </article> {/block} ~~~ ### 3、模板右侧 ~~~ {block name="sidebar"} <aside class="widget widget_hot_commend"> <h3 class="widget-title"><i class="fa-bars fa"></i>本站推荐</h3> <div id="hot" class="hot_commend"> <ul> {article:recommend name="vo" catid="$catid" num="6" /} <li> <figure class="thumbnail"><a href="{:url('info',['id'=>$vo.id])}"><img src="__UPLOADS__/{$vo.thumb}" alt="{$vo.title}"></a></figure> <div class="hot-title"><a href="{:url('info',['id'=>$vo.id])}">{$vo.title}</a></div> <div class="views">阅读 {$vo.views}</div> <i class="fa-thumbs-o-up fa"> 0</i> </li> {/article:recommend} </ul> <div class="clear"></div> </div> </aside> <aside class="widget widget_hot_post"> <h3 class="widget-title"><i class="fa-bars fa"></i>热门文章</h3> <div id="hot_post_widget"> <ul> {article:hot name="vo" catid="$catid" num="10"} <li><span class="li-icon li-icon-{$key+1}">{$key+1}</span><a href="{:url('info',['id'=>$vo.id])}">{$vo.title}</a></li> {/article:hot} </ul> </div> </aside> {/block} ~~~ ### 4、隐藏边栏 ~~~ <footer class="single-footer"> <ul class="single-meta"> <li class="comment"><a href="#">查看评论</a></li> <li class="views">阅读 {$info.views}</li> <li class="r-hide"> <a href="javascript:pr()" onclick="javascript:this.innerHTML=(this.innerHTML=='隐藏边栏'?'显示边栏':'隐藏边栏');">隐藏边栏 </a> </li> </ul> </footer> ~~~