From 88b35c1182326790e16746ed5d62461631f1425d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 28 Nov 2008 01:40:55 +0000 Subject: Tags_Model::items() now lets you filter by item type --- modules/tag/models/tag.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index 59dd8d54..de892db2 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -25,14 +25,18 @@ class Tag_Model extends ORM { /** * Return all items associated with this tag. + * @param string $type the type of item (album, photo) * @param integer $limit number of rows to limit result to * @param integer $offset offset in result to start returning rows from * @return ORM_Iterator */ - public function items($limit=null, $offset=0) { - return ORM::factory("item") + public function items($limit=null, $offset=0, $type=null) { + $model = ORM::factory("item") ->join("items_tags", "items.id", "items_tags.item_id") - ->where("items_tags.tag_id", $this->id) - ->find_all($limit, $offset); + ->where("items_tags.tag_id", $this->id); + if ($type) { + $model->where("items.type", $type); + } + return $model->find_all($limit, $offset); } } \ No newline at end of file -- cgit v1.2.3