Skip to content

Add scriptProperties values as placeholder to the pagination#392

Open
Jako wants to merge 1 commit into
modx-pro:masterfrom
Jako:patch-4
Open

Add scriptProperties values as placeholder to the pagination#392
Jako wants to merge 1 commit into
modx-pro:masterfrom
Jako:patch-4

Conversation

@Jako

@Jako Jako commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Add scriptProperties values as placeholder to the pagination. This is quite useful, if you need to fill special properties into special placeholders in the pagination links. Otherwise you have to create several pagination chunks with the special properties.

@Ibochkarev Ibochkarev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If for some reason it turns out to be null, array_merge(null, $pagination) will throw an error in PHP 8+.

Let's add some protection:

$pageNavVar => !empty($tplPageWrapper)
 ? $pdoPage->pdoTools->getChunk($tplPageWrapper, array_merge((array) ($scriptProperties ?? []), $pagination))
 : $pdoPage->pdoTools->parseChunk('', array_merge((array) ($scriptProperties ?? []), $pagination)),

or

$pagePlaceholders = array_merge((array) ($scriptProperties ?? []), $pagination);
$pageNavVar => !empty($tplPageWrapper)
 ? $pdoPage->pdoTools->getChunk($tplPageWrapper, $pagePlaceholders)
 : $pdoPage->pdoTools->parseChunk('', $pagePlaceholders),

@Jako

Jako commented Mar 8, 2026

Copy link
Copy Markdown
Contributor Author

I am quite sure that $scriptProperties is an array all the time. Otherwise the code will break before.

@Jako Jako requested a review from Ibochkarev March 20, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants