/** * @return array a list of links that point to the post list filtered by every tag of this post */ public function getTagLinks() { $links = []; foreach (Tag::string2array($this->tags) as $tag) { $links[] = Html::a(Html::encode($tag), ['/blog/home/default/index', 'tag' => $tag]); } return $links; }
/** * @param int $limit * @return array */ public static function findTagWeights($limit = 20) { $models = Tag::find()->orderBy(['frequency' => SORT_DESC])->all(); $total = 0; foreach ($models as $model) { $total += $model->frequency; } $tags = []; if ($total > 0) { foreach ($models as $model) { $tags[$model->name] = 8 + (int) (16 * $model->frequency / ($total + 10)); } ksort($tags); } return $tags; }