create prev next arg for content loop. Fix #361

This commit is contained in:
Manuel Raynaud
2014-04-30 10:22:12 +02:00
parent ed1be7019b
commit b15d52e6d3

View File

@@ -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);
}