WeCenter一些常用的数据调用介绍
目前WeCenter程序很多数据都是可以通过调用来实现内容展现和布局的。在前端调用的数据代码都可以在相对应的app文件里的main.php找到对应的代码。熟悉这些数据调用的代码有利于我们对模板进行二次开发。**注**:每组数据都对应的模块调用,比如首页这组数据对应的就是home里面的模板。
**全局用户信息**
{{{ <?php if ($this->user_id) { ?> :这个表示如果用户登录就显示后面的东西,其中user_id就表示用户id的意思;
<?php echo $this->user_info['notification_unread']; ?> : 表示输出用户未读的通知;
<?php echo $this->user_info['user_name']; ?> :表示输出用户名字;
<?php if ($this->user_info['inbox_unread'] != 0) {?> :输出用户未读私信;
<?php if ($this->user_info['invitation_available']) { ?> :输出用户可以邀请的好友数量;}}}
**首页相关:**
{{{$val['question_info'] : 问题信息;
<?php echo get_avatar_url($val['user_info']['uid'], 'mid'); ?> : 用户头像;
<?php echo $val['link']; ?><?php echo $val['title']; ?> : 问题链接和问题标题;
$val['add_time']) : 问题发布时间;
$val['article_info']['comments'] : 文章评论;
<?php _e('%s 个评论', $val['article_info']['comments']); ?> : 文章评论数量;
<?php _e('%s 个回复', $val['question_info']['answer_count']); ?> : 问题回答数量;
$val['topics'] : 话题;
$val['question_info']['question_id'] : 问题id;
$val['answer_info'] : 回答者信息;
$val['answer_info']['uid']: 回答者用户ID;
$val['answer_info']['agree_count'] : 回答者被赞同的数量;
$val['answer_info']['agree_users'] : 赞同用户;
<?php echo nl2br(strip_ubb(cjk_substr($val['answer_info']['answer_content'], 0, 130, 'UTF-8', '...'))); ?> : 输出回答摘要
$val['answer_info']['answer_content'] : 回答内容;
$val['answer_info']['attachs'] : 回答内容里的附件;
$t_val['is_image'] : 回答里的附件是否为图片;
$t_val['attachment'] : 回答里的附件的url;
$t_val['file_name'] : 回答里附件的文件名字;
$val['answer_info']['comment_count'] : 回答里的评论数量;}}}
**发现页面相关:**
{{{<?php echo $this->posts_list_bit; ?> : 发现页面的内容列表,调用的是ajax文件夹里的list.tpl.htm内容;
<?php echo $this->pagination; ?> : 翻页按钮的内容;
$this->feature_info : 专题信息;
$this->feature_info['id'] : 专题id;
$this->category_info['id'] : 分类id;
$val['question_id : 问题id;
$val['question_content'] : 问题内容;
$val['question_id' : 问题id;
$val['topics'] : 话题;
$t_val['topic_id'] : 话题id;
$t_val['topic_title'] : 话题标题;
<?php echo get_avatar_url($answer_user['uid'], 'mid'); ?> : 回答者头像;
$val['category_info']['title'] : 分类标题;
$val['answer']['user_info']['user_name'] : 回答者用户名;
$val['focus_count'] :关注数量;
$val['answer_count'] : 回复数量;
$val['view_count'] : 浏览量;
date_friendly($val['update_time'] : 发布时间;
$this->content_nav_menu as $key => $val : 专题导航菜单;}}}
**文章相关:**
{{{<?php echo $this->article_info['title']; ?> : 输出文章标题;
$this->user_info['permission']['is_administortar'] OR $this->user_info['permission']['is_moderator'] : 用户信息(是管理员还是作者);
$this->article_info['is_recommend'] : 文章被推荐;
$this->article_topics as $key => $val : 文章话题;
$this->article_info['message'] : 文章内容;
$this->article_info['attachs'] : 文章附件;
$attach['is_image'] : 附件是否是图片;
$attach['file_name'] : 附件名字;
$this->article_info['votes'] : 文章赞同按钮;
$this->article_info['vote_info']['rating'] : 文章投票信息;
$this->article_info['vote_users'] : 赞同文章用户;
<?php _e('%s 个评论', $this->comments_count); ?> : 文章评论数量;
$this->comments AS $key => $val : 文章评论(其实类似的很多后面跟了$key => $val是一个数组一样的,它还包括几个其他的调用文件,比如这个还包括子元素里的$val['user_info']['user_name'] 评论者姓名等等内容,这里我们就不去一一介绍了。)
<?php echo nl2br($val['message']); ?> : 输出文章内容;
$this->article_info['lock'] : 文章锁定;
$this->article_info['anonymous'] : 匿名作者;
$this->article_info['user_info']['integral'] : 积分;
$this->article_info['user_info']['reputation'] : 威望;
$this->reputation_topics , $this->reputation_topics AS $key => $val : 擅长话题;
$val['topic_id'] : 话题id;
$val['topic_title'] : 话题标题;
$this->question_related_list : 相关问题;
$this->article_list : 文章列表;
$this->article_topics[$val['id'] : 文章标题id;
<?php echo FORMAT::parse_attachs(nl2br(FORMAT::parse_markdown($val['message']))); ?> : 输出文章内容;
<?php if (cjk_strlen($val['message']) > 130) { ?> : 截取文章130个字;
$this->hot_articles AS $key => $val : 热门文章;
$this->content_nav_menu as $key => $val : 专题分类导航;
$val['child'] AS $_key => $_val :二级分类;
$val['icon'] : 图片导航;
$val['description'] : 描述;
$this->user_info['invite_count'] : 邀请数量;}}}
**问题页面相关**
{{{$this->question_info['question_content'] : 问题内容;
$this->question_info['lock'] : 锁定问题;
$this->question_info['is_recommend'] : 推荐问题;
$this->question_info['ip'] : 问题ip;
$this->question_topics as $key => $val : 问题标签;
$this->question_info['lock'] : 锁定问题;
$this->user_info['permission']['edit_question_topic'] : 编辑问题标签;
$this->related_topics AS $key => $topic_title : 相关话题;
$this->question_info['attachs'] : 问题附件;
$this->question_related_links : 问题相关链接;
$this->question_info['add_time'] : 问题发布时间;
$this->invite_users : 邀请用户回答;
$val['answer_content'] : 问题评论内容
$this->question_info['comment_count'] : 问题评论数量;
$this->question_info['question_id'] : 问题ID;
$this->question_thanks : 感谢提问者;
$this->question_info['update_time'] : 问题最新活动时间;
$this->question_info['view_count'] : 问题浏览量;
$this->question_info['focus_count'] : 问题关注数;
$this->question_related_list AS $key => $val) : 相关问题列表;
$this->question_info['best_answer'] : 最佳回复;
$val['user_rated_thanks'] : 感谢回复者;
$val['user_rated_uninterested'] : 没有帮助;
$this->question_info['question_detail'] : 问题描述;}}}
**发布**
{{{$this->question_category_list : 问题分类列表;
$this->recent_topics : 最近话题;
$this->human_valid : 验证码;
$this->article_category_list : 文章分类列表;
$this->article_info['message'] : 文章内容;
$this->article_topics : 文章标签;}}}
**话题页面相关**
{{{$this->redirect_message : 重定向内容;
$this->topic_info['topic_lock'] : 话题被锁定;
$this->topic_info['focus_count'] : 关注话题人数;
<?php echo $this->all_questions_list_bit; ?> :输出全部问题列表;
<?php echo $this->best_questions_list_bit; ?> : 输出精华问题列表;
<?php echo $this->articles_list_bit; ?> :输出文章列表;
$this->topic_info['topic_description'] : 话题描述;
$this->best_answer_users AS $key => $val : 最佳回复者;
$this->log_list : 话题修改记录;
$this->user_info['permission']['edit_topic'] :编辑话题;
$this->user_info['permission']['manage_topic'] : 管理话题;
$this->topics_list :话题列表;
$val['discuss_count'] : 该话题下的问题数量;
$val['focus_count'] : 该话题的关注人数;
$this->today_topic['topic_id'] : 今日话题id;
$this->today_topic['topic_title'] : 今日话题标题;
$this->today_topic['topic_description'] : 今日话题描述;}}}
**用户页面**
{{{$this->user['uid'] : 用户uid;
$this->user['verified'] : 用户认证;
$this->user['friend_count'] :关注人数;
$this->friends_list : 关注人数列表;
$this->user['fans_count'] : 粉丝数量;
$this->fans_list : 粉丝列表;
$this->focus_topics : 关注的话题;
$this->custom_group : 用户组;
$val['group_name'] : 用户组名称;
$val['group_id'] : 用户组id;
$this->feature_list : 专题列表;
$this->users_list : 用户列表;}}}
**其他**
{{{$this->feature_info['topic_count'] : 专题话题数量;
$this->sidebar_hot_topics AS $key => $val : 专题页面下的侧边栏热门话题;
$val['discuss_count'] : 专题下面的问题数量;
$this->feature_info['css'] : 自定义专题页面的css;
$this->favorite_tags : 收藏的标签;}}}
2014-07-08 21:56
2014-07-08 18:38
2014-07-08 17:16
2014-07-08 16:57