标签:
查阅文档:
http://wenda.wecenter.com/question/1893
http://www.zhidiu.com/article/1012
http://wenda.wecenter.com/question/14010
http://wenda.wecenter.com/article/1253
1,在app/explore/main.php下添加
//99行添加模块
if (TPL::is_output(‘block/content_index.tpl.htm‘, ‘explore/index‘))
{
// $posts_list = $this->model(‘posts‘)->get_hot_posts(null, $category_info[‘id‘], null, $_GET[‘is_recommend‘], $_GET[‘page‘], 12);
$posts_list = $this->model(‘posts‘)->get_posts_list(question, $page = 1, $per_page = 10, $sort = null, $topic_ids = null, $category_id = null, $answer_count = null, $day = 30, $is_recommend = true);
TPL::assign(‘recommend_posts_list‘, $posts_list);
}
//添加模块,为什么用get_posts_list(),可查阅POST方法,在models/xx文件
2,新建模块文件:views/default/block/content_index.tpl.htm,内容为:
<div class="main">
<div class="focus">
<h2>精选问答</h2>
<ul>
<?php foreach ($this->recommend_posts_list AS $key => $val) { ?>
<li><a href="question/<?php echo $val[‘question_id‘]; ?>"><?php echo $val[‘question_content‘]; ?></a></a></li>
<?php } ?>
</ul>
</div>
</div>
标签:
原文地址:http://www.cnblogs.com/tanlingdangan/p/4435382.html