phpcms V9首頁 頻道頁 列表頁 推薦位 簡單獲取文章瀏覽量和評論統計


phpcms V9首頁 頻道頁 列表頁 推薦位 簡單獲取文章瀏覽量和評論統計

列表取得數據方法:

{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
{loop $data $r}
{php $db = pc_base::load_model('hits_model');   $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));}
<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}
{$pages}
{/pc}

頻道頁獲取數據方法

{pc:content action="lists" catid="$v[catid]" num="5" order="id DESC"}
{loop $data $v}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));}
<li><a href="{$v[url]}" target="_blank"{title_style($v[style])}>{$v[title]}</a>點擊:{$views}評論數:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
{/pc}

 首頁獲取數據方法

{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
    {php $categorys = getcache('category_content_'.$siteid,'commons');}
                <ul class="list lh24 f14">
                {loop $info $v}
                 {php $category = $categorys[$v[catid]];}
                    {php $modelid = $category['modelid'];}
                   {php $db = pc_base::load_model('hits_model');   $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; }
                    {php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));} 
                 <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>
                {/loop}
                </ul>
                {/pc}

推薦位獲取數據方法

{pc:content action="position" posid="2" order="listorder DESC" num="4"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}

{loop $data $r}
{php $category = $categorys[$r[catid]];}
{php $modelid = $category['modelid'];}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$r[catid].'-'.$r[id].'-'.$modelid));}
<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>
<p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)}</p>
<div class="bk20 hr"><hr /></div>
{/loop} 
{/pc} 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM