Feature #34944
closedPaginate viewhelper should be possible to handle non-query-result objects
100%
Description
this threat is associated to the ticket:
http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2012-March/011988.html
Files
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 ---
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
Updated by Ingo Pfennigstorf about 12 years ago
- Target version changed from 6.1.0 to 1910
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']); }
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)
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!
Updated by Gerrit Code Review almost 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
Updated by Gerrit Code Review almost 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
Updated by Gerrit Code Review almost 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
Updated by Alexander Opitz about 10 years ago
- Project changed from 2559 to TYPO3 Core
- Category changed from Fluid: Widgets to Fluid
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
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
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
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
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
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
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
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
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
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
Updated by Tom Ruether almost 10 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ec9899d601dd5b318c62ba9c6653bf9543525821.
Updated by Julian Stock about 9 years ago
- File Bildschirmfoto 2015-09-11 um 13.59.32.png Bildschirmfoto 2015-09-11 um 13.59.32.png added
- Target version set to 6.2.16
This problem has been solved 8 months ago and it's still not merged into the core? w00t! :D (Tried v6.2.15)
Updated by Bernhard Eckl over 8 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…
Updated by Tilo Baller over 8 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.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed