Feature #11740

Paginate viewhelper should be possible to handle non-query-result objects

Added by Armin Ruediger Vieweg over 4 years ago. Updated over 3 years ago.

Status:Closed Start date:2010-12-27
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:Widgets
Target version:-
Has patch:No

Description

Hello,

sometimes it is necessary to use an object storage or an array instead of an query result. If this is the case, it is not possible to use the default paginate viewhelper anymore, cause it is requiering a Tx_Extbase_Persistence_QueryResultInterface.

I've copied the widget and changed it to work with array. This is my indexAction of PaginateController:

    public function indexAction($currentPage = 1) {
        // set current page
        $this->currentPage = (integer)$currentPage;
        if ($this->currentPage < 1) {
            $this->currentPage = 1;
        } elseif ($this->currentPage > $this->numberOfPages) {
            $this->currentPage = $this->numberOfPages;
        }

        $i = 0;
        $itemsPerPage = (integer)$this->configuration['itemsPerPage'];
        $modifiedObjects = array();
        $indexMin = $itemsPerPage * ($this->currentPage - 1);
        $indexMax = $itemsPerPage * $this->currentPage - 1;

        foreach ($this->objects as $object) {
            if ($i >= $indexMin && $i <= $indexMax ) {
                $modifiedObjects[] = $object;
            }
            $i++;
        }

        $this->view->assign('contentArguments', array(
            $this->widgetConfiguration['as'] => $modifiedObjects
        ));
        $this->view->assign('configuration', $this->configuration);
        $this->view->assign('pagination', $this->buildPagination());
    }

Of cause you would have to remove the requirement of Tx_Extbase_Persistence_QueryResultInterface in PaginateViewHelper (Line 76 and 71) and PaginateController (Line 34) too.

This example is for arrays only, but if you make a check of the objecttype you can consolidate the support of queryResults (current) and arrays (this code example).

And it is relatively less work.


Related issues

related to Core - Feature #34944: Paginate viewhelper should be possible to handle non-quer... Resolved 2012-03-16

History

#1 Updated by Armin Ruediger Vieweg over 4 years ago

Hello,

I've written for an experimental extension the paginate controller which supports QueryResults, ObjectStorages and simple arrays.

You'll find them in the repository of the pw_teaser extension.

Kind regards
~Armin

#2 Updated by Roland Waldner over 3 years ago

[post deleted]

#3 Updated by Armin Ruediger Vieweg over 3 years ago

Ehm, sure that this discussion has anything to do with my feature request? xD
I'm not!

#4 Updated by Roland Waldner over 3 years ago

you are right, sorry!

this threat should be associated to the ticket:

http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2012-March/011988.html

#5 Updated by Roland Waldner over 3 years ago

maybe this is a stupid question: should this be an extbase/TYPO3 v4 feature request or should this be a flow3/phoenix feature request. i guess this section of forge is the flow3/phoenix one, isn't it? i opened the same ticket in the extbase/TYPO3 v4 section of forge and related it to this ticket. what do you think?

#6 Updated by Armin Ruediger Vieweg over 3 years ago

oh lol, yes! You are right. I'm in the wrong topic.
Thanks!

#7 Updated by Roland Waldner over 3 years ago

:-)

maybe you want to vote for the ticket in the extbase section?

http://forge.typo3.org/issues/34944

#8 Updated by Roland Waldner over 3 years ago

this ticket could then be closed, couldn't it? i have not the rights to do it...

#9 Updated by Armin Ruediger Vieweg over 3 years ago

me neither...

#10 Updated by Karsten Dambekalns over 3 years ago

  • Status changed from New to Closed
  • Has patch set to No

Also available in: Atom PDF