diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2011-08-11 22:11:24 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2011-08-11 22:11:24 -0700 |
commit | c92d34a86b0515363f790056293cea2b0a738782 (patch) | |
tree | 9d5b794e434d26ef7ee50281b3ebee716e3327a5 /modules/tag/controllers | |
parent | a5b1972bbe9676479886ca94bb23f09407a87561 (diff) | |
parent | 933a34986dbca248f388e8aa3c3aea4a6d71a94b (diff) |
Merge branch 'displayContext' into display_context_compressed
Conflicts:
modules/gallery/controllers/movies.php
modules/gallery/controllers/photos.php
modules/tag/controllers/tag.php
Diffstat (limited to 'modules/tag/controllers')
-rw-r--r-- | modules/tag/controllers/tag.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 7786daa1..1628f0ac 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -22,7 +22,22 @@ class Tag_Controller extends Controller { $tag_id = $function; $tag = ORM::factory("tag")->where("id", "=", $tag_id)->find(); $page_size = module::get_var("gallery", "page_size", 9); - $page = (int) Input::instance()->get("page", "1"); + + $input = Input::instance(); + $show = $input->get("show"); + + if ($show) { + $child = ORM::factory("item", $show); + $index = tag::get_position($tag, $child); + if ($index) { + $page = ceil($index / $page_size); + $uri = "tag/$tag_id/" . urlencode($tag->name); + url::redirect($uri . ($page == 1 ? "" : "?page=$page")); + } + } else { + $page = (int) $input->get("page", "1"); + } + $children_count = $tag->items_count(); $offset = ($page-1) * $page_size; $max_pages = max(ceil($children_count / $page_size), 1); @@ -35,6 +50,10 @@ class Tag_Controller extends Controller { } $root = item::root(); + Display_Context::factory("tag") + ->set(array("tag" => $tag)) + ->save(); + $template = new Theme_View("page.html", "collection", "tag"); $template->set_global( array("page" => $page, |