网站开发(十三)首页文章循环显示和显示文章内容
来源:互联网 发布:java专业技能怎么写 编辑:程序博客网 时间:2024/05/22 06:16
首页文章循环显示效果
显示文章内容效果
一、首页文章循环显示
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.html
2.对文章部分进行循环数据(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(); }
完成
阅读全文
1 0
- 网站开发(十三)首页文章循环显示和显示文章内容
- 首页不能显示文章内容
- ECSHOP修改文章列表显示文章内容提要
- 网站的首页显示(表格标签)
- Flash组件开发研究(2):显示文章内容
- wordpress 首页文章显示摘要
- 关于长文章如何分页显示文章内容的一点建议
- asp.net 关于列表问题。点击文章标题,显示文章内容。
- 织梦5.7 后台添加文章,文章内容框不能显示
- 文章内容分页显示函数
- 文章内容过长显示省略号
- 网站开发(十一)实战后台首页管理和文章管理
- wordpress首页文章显示reade more
- hexo 首页文章只显示一部分
- 首页信息显示,网站优化(缓存,静态)
- 手动分页方式显示文章内容
- 让wordpress首页和分类列表页只显示文章标题列表
- Ecshop模板开发(二十三):手机版显示商城
- mybatis对于传入的多个参数的处理
- cookie跨域清除
- POJ 3616 Milking Time (基础DP)
- zcmu-1668: 高桥和低桥
- Android学习心得(一)记录一个问题
- 网站开发(十三)首页文章循环显示和显示文章内容
- python获取网页amf的信息
- kafka工作原理
- 《任正非致新员工书》
- jquery.cookies.js
- Banner加载轮播图
- 01-用户管理
- linux环境,Tomcat 指定运行时 jdk的版本
- iOS之《Effective Objective-C 2.0》读书笔记(6)