diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-31 07:06:10 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-31 07:06:10 +0000 |
commit | 44c987e89e7fd3babebdc4835c1225b6d7869df1 (patch) | |
tree | 217853f2c70b1c39c2e3687409287729dea7d18b /core | |
parent | b7f451635a043a98d75ccba3e69597e8ea11226f (diff) |
Add sibling information on photo pages and a very simple next/previous interface.
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/photos.php | 23 |
1 files changed, 23 insertions, 0 deletions
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"); |