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

[BUGFIX] Fix pagebrowser on the overview page

parent d08d013f
No related branches found
Tags 3.2.4
No related merge requests found
......@@ -77,7 +77,7 @@ class ListByCategoryController extends AbstractController {
$offset = $currentPageBrowserPage * $newsPerPage;
}
$newsCount = $this->newsRepository->newsCountByCategories($categoryUids);
$numberOfPages = ceil($newsCount / $newsPerPage);
$numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage));
$newsMetaData = [];
$headerSet = FALSE;
......
......@@ -124,40 +124,38 @@ class OverviewController extends AbstractController {
protected function overviewWithoutCategoriesAction() {
$offset = 0;
$newsPerPage = (int) $this->settings['newsLimit'];
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['page'];
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'];
if ($currentPageBrowserPage && $newsPerPage) {
$offset = $currentPageBrowserPage * $newsPerPage;
$offset = ($currentPageBrowserPage * $newsPerPage) - 1;
}
/** @noinspection PhpUndefinedMethodInspection */
$newsCount = $this->newsRepository->countAll();
$numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage));
if ($this->settings['onlyNewsWithinThisPageSection']) {
/** @noinspection PhpUndefinedMethodInspection */
$categories = $this->categoryRepository->findByPid($GLOBALS['TSFE']->id);
$categoryIds = [];
$categoriesById = [];
foreach ($categories as $category) {
/** @var $category Category */
$categoryIds[] = $category->getUid();
$categoriesById[$category->getUid()] = $category;
}
$news = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$newsPerPage, FALSE, $categoryIds, $offset
);
$newsCount = $this->newsRepository->newsCountByCategories($categoryIds);
} else {
$categories = $this->categoryRepository->findAll();
$news = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$newsPerPage, FALSE, NULL, $offset
);
}
$newsCount = $this->newsRepository->countAll();
$categoryIds = NULL;
$categoriesById = [];
foreach ($categories as $category) {
/** @var $category Category */
$categoriesById[$category->getUid()] = $category;
$categoriesById = [];
$categories = $this->categoryRepository->findAll();
foreach ($categories as $category) {
/** @var $category Category */
$categoriesById[$category->getUid()] = $category;
}
}
$newsMetaData = [];
$news = $this->newsRepository->findAllSortedNewsByCategories($categoryIds, $newsPerPage, $offset);
foreach ($news as $newsEntry) {
/** @var News $newsEntry */
$data = $this->getMetaDataForNews($newsEntry, $categoriesById[$newsEntry->getPid()]);
......@@ -171,6 +169,7 @@ class OverviewController extends AbstractController {
HeaderMetaDataService::addOgImageToHeader($firstNews['teaserImage']);
}
$numberOfPages = ($newsPerPage <= 0 ? 0 : ceil($newsCount / $newsPerPage));
$this->view->assign('numberOfPages', $numberOfPages);
$this->view->assign('newsMetaData', $newsMetaData);
}
......
......@@ -29,6 +29,7 @@ namespace SGalinski\SgNews\Domain\Repository;
use SGalinski\SgNews\Domain\Model\News;
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* News Repository
......@@ -40,7 +41,7 @@ class NewsRepository extends AbstractRepository {
* @param array $categoryIds NULL, if the category filter isn't applied, otherwise an array with the categories uid.
* @param int $limit
* @param int $offset
* @return QueryResult
* @return QueryResultInterface
*/
public function findAllSortedNewsByCategories($categoryIds = NULL, $limit = 0, $offset = 0) {
$query = $this->createQuery();
......
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