From 39954ad0b77800b3d4935430794adf18c2625148 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 8 Mar 2009 16:29:01 +0000 Subject: Implement Sortable albums. Current sort fields include (Creation Date, Update Date, Random Key, Title, Mime Type, Item Type & Number of views) --- core/libraries/ORM_MPTT.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'core/libraries/ORM_MPTT.php') diff --git a/core/libraries/ORM_MPTT.php b/core/libraries/ORM_MPTT.php index 7e89bf6f..6b493e88 100644 --- a/core/libraries/ORM_MPTT.php +++ b/core/libraries/ORM_MPTT.php @@ -142,10 +142,14 @@ class ORM_MPTT_Core extends ORM { * @param integer SQL offset * @return array ORM */ - function children($limit=null, $offset=0) { - return $this->where("parent_id", $this->id) - ->orderby("id", "ASC") - ->find_all($limit, $offset); + function children($limit=null, $offset=0, $orderby=null) { + $this->where("parent_id", $this->id); + if (empty($orderby)) { + $this->orderby("id", "ASC"); + } else { + $this->orderby($orderby); + } + return $this->find_all($limit, $offset); } /** -- cgit v1.2.3