Extbase Pager
Paging mit Extension
Diese Extension funktioniert super! Installieren der Extension und dann einbinden wie folgt:
/**
* action list
*
* @param int $page page number
* @return void
*/
public function listAction($page = 1) {
$pageCount = 0;
$itemsPerPage = 3;
$query = $this->productRepository->createQuery();
// pager
$pageCount = Tx_ExtbasePager_Utility_Pager::prepareQuery($query, $page, $itemsPerPage);
// get data
$products = $query->execute();
// views
$this->view->assign('products', $products);
$this->view->assign('page', $page);
$this->view->assign('pageCount', $pageCount);
}
Im Template
<f:if condition="{pageCount} > 1">
<!-- pager -->
{namespace pager=Tx_ExtbasePager_ViewHelpers}
<pager:pager typoscript="plugin.tx_rsysproductbase.settings.pager" page="{page}" lastPage="{pageCount}" localLang="EXT:rsysproductbase/Resources/Private/Language/locallang_extbasepager.xml" />
</f:if>
Die Sprachdatei locallang_extbasepager.xml habe ich in /Resources/Private/Language kopiert und angepasst. Anders ist es mir nicht gelungen die Labels zu überschreiben (mit TS).
Und die Konfiguration steht in TS:
plugin.tx_rsysproductbase.settings.pager {
// basic configuration
// can be static -> same amount (max) on each side of the current page (default), auto -> tries to always show the same amount of pager links (ignores maxBefore/maxAfter if only one is set), growing -> tries to give as many links to previous pages as possible
style = auto
// if set with maxAfter it will override style and max, overrides growing style
maxBefore = 3
// if set with maxBefore it will override style and max
maxAfter = 5
// total maximum of pages shown, default is 5. If it is an even number, pages towards the end are favoured. 5 is default.
max = 5
// if the max is even the pages towards the start are favoured
favourStart = 1
// does not wrap the pager in ul tags
noUlWrap = 0
// the class to add to the ul, "pager" by default
class = pager_box
// stdwrap around the pager, simple wrap if only a string, full stdwrap if its an array
stdWrap = <div id="someId">|</div>
stdWrap {
wrap3 = <div id="someId">|</div>
}
// namespace for the page/lastPage arguments default is the namespace of the extension running the pager
GPnamespace = tx_rsysproductbase_productlist
// order of display, omitted keywords are appended. This is the default order.
order = first,previous,items, next,last,jumpto,current
// reverse the order, say for float: right (also reverses the items etc)
reverse = 0
// alternate page key for the GPvars, 'page' by default
pageKey = page
// alternate lastPage key for the GPvars, 'lastPage' by default
lastPageKey = lastPage
// include the lastPage parameter to the links, not included by default
includeLastPage = 1
active {
// the current page item
// hide the current page
doNotDisplay = 0
// do not link the current page
doNotLinkIt = 1
// default is 'pager_active'
class = pager_active pager
// this is the default if value is not set
value.current = 1
// active page is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
}
item {
// the items shown before/after the current
// hide the current item
doNotDisplay = 0
// no class as default
class = pager
// this is the default if value is not set
value.current = 1
// pages are not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
// added between the items (including active item)
separator = <li class="pager_separator pager">|</li>
}
more {
// ... before and after the page items
// hide the ...
doNotDisplay = 0
// 'more' as default
class = pager_more pager
// this is the default if value is not set (stdwrap as the other values)
value = ...
// ... are not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the ...
}
}
first {
// the link pointing to the first page (1)
// hide the 'first page' link
doNotDisplay = 0
// default is 'first'
class = pager_first pager
// this is the default if value is not set
value.field = title
// hidden by default if only one page exists
showIfOnePage = 1
// hidden by default if the current page is the first
showIfFirstPage = 1
// first page link is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
}
last {
// the link pointing to the last page that can be shown
// hide the 'last page' link
doNotDisplay = 0
// default is 'last'
class = pager_last pager
// this is the default if value is not set
value.field = title
// hidden by default if only one page exists
showIfOnePage = 1
// hidden by default if the current page is the last
showIfLastPage = 1
// last page link is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
}
previous {
// the link pointing to the previous page
// not shown when there is no page before!
// hide the 'previous page' link
doNotDisplay = 0
// default is 'previous'
class = pager_previous pager
// this is the default if value is not set
value.field = title
// previous page link is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
}
next {
// the link pointing to the next page
// not shown when there is no page after!
// hide the 'next page' link
doNotDisplay = 0
// default is 'next'
class = pager_next pager
// this is the default if value is not set
value.field = title
// next page link is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
value = >
}
jumpto {
// the form field to jump to a page directly
// hide the jumpto field
doNotDisplay = 1
// default is 'jumpto'
class = pager_jumpto pager
// this is the default if value is not set
value.current = 1
// jumpto field is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the link
}
}
current {
// the item displaying what page is currently displayed
// hide the current info
doNotDisplay = 0
// default is 'current'
class = pager_current pager
// this is the default if value is not set
value = (Seite <span class="actPage">{field:activePage}</span> | {field:lastPage})
value.insertData = 1
// current page info is not wrapped in li tags
noLiWrap = 0
outerWrap {
// stdWrap around the info
}
}
}
Bug "loadTypoScriptSetup"
Und doch klappt nicht mehr alles: seit TYPO3 4.6.1 mit extbase 1.4.0 kommt ein Fehler eines ungültigen Methodenaufrufs: Call to undefined method loadTypoScriptSetup(). Es hat sich da wohl was geändert an Extbase. Ich habe die Klasse extbase_pager/Classes/ViewHelpers/PagerViewHelper.php geändert in Zeile 69:
//$this->typoScriptSetup = &$configurationManager->loadTypoScriptSetup();
$this->typoScriptSetup = &$configurationManager->getConfiguration('FullTypoScript'); // rsys bugfix
Und nun klappt's wieder.