public function category($category_id = 0) { $map['category'] = $category_id; $map['status'] = 1; $questionModel = new QuestionModel(); $hot_list = $questionModel->getList($map, '*', 5, 'answer_num desc'); foreach ($hot_list as &$val) { $val['info'] = msubstr(op_t($val['description']), 0, 50); } unset($val); $this->assign('hot_list', $hot_list); $this->display(T('Application://Question@Widget/category')); }
private function _getList($map, $page = 1, $r = 20) { $questionModel = new QuestionModel(); $questionAnswerModel = new QuestionAnswerModel(); list($list, $totalCount) = $questionModel->getListPageByMap($map, $page, 'create_time desc', $r, '*'); foreach ($list as &$val) { $val['info'] = msubstr(op_t($val['description']), 0, 200); $val['img'] = get_pic($val['description']); $val['user'] = query_user(array('uid', 'space_url', 'nickname'), $val['uid']); if ($val['best_answer']) { $val['best_answer_info'] = $questionAnswerModel->getData(array('id' => $val['best_answer'], 'status' => 1)); } else { $val['best_answer_info'] = $questionAnswerModel->getData(array('question_id' => $val['id'], 'status' => 1), 'support desc'); } if ($val['best_answer_info']) { $val['best_answer_info']['content'] = msubstr(op_t($val['best_answer_info']['content']), 0, 200); } } return array($list, $totalCount); }
private function _getList($map, $limit, $order) { $questionModel = new QuestionModel(); $questionAnswerModel = new QuestionAnswerModel(); $list = $questionModel->getList($map, '*', $limit, $order); foreach ($list as &$val) { $val['info'] = msubstr(op_t($val['description']), 0, 200); $val['img'] = get_pic($val['description']); $val['user'] = query_user(array('uid', 'space_url', 'nickname', 'avatar64'), $val['uid']); if ($val['best_answer']) { $val['best_answer_info'] = $questionAnswerModel->getData(array('id' => $val['best_answer'], 'status' => 1)); } else { $val['best_answer_info'] = $questionAnswerModel->getData(array('question_id' => $val['id'], 'status' => 1), 'support desc'); } if ($val['best_answer_info']) { $val['best_answer_info']['content'] = msubstr(op_t($val['best_answer_info']['content']), 0, 200); } } return $list; }