public function get_category_ids($category) {
$cateinfo = $this->fetch_one('category', 'id', "url_token = '".$category."' or id = '".$category."'");
$cateall = $this->fetch_all('category',"parent_id = ".$cateinfo);
$cate ='';
foreach ($cateall as $val) {
$cate .= $val['id'].',';
}
$category_ids = $cate.$cateinfo;
//print_r($category_ids);
return $category_ids;
}
以为考虑到$_GET['category']可能是别名或ID所以加了一步验证。
然后修改文章模块:models/category.php 的 get_articles_list 函数。(没有原函数代码啦)直接改成下面的代码就可以啦!
public function get_articles_list($category_id, $page, $per_page, $order_by) { if ($category_id) { $where = 'category_id IN ('.$category_id.')'; } return $this->fetch_page('article', $where, $order_by, $page, $per_page); }最后修改下app/article/main.php 中获取文章列表的代码。(因为官方的抒写风格不大喜欢所以调整了,具体在多少行我也不清楚了。)我将public function square_action() 作用的代码贴上自己对照着修改下。
if ($_GET['feature_id']) { $article_list = $this->model('article')->get_articles_list_by_topic_ids($_GET['page'], get_setting('contents_per_page'), 'add_time DESC', $this->model('feature')->get_topics_by_feature_id($_GET['feature_id'])); $article_list_total = $this->model('article')->article_list_total; if ($feature_info = $this->model('feature')->get_feature_by_id($_GET['feature_id'])) { $this->crumb($feature_info['title'], '/article/square/feature_info-' . $category_info['id']); TPL::assign('feature_info', $feature_info); } } else { if ($_GET['category']) { $category_ids = $this->model('category')->get_category_ids($_GET['category']); } $article_list = $this->model('article')->get_articles_list($category_ids, $_GET['page'], get_setting('contents_per_page'), 'add_time DESC'); $article_list_total = $this->model('article')->found_rows(); }因为只有这段修改了,所以没有贴完整的代码!有问题留言吧!
AI智能回复搜索中,请稍后...