网站开发(十三)首页文章循环显示和显示文章内容
2017-08-18 11:35
330 查看
首页文章循环显示效果
显示文章内容效果
一、首页文章循环显示
1、进入Home下的indexController.class.php,(因为首页文章都在first数据表中),所以要获取first所以数据,然后分配数据。所以在index的控制器中在index函数中添加代码
$first=D('first'); $firsts=$first->select(); $this->assign('firsts',$firsts);
2、首页文章与后台同步(动态)
1.进入Home/View/Index下的index.html2.对文章部分进行循环数据(volist)
3.对文章标题进行从数据库中读取
4.if判断是否有图片,若无图片显示一张无图片的图片(将无图片的图片存在根目录下的Uploads下)
5.加上时间函数,并加上时间戳
<volist name="list" id="vo"> <div class="list"> <ul> <li> <h1 class="title"><a href="#" >{$vo.f_title}</a></h1> <div class="info"><span>{$vo.time|date="Y-m-d",###}</span></div> <div class="thumb"> <a href="#" > <if condition="$vo['f_pic'] neq null"> <img width="1200" height="630" src="__ROOT__{$vo.f_pic}" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" /> <else/> <img width="1200" height="630" src="__ROOT__/Uploads/暂无图片.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" /> </if> </a></div> </li> </ul> </div> </volist>
文章循环显示完成
二、首页文章内容页
1.先创建首页文章内容页的html(在Home/View/Index下和index.html同级)article.html
article.html代码<!doctype html> <html lang="zh-CN" prefix="og: http://ogp.me/ns#"> <head> <title>文章页面</title> <include file="Common:header"/> <div class="body"> <div class="wrapper cls"> <div class="main"> <div class="list"> <ul> <li> <h1 class="title"><a href="#" >{$firsts.f_title}</a></h1> <div class="info"><span>{$firsts.time|date="Y-m-d",###}</span></div> <!-- 文章内容 --> {$firsts.f_content}<!-- 获取文章内容 --> <!-- 文章内容 --> </li> </ul> </div> <div class="list page b-page"> {$page} </div> </div> <include file="Common:right"/> <include file="Common:footer"/>
2.修改index.html中点击动态标题的超链接
href="__CONTROLLER__/article/id/{$vo.f_id}"
3.写控制器中article的方法
1.进入indexController.class.php创建article函数并写方法article函数代码
public function article(){ //进入article页面导航的蓝色背景 $cate=D('cate'); $cateid=1; $cateids=$cate->find($cateid); $this->assign('cateids',$cateids); //获取文章内容 $first=D('first'); $firstid=I('id'); $firsts=$first->find($firstid); $this->assign('firsts',$firsts); $this->display(); }
完成
相关文章推荐
- Flash组件开发研究(2):显示文章内容
- ASP.NET MVC5网站开发显示文章列表(九)
- 基于jquery的内容循环滚动小模块(仿新浪微博未登录首页滚动微博显示)
- 如何给wordpress首页自动显示文章内容的第一个图片
- Flash组件开发研究(2):显示文章内容
- Flash组件开发研究(2):显示文章内容
- 小模块:内容循环滚动(仿新浪微博未登录首页滚动微博显示)
- 网站开发(十一)实战后台首页管理和文章管理
- 首页不能显示文章内容
- ASP.NET动态网站开发培训-05.使用GridView显示数据库内容
- Hexo博客首页自动添加Read More标记-不在首页显示全部文章全部内容
- ASP.NET MVC5网站开发显示文章列表(九)
- 显示Z-Blog首页置顶文章摘要内容
- jQuery UI 实现图片循环显示,常用于网站首页banner广告切换
- 如何在首页只显示所有子网站的特定通知
- 网站首页必须具备哪些内容?
- 【PC网站前端架构探讨系列】结合公司网站首页,谈前端模块化开发与网站性能优化实践
- Android编程实现ListView内容无限循环显示的方法
- 网站首页内容该怎么规划?