Skip to content
Snippets Groups Projects
Commit 0807bb3a authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] More fixes to the pagination

parent 844375b9
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,6 @@ use SGalinski\SgNews\Domain\Repository\TagRepository;
use SGalinski\SgNews\Service\ConfigurationService;
use SGalinski\SgNews\Service\HeaderMetaDataService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/**
* Controller that handles the list rendering of a single category
......@@ -54,18 +53,6 @@ class ListByCategoryController extends AbstractController {
*/
protected $newsRepository;
/**
* Initialize the indexAction to set the currentPageBrowserPage parameter
*
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
public function initializeIndexAction() {
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'];
if ($currentPageBrowserPage > 0) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
}
}
/**
* @param CategoryRepository $categoryRepository
*/
......@@ -88,6 +75,18 @@ class ListByCategoryController extends AbstractController {
$this->tagRepository = $tagRepository;
}
/**
* Initialize the indexAction to set the currentPageBrowserPage parameter
*
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
public function initializeIndexAction() {
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'];
if ($currentPageBrowserPage > 0) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
}
}
/**
* Renders the news list of a category
*
......
......@@ -74,11 +74,11 @@ class PageBrowserViewHelper extends AbstractViewHelper {
$view->setPartialRootPaths($configuration['view']['partialRootPaths']);
$view->setLayoutRootPaths($configuration['view']['layoutRootPaths']);
$view->setTemplate('PageBrowser/Index');
$currentPage = 0;
$pageBrowserVars = GeneralUtility::_GP('tx_sgnews_pagebrowser');
if (isset($pageBrowserVars['currentPage']) && (int) $pageBrowserVars['currentPage'] > 0) {
$currentPage = (int) $pageBrowserVars['currentPage'];
} else {
$currentPage = 0;
}
$pageLinks = [];
......@@ -98,7 +98,7 @@ class PageBrowserViewHelper extends AbstractViewHelper {
'enableMorePages' => 1,
'pageLinks' => $pageLinks,
'currentPage' => $currentPage,
'prevPageExist' => $currentPage > 1,
'prevPageExist' => $currentPage >= 1,
'showLessPages' => ($currentPage - 1) > 1,
'showNextPages' => ($currentPage + 2) < $this->arguments['numberOfPages'],
'nextPageExist' => $currentPage < $this->arguments['numberOfPages'] - 1,
......
{namespace sg=SGalinski\SgNews\ViewHelpers}
<f:layout name="PageBrowser" />
<f:layout name="PageBrowser"/>
<f:section name="main">
<nav>
......@@ -8,8 +8,8 @@
<f:if condition="{prevPageExist}">
<f:then>
<li class="tx-pagebrowse-prev">
<f:variable name="prevPage" value="{currentPage - 1}" />
<f:link.action additionalParams="{tx_sgnews_pagebrowser: {currentPage: prevPage}}"
<f:variable name="prevPage" value="{currentPage - 1}"/>
<f:link.action addQueryString="1" additionalParams="{tx_sgnews_pagebrowser: {currentPage: prevPage}}"
additionalAttributes="{aria-label: 'Previous'}">
&laquo;
</f:link.action>
......@@ -28,8 +28,8 @@
<f:if condition="{enableLessPages} && {showLessPages}">
<li>
<f:variable name="lessPage" value="{currentPage - 2}" />
<f:link.action additionalParams="{tx_sgnews_pagebrowser: {currentPage: lessPage}}">
<f:variable name="lessPage" value="{currentPage - 2}"/>
<f:link.action addQueryString="1" additionalParams="{tx_sgnews_pagebrowser: {currentPage: lessPage}}">
...
</f:link.action>
</li>
......@@ -49,7 +49,7 @@
</f:then>
<f:else>
<li class="tx-pagebrowse-page">
<f:link.action additionalParams="{tx_sgnews_pagebrowser: {currentPage: pageLink.page}}">
<f:link.action addQueryString="1" additionalParams="{tx_sgnews_pagebrowser: {currentPage: pageLink.page}}">
{pageLink.number}
</f:link.action>
</li>
......@@ -59,8 +59,8 @@
<f:if condition="{enableMorePages} && {showNextPages}">
<li>
<f:variable name="morePage" value="{currentPage + 2}" />
<f:link.action additionalParams="{tx_sgnews_pagebrowser: {currentPage: morePage}}">
<f:variable name="morePage" value="{currentPage + 2}"/>
<f:link.action addQueryString="1" additionalParams="{tx_sgnews_pagebrowser: {currentPage: morePage}}">
...
</f:link.action>
</li>
......@@ -69,8 +69,8 @@
<f:if condition="{nextPageExist}">
<f:then>
<li class="tx-pagebrowse-next">
<f:variable name="nextPage" value="{currentPage + 1}" />
<f:link.action additionalParams="{tx_sgnews_pagebrowser: {currentPage: nextPage}}"
<f:variable name="nextPage" value="{currentPage + 1}"/>
<f:link.action addQueryString="1" additionalParams="{tx_sgnews_pagebrowser: {currentPage: nextPage}}"
additionalAttributes="{aria-label: 'Next'}">
&raquo;
</f:link.action>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment