Skip to content

Commit

Permalink
[BUGFIX] Ignore pageUid when selecting content by specific UIDs
Browse files Browse the repository at this point in the history
Close: #1868
  • Loading branch information
NamelessCoder committed Jul 27, 2023
1 parent 9876036 commit e58bf77
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Classes/ViewHelpers/Content/AbstractContentViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public function initializeArguments(): void
'sorting'
);
$this->registerArgument('sortDirection', 'string', 'Optional sort direction of content elements', false, 'ASC');
$this->registerArgument('pageUid', 'integer', 'If set, selects only content from this page UID', false, 0);
$this->registerArgument(
'pageUid',
'integer',
'If set, selects only content from this page UID. Ignored when "contentUids" is specified.',
false,
0
);
$this->registerArgument(
'contentUids',
'array',
Expand Down Expand Up @@ -90,11 +96,11 @@ protected function getContentRecords(): array
{
/** @var int $limit */
$limit = $this->arguments['limit'];

$pageUid = $this->getPageUid();
/** @var int $slide */
$slide = $this->arguments['slide'];

$pageUid = $this->getPageUid();

if ((integer) $slide === 0) {
$contentRecords = $this->getSlideRecordsFromPage($pageUid, $limit);
} else {
Expand Down Expand Up @@ -167,8 +173,16 @@ protected function getSlideRecordsFromPage(int $pageUid, ?int $limit): array
*/
protected function getPageUid(): int
{
/** @var array|null $contentUids */
$contentUids = $this->arguments['contentUids'] ?? null;

if (!empty($contentUids)) {
return 0;
}

/** @var int $pageUid */
$pageUid = $this->arguments['pageUid'];

$pageUid = (integer) $pageUid;
if (1 > $pageUid) {
$pageUid = (integer) ($GLOBALS['TSFE']->page['content_from_pid'] ?? 0);
Expand Down

0 comments on commit e58bf77

Please sign in to comment.