diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-01-03 20:14:06 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-01-03 20:14:06 +0000 |
commit | 3d9e5e439e63404159c1ef763c8b07dd15a367ec (patch) | |
tree | fe7483df1a468f1443f60bc154edeb3fecd29a1f /core/models | |
parent | 8ed5200101ac6feb48795b2fd8b2fb4a3462d45e (diff) |
Stay on the right page when we navigate up in the breadcrumb.
Introduce a "show" parameter which contains the id of the item that we
want to show when we go to the parent's page.
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/item.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/models/item.php b/core/models/item.php index ffdaa7e9..6f56e726 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -234,4 +234,17 @@ class Item_Model extends ORM_MPTT { return model_cache::get("item", $this->album_cover_item_id); } + + /** + * Find the position of the given child id in this album. The resulting value is 1-indexed, so + * the first child in the album is at position 1. + */ + public function get_position($child_id) { + // Right now we only sort by id ascending, so bake that assumption in here. + // @todo fix this when we introduce sort orders. + return ORM::factory("item") + ->where("parent_id", $this->id) + ->where("id <=", $child_id) + ->count_all(); + } } |