public function actionSearchart() { \Yii::$app->response->format = Response::FORMAT_JSON; $article = []; $articleid = $this->helpGquery('articleid', '0'); $type = $this->helpGquery('type', '1'); if (!empty($articleid)) { if ($type == 2) { $articleObj = new \common\models\Article(); $temp = $articleObj->List_ArticleByIds([$articleid]); if (!empty($temp)) { $article = $temp[0]; } } elseif ($type == 1) { $temp = Article::find()->where(['id' => $articleid])->asArray()->one(); if (!empty($temp)) { $temp['url'] = \Yii::getAlias("@domain") . '/article/' . date('Y/md', $temp['inputtime']) . '/' . $temp['id'] . '.shtml'; $article = $temp; } } } return $article; }
public static function getListByDiseaseid($condition = [], $offset = 0, $limit = 10, $orderBy = 'id DESC') { $article = new Article(); $articles = Article::find()->select(['id', 'title', 'description', 'inputtime', 'content'])->where($condition)->offset($offset)->limit($limit)->asArray()->all(); if (isset($articles) && !empty($articles)) { foreach ($articles as $key => &$article) { if (empty($article['description'])) { $article['description'] = String::cutString($article['content'], 66); } else { $article['description'] = String::cutString($article['description'], 66); } $article['url'] = '/article/' . date("Y/md", $article["inputtime"]) . '/' . $article['id'] . '.shtml'; } } return $articles; }
function get_disease_articles($match_count) { return \common\models\disease\Article::find()->where(['diseaseid' => 0, 'status' => 99])->andWhere(['ismatch' => 0])->limit($match_count)->all(); }
/** * 疾病症状 饮食护理 * @return type */ public function actionArticle() { $pinyin = $this->helpGquery('pinyin'); $result = $this->getColumn('cause', $pinyin); //获取基本信息及字段对应信息 $name = $result['info']['name']; $symptomid = $result['info']['id']; //症状基本信息 $model['id'] = $symptomid; $model['info'] = $result['info']; $model['content'] = $result['content']; $model['pinyin_initial'] = $pinyin; //设置title,keywords,description $this->setMeta($name, 'article'); //右侧公用信息 $rightTmp = $this->getRightInfo($symptomid, ['disease', 'articles', 'doctorInfos', 'relSymptom']); foreach ($rightTmp as $k => $v) { $model[$k] = $v; } //症状相关文章 $article_count = Article::find()->andWhere('symptomid=:symptomid', [':symptomid' => $symptomid])->count('id'); if ($article_count > 0) { $perpage = 20; $pagenum = $this->helpGparam('page', 1); $total = $article_count; $page = $pagenum <= $total / $perpage ? $pagenum : $total / $perpage; $paging = $this->helpPaging('pager_symptom_article')->setSize($perpage)->setPageSetSize(5); $paging->setUrlFormat(Url::to("@domain/zhengzhuang/{$pinyin}/article_list_%u.shtml")); $paging->setTotal($total)->setCurrent($page); $offset = $paging->getOffset(); $articles = $this->article->listByCondition([['status' => '99'], ['symptomid' => $symptomid]], $perpage, $offset, 'id DESC'); //查询结果 $model['articles'] = $articles; $model['paging'] = $paging; } else { if (isset($model['disid'])) { //通过疾病id查找【疾病与疾病文章关联表】得到疾病文章id $diseaseIdStr = implode(',', $model['disid']); $perpage = 20; $pagenum = $this->helpGparam('page', 1); $tmp = $this->article->getRecordsBySql($diseaseIdStr); $totalPage = $tmp[0]['num']; $page = $pagenum <= $totalPage / $perpage ? $pagenum : $totalPage / $perpage; $paging = $this->helpPaging('pager_symptom_article')->setSize($perpage)->setPageSetSize(5); $paging->setUrlFormat(Url::to("@domain/zhengzhuang/{$pinyin}/article_list_%u.shtml")); $paging->setTotal($totalPage)->setCurrent($page); $offset = $paging->getOffset(); $articles = $this->article->listBySqlCondition($diseaseIdStr, $perpage, $offset); //查询结果 $model['articles'] = $articles; $model['paging'] = $paging; } } //底部随机词 $randWords = $this->letterHotWordsBatch($name); $model['randWords'] = $randWords; return $this->render('article', ['model' => $model]); }