Project

General

Profile

Actions

Feature #34944

closed

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

Added by most wanted over 12 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2012-03-16
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description


Files

Actions #1

Updated by most wanted over 12 years ago

--- quote ---

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.

--- /quote ---

Actions #2

Updated by Ingo Pfennigstorf about 12 years ago

  • Category set to 964
  • Status changed from New to Accepted
  • Target version set to 6.1.0
Actions #3

Updated by Ingo Pfennigstorf about 12 years ago

  • Target version changed from 6.1.0 to 1910
Actions #4

Updated by Max Messing almost 12 years ago


            // Modified to let it work with non query result interfaces
            if(is_a($this->objects, 'Tx_Extbase_Persistence_QueryResultInterface')){
                $query = $this->objects->getQuery();
                $query->setLimit($itemsPerPage);
                if ($this->currentPage > 1) {
                    $query->setOffset((integer)($itemsPerPage * ($this->currentPage - 1)));
                }
                $modifiedObjects = $query->execute();
            }else{
                $offset = 0;
                if ($this->currentPage > 1) {
                    $offset = ((integer)($itemsPerPage * ($this->currentPage - 1)));
                }
                $modifiedObjects = array_slice($this->objects->toArray(), $offset, (integer)$this->configuration['itemsPerPage']);
            }

Actions #5

Updated by Anja Leichsenring almost 12 years ago

  • Project changed from 534 to 2559
  • Category changed from 964 to Fluid: Widgets
  • Target version deleted (1910)
Actions #6

Updated by Mohamed Rebai about 11 years ago

Is this feature going to be implemented or not ? I need to apply a pagination on a array!

Actions #7

Updated by Gerrit Code Review about 11 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25687

Actions #8

Updated by Gerrit Code Review about 11 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25687

Actions #9

Updated by Gerrit Code Review about 11 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25687

Actions #10

Updated by Alexander Opitz about 10 years ago

  • Project changed from 2559 to TYPO3 Core
  • Category changed from Fluid: Widgets to Fluid
Actions #11

Updated by Gerrit Code Review almost 10 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #12

Updated by Gerrit Code Review almost 10 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #13

Updated by Gerrit Code Review almost 10 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #14

Updated by Gerrit Code Review almost 10 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #15

Updated by Gerrit Code Review almost 10 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #16

Updated by Gerrit Code Review almost 10 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #17

Updated by Gerrit Code Review almost 10 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #18

Updated by Gerrit Code Review almost 10 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #19

Updated by Gerrit Code Review almost 10 years ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #20

Updated by Gerrit Code Review almost 10 years ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/25687

Actions #21

Updated by Tom Ruether almost 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #22

Updated by Julian Stock about 9 years ago

This problem has been solved 8 months ago and it's still not merged into the core? w00t! :D (Tried v6.2.15)

Actions #23

Updated by Bernhard Eckl almost 9 years ago

I replaced the two files, is there any cache to delete to get it to work then? I cleared all caches with no change…

Actions #24

Updated by Tilo Baller almost 9 years ago

Bernhard Eckl wrote:

I replaced the two files, is there any cache to delete to get it to work then? I cleared all caches with no change…

Clearing cache in TYPO3 Backend might not be enough, try clearing cache in Install Tool. You also might have to clear your opcode cache, if any.

Actions #25

Updated by Riccardo De Contardi about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF