filter with contentFolder table for finding next/prev content

This commit is contained in:
Manuel Raynaud
2014-04-30 10:32:17 +02:00
parent b15d52e6d3
commit 270b5f6499

View File

@@ -202,6 +202,7 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
public function parseResults(LoopResult $loopResult) public function parseResults(LoopResult $loopResult)
{ {
/** @var \Thelia\Model\Content $content */
foreach ($loopResult->getResultDataCollection() as $content) { foreach ($loopResult->getResultDataCollection() as $content) {
$loopResultRow = new LoopResultRow($content); $loopResultRow = new LoopResultRow($content);
@@ -224,14 +225,19 @@ class Content extends BaseI18nLoop implements PropelSearchLoopInterface
if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { if ($this->getBackend_context() || $this->getWithPrevNextInfo()) {
$defaultFolderId = $content->getDefaultFolderId();
// Find previous and next category // Find previous and next category
$previous = ContentQuery::create() $previous = ContentQuery::create()
->joinContentFolder()
->where('ContentFolder.folder_id = ?', $defaultFolderId)
->filterByPosition($content->getPosition(), Criteria::LESS_THAN) ->filterByPosition($content->getPosition(), Criteria::LESS_THAN)
->orderByPosition(Criteria::DESC) ->orderByPosition(Criteria::DESC)
->findOne() ->findOne()
; ;
$next = ContentQuery::create() $next = ContentQuery::create()
->joinContentFolder()
->where('ContentFolder.folder_id = ?', $defaultFolderId)
->filterByPosition($content->getPosition(), Criteria::GREATER_THAN) ->filterByPosition($content->getPosition(), Criteria::GREATER_THAN)
->orderByPosition(Criteria::ASC) ->orderByPosition(Criteria::ASC)
->findOne() ->findOne()