From 9d9cda4fbd8125e5c2e8b3425a88fcedeeaa9bae Mon Sep 17 00:00:00 2001 From: Neil Anderson Date: Thu, 17 Nov 2016 09:59:12 +0000 Subject: [PATCH 1/2] fix indenting --- lowblocks/variables/LowBlocksVariable.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lowblocks/variables/LowBlocksVariable.php b/lowblocks/variables/LowBlocksVariable.php index eda2e76..5b2882f 100644 --- a/lowblocks/variables/LowBlocksVariable.php +++ b/lowblocks/variables/LowBlocksVariable.php @@ -3,22 +3,21 @@ class LowBlocksVariable { - protected $criteria; public function __construct() { $this->criteria = craft()->elements->getCriteria(ElementType::MatrixBlock); } - - public function id($id) - { - $this->criteria->id = $id; - return $this->criteria->first(); - } - public function blocks() - { - return $this->criteria; - } + public function id($id) + { + $this->criteria->id = $id; + return $this->criteria->first(); + } + + public function blocks() + { + return $this->criteria; + } } \ No newline at end of file From 4932f71447b833818ec384fab6ebfc4687f5f100 Mon Sep 17 00:00:00 2001 From: Neil Anderson Date: Thu, 17 Nov 2016 09:59:28 +0000 Subject: [PATCH 2/2] add blocksParams() method This method allows for the use of object-based parameters when fetching block data. Feel free to rewrite into the class if you think it adversely affects the workings of the id() method! --- lowblocks/variables/LowBlocksVariable.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lowblocks/variables/LowBlocksVariable.php b/lowblocks/variables/LowBlocksVariable.php index 5b2882f..b5e4fc3 100644 --- a/lowblocks/variables/LowBlocksVariable.php +++ b/lowblocks/variables/LowBlocksVariable.php @@ -20,4 +20,9 @@ public function blocks() { return $this->criteria; } + + public function blocksParams($params) + { + return craft()->elements->getCriteria(ElementType::MatrixBlock, $params); + } } \ No newline at end of file