ThinkSNS-评论widget
查看全部词条命名空间:Main
导航: 上一页
模板调用举例:
{:W('Comment',array( 'type'=>'share','appid'=>$share['id'],
'mid'=>$share['toUid'],"face"=>getUserFace( $share['toUid'] ),'role'=>1,
'filed'=>"toUid"))}
功能说明:产生一个通用评论显示页面。需要在页面中自行定义一个回调js 函数commentSuccess(json)来发送通知和更新调用的应用评论数。比如下面分享的回调函数:
public function commentSuccess(){
//json 被反解析成了stdClass 类型
$result = json_decode(stripslashes($_POST['data']));
//计数更新
$this->model->setInc('comNum','id='.$result->appid);
//发送两条消息
$data['toUid'] = $result->toUid;
$need = $this->model->where('id='.$result->appid)->field('toUid, title')->find();
$data['uids'] =$need['toUid'];
$data['url'] = sprintf('%s/Index/content/id/%s/', , $result->appid);
$data['title_body']['comment'] = $result->comment;
$data['title_data']['title'] = sprintf("%s", $data['url'],
$need['title']);
$data['title_data']['type'] = '分享';
echo intval($this->api->comment_notify('share', $data, $this->appId));
}
参数说明:
参数 属性 空? 说明
type string 否 评论的类型
appid int 否 评论主体Id;比如说评论分享,就是这个分享的Id
mid int 否 评论主体的uid;比如说评论分享,就是这个分享主人toUid
face string 否 当前评论者的头像
role int 否 1,可以评论;2,提示:您无法评论,发布者设置好友可评论;3,您无法评论,发布者已经关闭评论。
补充说明:
评论的按钮激发后。是返回一个json数组。供回调函数commentSuccess(json)使用。
- json 数据格式:
- comment: 评论的内容
- type : 评论主体的类型,强烈建议使用应用名(英文)
- appid : 评论主体的id
- name : 评论者的名字
- uid : 评论者的id
- toId : 回复某一条评论,这条评论的id
- quietly: 是否是悄悄话1 是悄悄话,0 是非悄悄话
- id : 评论的id
- face : 评论者的头像完整路径
- toUid : 回复某一条评论,这条评论的uid
- 可以再回调js 中传递到action 里面进行各种操作。