设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 1565|回复: 2
打印 上一主题 下一主题

PHPCMS 调用点击量和评论 [复制链接]

Rank: 9Rank: 9Rank: 9

跳转到指定楼层
1#
莺子 发表于 2012-10-7 11:19:36 |只看该作者 |倒序浏览
PHPCMS V9二次开发之首页、频道、列表等调用浏览量和评论。
Phpcms V9 内容页加上此代码可统计到点击量今日:<span id="todaydowns"></span>,
本周:<span id="weekdowns"></span>,
本月:<span id="monthdowns"></span>
内容页统计代码:
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
其它:
一、首页获取数据方法
{pc:content action=”lists” catid=”$r[catid]” num=”5″ order=”id DESC” return=”info”}
{php $categorys = getcache(‘category_content_’.$siteid,’commons’);}
<ul>
{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=”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=”$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=”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><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><hr /></div>
{/loop}
{/pc}
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0

Rank: 5Rank: 5

2#
追忆☆到未来 发表于 2012-10-8 18:40:26 |只看该作者
没学过,路过看看

使用道具 举报

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

3#
混混@普宁.中国 实名认证  发表于 2012-10-10 00:13:01 |只看该作者
又厉害了

使用道具 举报

您需要登录后才可以回帖 登录 | 加入学盟

手机版|Scripts 学盟   |

GMT+8, 2024-4-26 16:52 , Processed in 1.063821 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部