for($i = 1;$i < 5; $i++){
$images = $modx->resource->get('Images'.$i);
$decoded = json_decode($images[1]);
$imageLength = count($decoded);
if($imageLength > 0){
$properties = array('imageKey' => 'Images'.$i, 'contentKey' => 'Content'.$i);
switch($imageLength){
case ($imageLength < 2):
$output = $modx->getChunk('SingleSection',$properties);
return $output;
break;
case ($imageLength <= 6):
$output = $modx->getChunk('SliderSection',$properties);
return $output;
break;
default:
$output = $modx->getChunk('GallerySection',$properties);
return $output;
break;
}
}
}
<div class="imageSlider">
<div class="imageStore store">
[[!getImageList?
&tvname=`[[+imageKey]]`
&tpl=`@CODE:<div class="cell" style="background:url([[+image]]) no-repeat center center"></div>
`]]
</div>
</div>
<?php
for ($i = 1; $i < 5; $i++) {
$images = $modx->resource->getTVValue('Images' . $i);
$decoded = json_decode($images[1]);
$imageLength = count($decoded);
if ($imageLength > 0) {
$gil_properties = array();
$gil_properties['tvname'] = 'Images' . $i;
switch ($imageLength) {
case ($imageLength < 2):
$gil_properties['tpl'] = '@CODE:<div class="cell" style="background:url([[+image]]) no-repeat center center"></div>';
$gil_output = $modx->runSnippet('getImageList', $gil_properties);
$properties = array('gil_output' => $gil_output, 'content' => $modx->resource->getTVValue('Content' . $i));
$output = $modx->getChunk('SingleSection', $properties);
return $output;
break;
case ($imageLength <= 6):
//different tpl goes here:
$gil_properties['tpl'] = '@CODE:<div class="cell" style="background:url([[+image]]) no-repeat center center"></div>';
$gil_output = $modx->runSnippet('getImageList', $gil_properties);
$properties = array('gil_output' => $gil_output, 'content' => $modx->resource->getTVValue('Content' . $i));
$output = $modx->getChunk('SliderSection', $properties);
return $output;
break;
default:
//different tpl goes here:
$gil_properties['tpl'] = '@CODE:<div class="cell" style="background:url([[+image]]) no-repeat center center"></div>';
$gil_output = $modx->runSnippet('getImageList', $gil_properties);
$properties = array('gil_output' => $gil_output, 'content' => $modx->resource->getTVValue('Content' . $i));
$output = $modx->getChunk('GallerySection', $properties);
return $output;
break;
}
}
}
<div class="imageSlider">
<div class="imageStore store">
[[+gil_output]]
</div>
[[+content]]
</div>
for ($i = 1; $i < 5; $i++) {
$images = $modx->resource->getTVValue('Images' . $i);
$decoded = json_decode($images[1]);
$imageLength = count($decoded);
$type = '';
if ($imageLength > 0) {
switch ($imageLength) {
case ($imageLength < 2):
$type = 'SingleSection';
break;
case ($imageLength <= 6):
$type = 'SliderSection';
break;
default:
$type = 'GallerySection';
break;
}
$gil_properties = array();
$gil_properties['tvname'] = 'Images' . $i;
$gil_properties['tpl'] = $type . 'Tpl';
$gil_output = $modx->runSnippet('getImageList', $gil_properties);
$properties = array('gil_output' => $gil_output, 'content' => $modx->resource->getTVValue('Content' . $i));
$output = $modx->getChunk($type, $properties);
return $output;
}
}
I thought of the sub resources but i thought the client would be more confused that way as they are basically adding psuedo pages.