当前位置:首页 > CMS教程 > phpcms > 列表

【phpcms-v9】phpcms-v9中首页、频道页、列表页如何显示文章的

发布:smiling 来源: PHP粉丝网  添加日期:2014-10-24 10:08:53 浏览: 评论:0 

【phpcms-v9】phpcms-v9中首页、频道页、列表页如何显示文章的浏览量和评论数:

1.列表页获取数据的方法:

  1. {pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"
  2.     
  3. {loop $data $r
  4.     
  5. {php $db = pc_base::load_model('hits_model');   $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; } 
  6.     
  7. {php $comment_tag = pc_base::load_app_class("comment_tag""comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));} 
  8.     
  9. <li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}</li>{/loop} 
  10.     
  11.     
  12.     
  13. {$pages
  14.     
  15. {/pc} 

2.频道页获取数据方法:

  1. {pc:content action="lists" catid="$v[catid]" num="5" order="id DESC"
  2.     
  3. {loop $data $v
  4.     
  5. {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; } 
  6.     
  7. {php $comment_tag = pc_base::load_app_class("comment_tag""comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));} 
  8.     
  9. <li><a href="{$v[url]}" target="_blank"{title_style($v[style])}>{$v[title]}</a>点击: {$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}</li> 
  10.     
  11. {/loop} 
  12.     
  13. {/pc} 

3.首页获取数据方法:

  1. {pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"
  2.     
  3.     {php $categorys = getcache('category_content_'.$siteid,'commons');} 
  4.     
  5.                 <ul class="list lh24 f14"
  6.     
  7.                 {loop $info $v
  8.     
  9.                  {php $category = $categorys[$v[catid]];} 
  10.     
  11.                     {php $modelid = $category['modelid'];} 
  12.     
  13.                    {php $db = pc_base::load_model('hits_model');   $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; } 
  14.     
  15.                     {php $comment_tag = pc_base::load_app_class("comment_tag""comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));} 
  16.     
  17.                  <li>·<a href="{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</li> 
  18.     
  19.                 {/loop} 
  20.     
  21.                 </ul> 
  22.     
  23.                 {/pc} 

4.推荐位获取数据方法:

  1. {pc:content action="position" posid="2" order="listorder DESC" num="4"
  2.     
  3. {php $categorys = getcache('category_content_'.$siteid,'commons');} 
  4.     
  5.     
  6. {loop $data $r
  7.     
  8. {php $category = $categorys[$r[catid]];} 
  9.     
  10. {php $modelid = $category['modelid'];} 
  11.     
  12. {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; } 
  13.     
  14. {php $comment_tag = pc_base::load_app_class("comment_tag""comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$r[catid].'-'.$r[id].'-'.$modelid));} 
  15.     
  16. <h4 class="blue"><a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</h4> //开源代码phpfensi.com 
  17.     
  18. <p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)}</p> 
  19.     
  20. <div class="bk20 hr"><hr /></div> 
  21.     
  22. {/loop} 
  23.     
  24. {/pc}

Tags: phpcms文章频道 phpcms文章评论数

分享到: