diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-09 14:38:25 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-03-09 14:38:25 +0000 |
commit | b9ee37f30effee856dc963b38751f3e904fd8ddf (patch) | |
tree | 3d7b4360923923e4972029c156281df9c4c6daaa /core/libraries/ORM_MPTT.php | |
parent | ac82e0a9dff9511eaf97bb7fc6f25add762583a4 (diff) |
Override the ORM_MTTP::children and ORM_MTPP::descendants methods in
the item model and always pass the orderby fields. This insures that
all children or descendant calls will respect the album sort order.
Diffstat (limited to 'core/libraries/ORM_MPTT.php')
-rw-r--r-- | core/libraries/ORM_MPTT.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index 6b493e88..f59aa084 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -140,6 +140,7 @@ class ORM_MPTT_Core extends ORM { * @chainable * @param integer SQL limit * @param integer SQL offset + * @param array orderby * @return array ORM */ function children($limit=null, $offset=0, $orderby=null) { @@ -170,17 +171,21 @@ class ORM_MPTT_Core extends ORM { * @param integer SQL limit * @param integer SQL offset * @param string type to return + * @param array orderby * @return object ORM_Iterator */ - function descendants($limit=null, $offset=0, $type=null) { + function descendants($limit=null, $offset=0, $type=null, $orderby=null) { $this->where("left >", $this->left) ->where("right <=", $this->right); if ($type) { $this->where("type", $type); } - // @todo: make the order column data driven - $this->orderby("id", "ASC"); + if (empty($orderby)) { + $this->orderby("id", "ASC"); + } else { + $this->orderby($orderby); + } return $this->find_all($limit, $offset); } |