Summary
I’m getting a snippet and a chunk, the chunk contains a getResources in which the &parents parameter (pops) should be set when calling the chunk.
Step to reproduce
Getting the snippet and the chunk:
[[!webinarIndexModule? &tpl=`upcomingWebinars` &pops=`77583`]]
Note: webinarIndexModule is a small snippet that simply sets the number of columns based on a TV. It has nothing to do with the getResources code.
This is the getResources in the (upcomingWebinars) chunk:
[[!getResources?
&parents= `[[+pops]]`
&limit= `[[+limit]]`
&tpl= `webinarFlexCard`
&includeTVs= `1`
&processTVs= `1`
&tvPrefix=``
&sortbyTV= `eventStart`
&sortdirTV= `ASC`
&includeContent= `0`
&tvFilters= `eventStart>>[[!getDate]],eventStart!==`]]
Observed behavior
The &pops value (77583) is not being passed.
Everything works fine if I hardcode the &parents ID number in the getResources but it should be automated to pull content from multiple places.
Expected behavior
The &parents in getResources should be set to 77583
Environment
MODX Revolution 2.8.1
bruno17
January 19, 2022, 11:02am
2
whats the code of that webinarIndexModule snippet?
Bruno, the webinarIndexModule is a small snippet that simply sets the number of columns based on a TV. It has nothing to do with the getResources code. By the way, everything works fine if I hardcode the &parents ID number in the getResources but it should be automated to pull content from multiple places.
bruno17
January 19, 2022, 11:33am
4
you need to pass the pops scriptProperty to the getChunk method within the webinarIndexModule snippet.
If I would see the snippet code, I could say, how exactly in that case.
I see, thank you Bruno. Here’s the webinarIndexModule snippet code:
<?php
// error_reporting(E_ALL);
$output = '';
$tvname = $modx->getOption('tvname', $scriptProperties, '');
$tpl = $modx->getOption('tpl', $scriptProperties, '');
$sectionOptions = $modx->fromJSON($modx->resource->getTVValue($tvname));
// Build flexcard
if (isset($sectionOptions[0])) {
for ($i = 0; $i <= ($sectionOptions[0]['sectionColumns'] - 1); $i++) {
$flexGrids[] = $modx->getChunk('htmlElement', [
'output' => "",
'element' => 'div',
'attr' => 'class="new-flexcard"'
]);
}
$output .= $modx->getChunk($tpl, [
'index-title' => $sectionOptions[0]['sectionTitle'],
'flexgrid-cols' => $sectionOptions[0]['sectionColumns'],
'limit' => $sectionOptions[0]['sectionLimit'],
'flexGrids' => implode("", $flexGrids),
]);
}
return $output;
bruno17
January 19, 2022, 12:01pm
6
You can try:
$output .= $modx->getChunk($tpl, array_merge($scriptProperties,[
'index-title' => $sectionOptions[0]['sectionTitle'],
'flexgrid-cols' => $sectionOptions[0]['sectionColumns'],
'limit' => $sectionOptions[0]['sectionLimit'],
'flexGrids' => implode("", $flexGrids),
]));
This should pass all scriptProperties
Thank you very much Bruno! Your solution works perfectly fine.
system
Closed
January 21, 2022, 12:53pm
8
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.