diff --git a/core/lib/Thelia/Core/Template/Element/LoopResult.php b/core/lib/Thelia/Core/Template/Element/LoopResult.php index f86ab203d..3ca1e91d3 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResult.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResult.php @@ -37,7 +37,7 @@ class LoopResult implements \Iterator public function __construct($modelCollection = null) { $this->position = 0; - if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) { + if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager || is_array($modelCollection)) { $this->modelCollection = $modelCollection; } } @@ -57,6 +57,17 @@ class LoopResult implements \Iterator return count($this->collection); } + public function getModelCollectionCount() + { + if ($this->modelCollection instanceof ObjectCollection || $this->modelCollection instanceof PropelModelPager) { + return $this->modelCollection->count(); + } elseif (is_array($this->modelCollection)) { + return count($this->modelCollection); + } else { + return 0; + } + } + /** * (PHP 5 >= 5.0.0)
* Return the current element diff --git a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php index 15bb287b1..9c4f93586 100755 --- a/core/lib/Thelia/Core/Template/Element/LoopResultRow.php +++ b/core/lib/Thelia/Core/Template/Element/LoopResultRow.php @@ -107,7 +107,7 @@ class LoopResultRow } if (true === $this->countable) { $this->set('LOOP_COUNT', 1 + $this->loopResult->getCount()); - $this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count()); + $this->set('LOOP_TOTAL', $this->loopResult->getModelCollectionCount()); } } } diff --git a/core/lib/Thelia/Core/Template/Loop/Feed.php b/core/lib/Thelia/Core/Template/Loop/Feed.php index 8e155a666..cf29cf3b7 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feed.php +++ b/core/lib/Thelia/Core/Template/Loop/Feed.php @@ -73,9 +73,14 @@ class Feed extends BaseLoop $limit = min(count($items), $this->getLimit()); - $loopResult = new LoopResult(); - + $indexes = array(); for ($idx = 0; $idx < $limit; $idx++) { + $indexes[] = $idx; + } + + $loopResult = new LoopResult($indexes); + + foreach ($indexes as $idx) { $item = $items[$idx]; @@ -87,7 +92,7 @@ class Feed extends BaseLoop $date = $item->get_date('d/m/Y'); - $loopResultRow = new LoopResultRow(); + $loopResultRow = new LoopResultRow($loopResult, null, $this->versionable, $this->timestampable, $this->countable); $loopResultRow->set("URL", $item->get_permalink()); $loopResultRow->set("TITLE", $item->get_title());