Hi,
I encountered the same problem trying to build a publishedon time based menu...
cyclissmo’s solution set me on the right track but needed some modifications to function properly, here is the final code I came up with and that works for me:
Please note that this was applied on getResources v 1.2.0-pl
1- Modify the getResources snippet code, adding the following line at line 256 (in v1.2.0-pl):
$properties['_serialized'] = '|' . base64_encode(serialize($properties)) . '|'; // pipes will help extract the data later
To locate this in the getResources code, here is the resulting chunk (lines 255 to 262)
if (empty($resourceTpl)) {
$properties['_serialized'] = '|' . base64_encode(serialize($properties)) . '|'; // pipes will help extract the data later
$chunk = $modx->newObject('modChunk');
$chunk->setCacheable(false);
$output[]= $chunk->process(array(), '<pre>' . print_r($properties, true) .'</pre>');
} else {
$output[]= $resourceTpl;
}
You probably noticed that the serialized data will only be made available when no template is specified in the getResources call parameters, which seems to be a logical behavior since recovering the raw data is opposed to templating it.
2- create your own snippet code with the following code to recover an array of the complete getResources data:
$gR_output = $modx->runSnippet( 'getResources', array(
parents => '2,3,4,5,6,7,8,9,10,11',
limit => '1000',
sortby => 'publishedon',
hideContainers => '1'
/* adapt those parameters to your need of course ;-) */
));
$gR_output = explode('|', $gR_output); // extract serialized data
foreach( $gR_output as $item ) {
$unserialized = unserialize( base64_decode( $item )); // expand data
if ( is_array( $unserialized )) {
$gR_array[] = $unserialized;
}
/* add your custom code logic here */
}
You can get an output of what is inside the $gR_array like this:
echo ( '<pre>' . print_r( $gR_array, true ) . '</pre>' );
Hope it can help someone...
Cheers.