From 44c987e89e7fd3babebdc4835c1225b6d7869df1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 31 Dec 2008 07:06:10 +0000 Subject: Add sibling information on photo pages and a very simple next/previous interface. --- core/controllers/photos.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'core/controllers') diff --git a/core/controllers/photos.php b/core/controllers/photos.php index bb2a8510..82f9b779 100644 --- a/core/controllers/photos.php +++ b/core/controllers/photos.php @@ -25,11 +25,34 @@ class Photos_Controller extends Items_Controller { public function _show($photo) { access::required("view", $photo); + // We sort by id ascending so for now, find sibling info by doing id based queries. + $next_item = ORM::factory("item") + ->viewable() + ->where("parent_id", $photo->parent_id) + ->where("id >", $photo->id) + ->orderby("id", "ASC") + ->find(); + $previous_item = ORM::factory("item") + ->viewable() + ->where("parent_id", $photo->parent_id) + ->where("id <", $photo->id) + ->orderby("id", "DESC") + ->find(); + $position = ORM::factory("item") + ->viewable() + ->where("parent_id", $photo->parent_id) + ->where("id <=", $photo->id) + ->count_all(); + $template = new Theme_View("page.html", "photo"); $template->set_global("item", $photo); $template->set_global("children", array()); $template->set_global("children_count", $photo->children_count()); $template->set_global("parents", $photo->parents()); + $template->set_global("next_item", $next_item); + $template->set_global("previous_item", $previous_item); + $template->set_global("sibling_count", $photo->parent()->children_count()); + $template->set_global("position", $position); $template->content = new View("photo.html"); -- cgit v1.2.3