From 983a893e8652c444646b511c817e9c0dd8a08945 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 24 Nov 2008 08:57:04 +0000 Subject: Show a link to the item with the most tags. --- core/controllers/welcome.php | 9 +++++++++ core/views/welcome.html.php | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 4f4f7535..a3e46214 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -47,8 +47,17 @@ class Welcome_Controller extends Template_Controller { try { $this->template->tag_count = ORM::factory("tag")->count_all(); + $this->template->most_tagged = Database::instance() + ->select("item_id AS id", "COUNT(tag_id) AS count") + ->from("items_tags") + ->groupby("item_id") + ->orderby("count", "DESC") + ->limit(1) + ->get() + ->current(); } catch (Exception $e) { $this->template->tag_count = 0; + $this->template->most_tagged = 0; } set_error_handler($old_handler); diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php index 154df8ce..c9277efd 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -177,7 +177,7 @@

- ( albums, photos, comments) + ( albums, photos, comments, tags)

add: [ @@ -231,6 +231,12 @@ (level ?> levels deep) + +

  • + id}", "Most tagged item") ?> + (count ?> tags) +
  • +
  • Profiling: get("use_profiler", false)): ?> on -- cgit v1.2.3