phpcms 获取phpcms调用指定文章章的评论

phpcms v9调用全站最新文章标签的教程指南
09:51:08&&&来源:www.abcde.cn&&&评论: 点击:
phpcms v9这个程序很强大,基本都可以DIY出你想要的功能,下面就以PHPCMS标签扩展实例,它的主要功能就是调用指定栏目或者全站的最新信
& phpcms v9这个程序很强大,基本都可以DIY出你想要的功能,下面就以PHPCMS标签扩展实例,它的主要功能就是调用指定栏目或者全站的最新信息。
修改方法如下:
& 首先,修改phpcms\modules\content\classes content_tag.class.php 在最后面的 } 上面添加以下代码
public&function&newcontent($data){&
&&$num&=&intval($data['limit'])&?&intval($data['limit'])&:&'20';&
&&//&设置排序&
&&switch($data['order']){&
&&case&'1':&
&&$order&=&'&`id`&ASC&';&
&&case&'2':&
&&$order&=&'&`id`&DESC&';&
&&case&'3':&
&&$order&=&'&`inputtime`&ASC&';&
&&case&'4':&
&&$order&=&'&`inputtime`&DESC&';&
&&case&'5':&
&&$order&=&'&`updatetime`&ASC&';&
&&case&'6':&
&&$order&=&'&`updatetime`&DESC&';&
&&default:&
&&$order&=&'&`id`&DESC&';&
&&if($data['catid']){&
&&$catids&=&explode(',',&$data['catid']);&
&&foreach($catids&as&$catid){&
&&$catid&=&intval($catid);&
&&if(empty($catid))continue;&
&&$this-&set_modelid($catid);&
&&$where&=&$this-&category[$catid]['child']&?&'&`catid`&IN&('.$this-&category[$catid]['arrchildid'].')'&:&&&`catid`&=&$catid&;&
&&$datas&=&$this-&db-&select($where,&'*',&$num,&$order);&
&&$data[$catid]['data']&=&$&
&&$data['num'][]&=&count($datas);&
&&$model_num++;&
&&$models&=&getcache('model',&'commons');&
&&foreach($models&as&$model){&
&&$this-&db-&set_model($model['modelid']);&
&&$datas&=&$this-&db-&select('',&'*',&$num,&$order);&
&&$data[$model['modelid']]['data']&=&$&
&&$data['num'][]&=&count($datas);&
&&$model_num++;&
&&if($data){&
&&$num&=&ceil($num/$model_num);&
&&$w_num&=&$w_num_t&=&'';&
&&foreach($data['num']&as&$num_t){&
&&if($num_t&&&$num){&
&&$w_num&+=&$num-$num_t;&
&&$w_num_t++;&
&&if($w_num_t){&
&&$num&+=&ceil($w_num/($model_num-$w_num_t));&
&&$datas&=&array();&
&&foreach($data&as&$r){&
&&$r_n&=&'';&
&&if(is_array($r['data']))&
&&foreach($r['data']&as&$r_t){&
&&$datas[]&=&$r_t;&
&&if(++$r_n&==&$num)break;&
&&return&$&
&&return&false;&
&然后,进行模板调用
其实就和默认的文章列表调用差不多
{pc:content&action=&newcontent&&}&
catid: 可有可无 加了就只调用指定栏目的信息 多个栏目请使用英文半角的 ,间隔
order:排序 参数值:1-7 具体的含义在代码里面很容易看明白&
num:调用数量 不指定默认调用20条
最后提醒一下使用UTF编码的童鞋,编辑文件的时候勿用记事本,否则会乱码。
原文标题:phpcms v9调用全站最新文章标签的教程指南
原文地址:
版权归网络时代所有,转载请注明出处
相关热词搜索:
延伸阅读:
频道总排行
Warning: error_log(/home/wwwroot/www.abcde.cn/info/caches/error_log.php): failed to open stream: Permission denied in /home/wwwroot/www.abcde.cn/info/phpcms/libs/functions/global.func.php on line 487
频道本月排行
Warning: error_log(/home/wwwroot/www.abcde.cn/info/caches/error_log.php): failed to open stream: Permission denied in /home/wwwroot/www.abcde.cn/info/phpcms/libs/functions/global.func.php on line 487站在巨人的肩膀上做笔记!
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}
三、Phpcms首页面取得文章点击量及评论数量:
{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}
四、Phpcms推荐位取得文章点击量及评论数量:
{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}
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!扫一扫体验手机阅读
phpcms V9如何调用全站文章排行
<span type="1" blog_id="1562171" userid='
207篇文章,22W+人气,0粉丝
<span type="1" blog_id="1562171" userid='PHPcms调用相关文章 | 网络菜鸟学习园地
最新日志热评日志随机日志
日志总数:174 篇
评论总数:1 篇
标签数量:131 个
链接总数:0 个
建站日期:
运行天数:5673 天
最后更新:

我要回帖

更多关于 phpcms 获取文章内容 的文章

 

随机推荐