[TYPO3-mvc] Problems with widget.paginate ViewHelper

g4-lisz at tonarchiv.ch g4-lisz at tonarchiv.ch
Thu Sep 8 17:16:02 CEST 2011


On 08.09.2011 16:44, Franz Koch wrote:
> Hi,
>
>> I always get this error:
>> "PHP Catchable Fatal Error: Argument 1 passed to
>> Tx_Fluid_ViewHelpers_Widget_PaginateViewHelper::render() must implement
>> interface Tx_Extbase_Persistence_QueryResultInterface, instance of
>> Tx_Extbase_Persistence_LazyObjectStorage given in
>> /var/www/typo3_src-4.5.3/typo3/sysext/fluid/Classes/ViewHelpers/Widget/PaginateViewHelper.php 
>>
>> line 76"
>>
>> The action looks like this:
>> public function galleryAction(Tx_Myextension_Domain_Model_Collection
>> $collection) {
>> $this->view->assign('collection', $collection);
>> }
> ...
>> what exactly should be assigned to the view?
>
> the paginate widget needs a QueryResult object, usually returned by 
> your repository.
>
> $records = $this->myRepository->findByFoo($foo);
> $this->view->assign('records', $records);
>
> <f:widget.paginate objects="{records}"...
>
>
> It doesn't work with arrays or objectStorages yet, so if you need that 
> feature, you would have to write your own, extended version of the 
> paginate widget that can also deal arrays and objectStorages. Or add a 
> feature/pull request and hope to get that feature in for the upcoming 
> Fluid 1.4.
Ah ok i see,

so i have to do something like

$repository = new Tx_Myextension_Domain_Repository_CollectionRepository();
$query = $repository->createQuey();
$query->matching(...);
$this->view->assign('collection', $query->execute());

This should work (AFAK findByFoo() returns $query->execute(), too)?

Thank you



More information about the TYPO3-project-typo3v4mvc mailing list