diff --git a/src/Controllers/TagController.php b/src/Controllers/TagController.php index efd014a1..5353b5d9 100644 --- a/src/Controllers/TagController.php +++ b/src/Controllers/TagController.php @@ -34,6 +34,7 @@ class TagController } else { + $this->context->highestUsage = TagSearchService::getMostUsedTag()['post_count']; $this->context->transport->paginator = new StdClass; $this->context->transport->paginator->page = $page; $this->context->transport->paginator->pageCount = $pageCount; diff --git a/src/Models/SearchServices/TagSearchService.php b/src/Models/SearchServices/TagSearchService.php index 8dd01040..77ed578d 100644 --- a/src/Models/SearchServices/TagSearchService.php +++ b/src/Models/SearchServices/TagSearchService.php @@ -5,4 +5,16 @@ class TagSearchService extends AbstractSearchService { $stmt->addColumn(new SqlAliasFunctor(new SqlCountFunctor('post_tag.post_id'), 'post_count')); } + + public static function getMostUsedTag() + { + $stmt = new SqlSelectStatement(); + $stmt->setTable('post_tag'); + $stmt->addColumn('tag_id'); + $stmt->addColumn(new SqlAliasFunctor(new SqlCountFunctor('post_tag.post_id'), 'post_count')); + $stmt->setGroupBy('post_tag.tag_id'); + $stmt->setOrderBy('post_count', SqlSelectStatement::ORDER_DESC); + $stmt->setLimit(1, 0); + return Database::fetchOne($stmt); + } } diff --git a/src/Views/tag-list.phtml b/src/Views/tag-list.phtml index 5532ad6f..5e6ff792 100644 --- a/src/Views/tag-list.phtml +++ b/src/Views/tag-list.phtml @@ -25,7 +25,7 @@ context->transport->tags)): ?>

No tags to show.

- context->transport->tags)); ?> + context->highestUsage ?> '_query_']) ?>