这是php文件,请问如何在内容模板中写标题和内容呢?请大神给写一个单条内容的模板。谢谢了,,由于代码太长,我删了一部份,急用,谢谢各位好心人了

spArgs('uid')){$uid = (int) $this->spArgs('uid');$cond = "and b.uid = '$uid'";}if($this->spArgs('pagelimit')){$pageLimit = ($this->spArgs('pagelimit') < 30) ? $this->spArgs('pagelimit') : 30 ; //自定义分页}else{$pageLimit = $this->yb['show_page_num'];}//LEFT JOIN `".DBPRE."follow` AS f ON ( b.uid = f.touid and f.uid = '$uid' )$sql = "SELECT b. * , k.id AS likeid ,m.username,m.domainFROM `".DBPRE."blog` AS b LEFT JOIN `".DBPRE."likes` AS k ON ( b.bid = k.bid AND k.uid ='$this->uid' )LEFT JOIN `".DBPRE."member` as m on b.uid = m.uid where b.open = 1 $cond ORDER BY b.time desc";$data['blog'] = spClass('db_blog')->spPager($this->spArgs('page',1),$pageLimit)->findSql($sql);$data['page'] = spClass('db_blog')->spPager()->getPager();unset($data['page']['all_pages']);if(!empty($data['blog'])){foreach($data['blog'] as &$d){$this->foramt_feeds($d);}$this->api_success($data);}else{$this->api_success("");}}//获取单个博客function getOneBlog(){$bid = (int) $this->spArgs('bid');$sql = "SELECT b. * , k.id AS likeid ,m.username,m.domainFROM `".DBPRE."blog` AS b LEFT JOIN `".DBPRE."likes` AS k ON ( b.bid = k.bid AND k.uid ='$this->uid' )LEFT JOIN `".DBPRE."member` as m on b.uid = m.uid where b.open in (1,-2) and b.bid = '$bid'";$data['blog'] = spClass('db_blog')->findSql($sql);foreach($data['blog'] as &$d){$this->foramt_feeds($d,0);}$this->api_success($data);}//获取我关注的用户feedsfunction followfeeds(){$followuid = spClass('db_follow')->getFollowUid($this->uid);if($followuid){$sql = "SELECT b. * , k.id AS likeid ,m.username,m.domainFROM `".DBPRE."blog` AS b LEFT JOIN `".DBPRE."likes` AS k ON ( b.bid = k.bid AND k.uid ='$this->uid' )LEFT JOIN `".DBPRE."member` as m on b.uid = m.uid where b.open = 1";$sql .= " and b.uid in ($followuid) and b.open=1 ORDER BY b.time desc";$data['blog'] = spClass('db_blog')->spPager($this->spArgs('page',1),10)->findSql($sql);$data['page'] = spClass('db_blog')->spPager()->getPager();foreach($data['blog'] as &$d){$this->foramt_feeds($d);}}$this->api_success($data);}/*获取随机推荐图片列表,首页用的*/function recommendImg(){$type = 3; //获取图像$cachename = 'recommend_shuffle_'.$type; if(!spAccess('r',$cachename)){ $recommend = spClass('db_blog')->recommend_shuffle($type);foreach($recommend as $d){$body = split_attribute($d['body']);if(is_array($body['attr']['img'])){foreach($body['attr']['img'] as $img){$imgs[] = array('bid'=>$d['bid'],'uid'=>$d['uid'],'img'=>$img['url'],'username'=>$d['user']['username'],'h_url'=>goUserHome(array('uid'=>$d['user']['uid'])),'h_img'=>avatar(array('uid'=>$d['user']['uid'],'size'=>'small')),'b_url'=>goUserBlog(array('bid'=>$d['bid'],'domain'=>$d['user']['domain'],'uid'=>$d['user']['uid'])));}}} spAccess('w',$cachename,$imgs,86400); }else{ $imgs = spAccess('r',$cachename); } $count = count($imgs); $numbers = range (0,$count-1); shuffle($numbers); $queue = array_slice($numbers,0,1); $result = array(); foreach($queue as $d){ $result = $imgs[$d]; }$this->api_success($result);}//发现频道 随机发现最新的100个博客内容,取前15个function discoverBlog(){$num = ($this->spArgs('num')) ? $this->spArgs('num') : 15;$page = ($this->spArgs('page',0)) ? $num * ($this->spArgs('page')-1) : 0;$isshuffle = ($this->spArgs('isshuffle',0)) ? 1 : 0;$type = 'all';$cachename = 'recommend_shuffle_'.$type;if(!spAccess('r',$cachename)){$recommend = spClass('db_blog')->recommend_shuffle($type,150);//条数 15*10$data = array();foreach($recommend as $d){$body = split_attribute($d['body']);if($d['type'] == 1){$d['attr'] = ' ';}if($d['type'] == 3){$d['attr'] = $body['attr']['img'][0]['url'];}if($d['type'] == 2 || $d['type'] == 4){if(!empty($body['attr'])){if(is_array($body['attr'])){if( count($body['attr']) <= 1){if($body['attr']['type'] == 'yinyuetai'){ //对音乐台特殊处理$d['attr'] = 'index.php?c=blog&a=getyytimg&src=' . $body['attr']['img'];}else{$d['attr'] = $body['attr']['img']; //将图片返回给前台}}else{if($body['attr'][0]['type'] == 'yinyuetai'){ //对音乐台特殊处理$d['attr'] = 'index.php?c=blog&a=getyytimg&src=' . $body['attr'][0]['img'];}else{$d['attr'] = $body['attr'][0]['img']; //将图片返回给前台}}}}else{$d['attr'] =$body['attr'];}}if($d['attr']){$data[] = array('bid'=>$d['bid'],'title'=>$d['title'],'body'=>utf8_substr(strip_tags($body['body']),0,120),'type'=>$d['type'],'uid'=>$d['uid'],'username'=>$d['user']['username'],'b_url'=>goUserBlog(array('bid'=>$d['bid'],'domain'=>$d['user']['domain'],'uid'=>$d['user']['uid'])),'tag'=>($d['tag'] != '') ? array_shift((explode(',',$d['tag']))) : '','img'=>$d['attr']);}}unset($recommend);spAccess('w',$cachename,$data,86400);}else{ $data = spAccess('r',$cachename);}$count = count($data); $numbers = range (0,$count-1);if($isshuffle){shuffle($numbers);} $queue = array_slice($numbers,$page,$num); $result = array(); foreach($queue as $d){ $result[] = $data[$d]; }unset($data);$this->api_success($result);}/*发现频道 随机发现20个tag model 已缓存*/function discovertag(){$tags = spClass('db_tags')->discoverTag();$maxhit = 0;foreach($tags as &$d){if($d['hit'] > $maxhit){$maxhit = $d['hit'];}if(is_array($d['ulist'])){foreach($d['ulist'] as &$list){$list['h_url'] = goUserHome(array('uid'=>$list['uid'], 'domain'=>$list['domain']));$list['h_img'] = avatar(array('uid'=>$list['uid'],'size'=>'small'));}}}$data = array();$data['maxhit'] = $maxhit;$data['data'] = $tags;$this->api_success($data);}/*推荐频道 推荐用户*/function recommendUser(){//如果是自动推荐模式if($this->yb['recomm_switch'] != 1){$data = spClass('db_tags_blog')->findUserBytid($this->spArgs(),$this->uid);foreach($data['data'] as & $d){$d['h_url'] = goUserHome(array('uid'=>$d['uid'], 'domain'=>$d['domain']));$d['h_img'] = avatar(array('uid'=>$d['uid'],'size'=>'big'));$d['logtime'] = ybtime(array('time'=>$d['logtime']));$d['sign'] = strip_tags($d['sign']);$d['isfollow'] = ($d['isfollow'] == $this->uid) ? true: false;$d['blogtag'] = ($d['blogtag'] != '' ) ? explode(',',$d['blogtag']) : '';}}else{}$this->api_success($data);}/*首页获取评论*/function reply(){$bid = $this->spArgs('bid');$result = spClass('db_replay')->spLinker()->spPager($this->spArgs('page',1),$this->spArgs('limit',10))->findAll(array('bid'=>$bid),'time desc','');$pager = '';$data = array();$data['page'] = spClass('db_replay')->spPager()->getPager();foreach($result as &$d){$d['msg'] = strip_tags(strreplaces($this->parse_uid($d['msg'])));$d['h_url'] = goUserHome(array('uid'=>$d['uid'], 'domain'=>$d['domain']));$d['h_img'] = avatar(array('uid'=>$d['uid'],'size'=>'small'));$d['time'] = ybtime(array('time'=>$d['time']));$d['del_flag'] = islogin() ? 1:0;$d['rep_flag'] = ( $this->uid != $d['uid'] && $this->uid != '') ? 1:0;}$data['body'] = $result;$this->api_success($data);}//处理feeds给前端显示//$split 是否截断内容private function foramt_feeds(& $d,$split=1){$d['more'] = 0;$d['h_url'] = goUserHome(array('uid'=>$d['uid'], 'domain'=>$d['domain']));$d['h_img'] = avatar(array('uid'=>$d['uid'],'size'=>'middle'));$d['b_url'] = goUserBlog(array('bid'=>$d['bid'],'domain'=>$d['domain'],'uid'=>$d['uid']));$d['tag'] = ($d['tag'] != '') ? explode(',',$d['tag']) : '';$d['time_y'] = date('Y.m',$d['time']);$d['time_d'] = date('d',$d['time']);$d['time'] = ybtime(array('time'=>$d['time']));$rs = split_attribute($d['body']); $d['attr'] = $rs['attr'];$d['repto'] = $rs['repto'];if(!empty($d['repto'])){$d['repto']['h_url'] = goUserHome(array('uid'=>$d['repto']['uid'], 'domain'=>$d['repto']['domain']));$d['repto']['h_img'] = avatar(array('uid'=>$d['repto']['uid'],'size'=>'small'));}else{$d['repto'] = null;}if($split == 1){$d['body'] = utf8_substr(strip_tags($rs['body'],'

'),0,500);}else{$d['body'] = strip_tags($rs['body'],'

');}if($d['body'] == false){$d['body'] = '';}$d['more'] = (utf8_strlen($rs['body']) > 500) ? 1: 0;//处理音乐和视频if($d['type'] == 2 || $d['type'] == 4){if(count($d['attr']) > 4){$d['mode'] = 1;if($split == 1){$d['attr'] = array_slice($d['attr'],0,4);}}}//处理图片,超过10个就任务moreif($d['type'] == 3){if($split == 1){if($d['attr']['count'] > 10){$d['attr']['img'] = array_slice($d['attr']['img'],0,10);$d['mode'] = 1;}}}//如果显示全部则把more改成0if($split != 1){$d['show_reply'] = 1; //展开评论}}}

回复讨论(解决方案)

你贴出的代码只是如何取得数据

并没给出数据如何写到模板

你贴出的代码只是如何取得数据

并没给出数据如何写到模板

这是模板是JS调用的,我不想用js调用,想直接写到模板里{include file="theme/default/header.html" titles=$data.title}{include file="require_models_js.html"}

{include file="theme/default/userheader.html"}

{if !empty($data.0.tag)}{foreach $data.0.tag as $d}

{if isset($adunit.6) && $adunit.6.is_show == 1}

{/if}

谁喜欢{$fava.count}{if $fava.count !=0}

{foreach from=$fava.rs item=d}{/foreach}{/if}

{include file="theme/default/aside.html"}{include file="theme/default/footer.html"}

那就需要看到到达浏览器的 html 代码,并从其中分析出数据是如何读取的

那就需要看到到达浏览器的 html 代码,并从其中分析出数据是如何读取的 您看一下这个网站www.shanzhaicun.com

好像就是这个 yb_load_feeds 函数吧,贴出他的代码

你那些紧凑格式的 js 看得人头发晕

好像就是这个 yb_load_feeds 函数吧,贴出他的代码

你那些紧凑格式的 js 看得人头发晕 我也找不到这个在哪里

好像就是这个 yb_load_feeds 函数吧,贴出他的代码

你那些紧凑格式的 js 看得人头发晕 看到这样的代码是不是您要看的template('feed_template', '{each blog as data i}

{include tpl_header_define(\'header\') data} {include tpl_feed_define(data.type) data} {if data.show_reply ==1} {include tpl_header_define(\'infooter\') data} {else} {include tpl_header_define(\'footer\') data} {/if} {/each}');template('tmpl_model_header', '

{time_y}

{time_d}

{if attr.length >0} {each attr as img i} {if i <1}

{/if} {/each} {/if} {body}');template('tmpl_model_2', '

{if attr.length > 0} {each attr as m i} {if m.type == \'local\'}

{if m.title != \'null\' && m.author != \'null\'} {else} {/if} {/if} {if m.type == \'yinyuetai\'}

{m.title}

{m.author}

{/if} {/each} {/if} {if body}

{body} {/if}');

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

如何在php中写内容,请问如何在内容模板中写标题和内容呢相关推荐

  1. smarty中使用php函数,在smarty模板中使用PHP函数的方法

    在smarty模板中使用PHP函数的方法 发布于 2014-11-23 22:57:51 | 174 次阅读 | 评论: 0 | 来源: 网友投递 Smarty模板引擎Smarty是一个使用PHP写出 ...

  2. html语言可以写模版继承吗,16-Django的模板语言(变量,标签,过滤器,继承,html转义)...

    模板语言 模板语言简称为DTL(Django Template Language) 模板变量 模板变量名由数字,字母,下划线和点组成,不能以下划线开头. 使用:{{模板变量名}} def index2 ...

  3. Java导出数据到Word模板中

    Java导出数据到Word模板. 前言 网上的方案 需求介绍 模板 简介 使用体验 poi-tl Freemarker 操作步骤 总结 前言 相信很多人都会遇到Java导出的业务,Java导出主要有导 ...

  4. UWP 查找模板中的控件

    UWP 查找模板中的控件 原文:UWP 查找模板中的控件 这个标题我也不知道咋起,意思说一下你就明白. 1. 对官方控件的模板进行定制修改,以满足多样化需求,还有漂亮的UI 比如ListView,Gr ...

  5. freemarker模板中long类型问题

    在用freemarker做模板的时候碰到了long类型对数字做了格式化,用逗号分隔,id的时候容易出问题 解决方案: 模板文件中直接tostring输出: ${num.toString()}   在模 ...

  6. java 文件追加 变大_用java写在doc中追加内容代码时,为什么它只能写入一次内容,后面都只是增加文件的大小,不增加内容啊?...

    用java写在doc中追加内容代码时,为什么它只能写入一次内容,后面都只是增加文件的大小,不增加内容啊? 答案:1  信息版本:手机版 电脑版 解决时间 2020-07-02 16:34 已解决 20 ...

  7. 微信html5页面开发教程,微信网页开发,如何在H5页面中设置分享的标题,内容以及缩略图...

    前言 最近的需求是做一个移动端H5的长屏广告页,最后需要在微信分享的时候修改文案以及带上图片,这个实现起来也不是很复杂. 实现步骤 先绑定域名,先登录微信公众平台进入"公众号设置" ...

  8. 如何在Linux中创建目录,并且在新建目录文件中用vi编译器输入内容

    .如何创建目录文件 第一步:我们使用mkdir 来创建一个新目录 ,目录名根据自己需求,我这里命名为 director. 语法: mkdir [选项]目录名     -m 创建新目录的同时设置目录权限 ...

  9. 如何在IDEA中创建web项目并且部署到Tomcat中

    如何在IDEA中创建web项目并且部署到Tomcat中 步骤1:File->New Project, 步骤2:选择Project SDK为1.7 -> Next -> Finish( ...

最新文章

  1. NC:电缆细菌减少水稻种植土壤中的甲烷排放
  2. 如何删除Android上ListViews之间的行?
  3. 像不像等待项目上线的你
  4. Python中os与sys两模块的区别
  5. Apache如何将HTTP重定向到HTTPS
  6. python 搭建web应用程序_用Python构建数据科学Web应用程序
  7. r 语言 ggplot上添加平均值_R语言自定义两种统计量度:平均值和中位数,何时去使用?
  8. Maven 连接私服资源库配置
  9. 【20180202】使用iptables做MySQL的端口转发
  10. 微信小程序,用户拒绝授权后重新授权;uni-app小程序,用户拒绝授权后点击无效;重新进入后拉起位置授权框;
  11. [html] 精确获取页面元素位置的方式有哪些?
  12. HDU 4870 Rating(高斯消元 )
  13. 生成XML文件的步骤 解析XML文件
  14. 【洛谷P1169】[ZJOI2007]棋盘制作
  15. 黑鲨官网装机大师工具如何制作u盘启动盘,u盘启动盘制作方法
  16. android无线投屏到电视盒子,如何把电脑视频投屏到智能电视/电视盒子上?
  17. IT桌面运维常识系列 -(Windows部署服务 - 01)
  18. Cousera吴恩达机器学习week8笔记
  19. Justinmind恢复30天试用 For Mac
  20. python 高级部分

热门文章

  1. java el表达式 导航规则_javaweb之EL表达式语言
  2. SVN trunk(主线) branch(分支) tag(标记) 用法详解和详细操作步骤
  3. 如何更改指定用户在windows系统目录的权限
  4. 计算机设计文献参考,优秀计算机设计论文参考文献 计算机设计论文参考文献数量是多少...
  5. c语言文件打开函数,C语言fopen函数中文件打开方式(参数值)
  6. 盘点2010年十大出版事件 文著协“宣战”百度文库
  7. legend2---开发日志16
  8. Python爬虫入门教程 6-100 蜂鸟网图片爬取之一
  9. 想靠大数据创业 你需要了解什么
  10. oracle的SCN和Checkpoint_Change#的关系