diff --git a/core/lib/Thelia/Core/Template/Loop/Content.php b/core/lib/Thelia/Core/Template/Loop/Content.php index 8185929eb..e567b13ac 100644 --- a/core/lib/Thelia/Core/Template/Loop/Content.php +++ b/core/lib/Thelia/Core/Template/Loop/Content.php @@ -53,6 +53,7 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface Argument::createIntListTypeArgument('folder_default'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('current_folder'), + Argument::createBooleanTypeArgument('with_prev_next_info', false), Argument::createIntTypeArgument('depth', 1), Argument::createBooleanOrBothTypeArgument('visible', 1), Argument::createAnyTypeArgument('title'), @@ -221,6 +222,29 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface ->set("VISIBLE" , $content->getVisible()) ; + + if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { + // Find previous and next category + $previous = ContentQuery::create() + ->filterByPosition($content->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() + ; + + $next = ContentQuery::create() + ->filterByPosition($content->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + + $loopResultRow + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ; + } + $loopResult->addRow($loopResultRow); }