typo3fluidextbasetypo3-6.2.xtypo3-4.5

TYPO3 6.2 fluid pagination not working as expected


My TYPO3 6.2 (Upgraded from TYPO3 4.5) fluid paginate displays all the items instead of 5 items.

My Repository Method :

public function getRandomLocation($iLimit)
{
    $query = $this->createQuery();
    $result = $query->statement("Select * FROM      tx_sfel_domain_model_ttblocationsproduktegruppen WHERE hidden = 0 AND deleted = 0 AND logo != '' ORDER BY uid LIMIT 0, ".$iLimit." ");
    return $result->execute(); 
}

My controller code :

$aSResultsLocations = $this->tTBLocationsProdukteGruppenRepository->getRandomLocation($iLimit);
$this->view->assign('aSResultsLocations', $aSResultsLocations);

My template :

    <f:widget.paginate objects="{aSResultsLocations}" as="aSResultsLocationss" configuration="{itemsPerPage: 5, insertAbove: 1 insertBelow: 1}"> 

                <f:for each="{aSResultsLocationss}" as="aSResultsLocation">
                     .................

                     //Getting all the items instead of 5 items.

                </f:for>
    </f:widget.paginate> 

In TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller\PaginateController.php indexaction() I'm getting following results.

Code :

$itemsPerPage = (int)$this->configuration['itemsPerPage'];

$query = $this->objects->getQuery();
$query->setLimit($itemsPerPage);
if ($this->currentPage > 1) {
     $query->setOffset((int)($itemsPerPage * ($this->currentPage - 1)));
}
$modifiedObjects = $query->execute();

Values I got from here are :

$itemsPerPage : 5

$query : Select * FROM tx_sfel_domain_model_ttblocationsproduktegruppen WHERE hidden = 0 AND deleted = 0 AND (jahr = '13' OR jahr = '14' OR jahr = '15') AND logo != '' ORDER BY uid LIMIT 0, 26

$modifiedObjects count = 26

But I need '$modifiedObjects count' as 5.

I think Following are not working for my query object,

$query->setLimit($itemsPerPage);
$query->setOffset((int)($itemsPerPage * ($this->currentPage - 1)));

I think this issue is something related to my query object using in the paginate. How to create query object for TYPO3 6.2 fluid paginate??

Please help me.


Solution

  • To fix the above issue i rebuilt the query in extbase query format. In typo3 6.2.x paginate will not work with query statement so we need to convert it into extbase query format.

    My rebuilt query format is,

    $constraints = array(); 
    $subConstraints = array(); 
    $query = $this->createQuery(); 
    
    foreach($PublicationYears as $year) 
         $subConstraints[] = $query->equals('jahr', $year); 
    
    $constraints[] = $query->logicalOr($subConstraints); 
    
    $constraints[] = $query->logicalNot( $query->equals('logo', '') ); 
    
    $query->matching($query->logicalAnd($constraints)); 
    
    $query->setLimit((integer)$iLimit); 
    
    $Result = $query->execute();