Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 类型3 6.2流体分页未按预期工作_Typo3_Fluid_Extbase_Typo3 6.2.x_Typo3 4.5 - Fatal编程技术网

Typo3 类型3 6.2流体分页未按预期工作

Typo3 类型3 6.2流体分页未按预期工作,typo3,fluid,extbase,typo3-6.2.x,typo3-4.5,Typo3,Fluid,Extbase,Typo3 6.2.x,Typo3 4.5,我的TYPO3 6.2(从TYPO3 4.5升级)流体分页显示所有项目,而不是5个项目 我的存储库方法: public function getRandomLocation($iLimit) { $query = $this->createQuery(); $result = $query->statement("Select * FROM tx_sfel_domain_model_ttblocationsproduktegruppen WHERE hidd

我的TYPO3 6.2(从TYPO3 4.5升级)流体分页显示所有项目,而不是5个项目

我的存储库方法:

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(); 
}
我的控制器代码:

$aSResultsLocations = $this->tTBLocationsProdukteGruppenRepository->getRandomLocation($iLimit);
$this->view->assign('aSResultsLocations', $aSResultsLocations);
我的模板:


.................
//获取所有项目,而不是5个项目。
TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller\PaginateController.php indexaction()中,我得到以下结果

代码:

$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();
我从这里得到的价值是:

$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计数=26

但我需要将“$modifiedObjects计数”设为5

我认为以下内容不适用于我的查询对象

$query->setLimit($itemsPerPage);
$query->setOffset((int)($itemsPerPage * ($this->currentPage - 1)));
我认为这个问题与我在paginate中使用的查询对象有关。 如何为TYPO3 6.2流体分页创建查询对象


请帮助我。

为了解决上述问题,我以extbase查询格式重建了查询。在typo3 6.2.x中,paginate将不适用于查询语句,因此我们需要将其转换为extbase查询格式

我重建的查询格式是

$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();

不能将语句与paginate一起使用,因为paginate将在执行之前更改原始语句。仅当它是通过查询生成器创建的查询时,才能执行此操作。谢谢您的支持。你的暗示对我帮助很大。我使用查询生成器重建了查询,ti现在正在工作。您好,为了解决上述问题,我以extbase查询格式重建了查询。在typo3 6.2.x中,paginate将不适用于查询语句,因此我们需要将其转换为extbase查询格式。请将重建的查询添加为答案,而不是使用注释。