[[pdoResources? &parents=`537` &limit=`0` &showHidden=`0` &sortby=`publishedon` &sortdir=`DESC` &includeTVs=`proAwards` &processTVs=`proAwards` &tpl=`overviewAwardTpl` &tvFilters=`proAwards.year==2015` ]]
[
{"MIGX_id":"3","status":"Winner","name":"Award Name 1","body":"Award Cermony 1","year":"2015"},
{"MIGX_id":"4","status":"Winner","name":"Award Name 2","body":"Award Cermony 2","year":"2015"},
{"MIGX_id":"2","status":"Winner","name":"Award Name 3","body":"Award Cermony 3","year":"2013"},
{"MIGX_id":"5","status":"Roll of Honour","name":"Award Name 4","body":"Award Cermony 4","year":"2012"}
]
But it would be possible to import all MIGX-items into a custom-table and use a MIGXdb-TV instead of the MIGX-TV to manage them.
<?xml version="1.0" encoding="UTF-8"?>
<model package="awards" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="awAward" table="aw_awards" extends="xPDOSimpleObject" >
<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
<field key="status" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
<field key="body" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="resource_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" index="index"/>
<field key="year" dbtype="int" precision="4" phptype="integer" null="false" default="0" index="index"/>
<aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" />
</object>
</model>
<?php
$parent = $modx->getOption('parent', $scriptProperties, '');
$packageName = 'awards';
$packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
if (is_dir($modelpath)) {
$modx->addPackage($packageName, $modelpath);
$classname = 'awAward';
if ($resources = $modx->getCollection('modResource', array('parent' => $parent))) {
foreach ($resources as $resource) {
$items = $modx->fromJson($resource->getTVValue('proAwards'));
if (is_array($items)) {
foreach ($items as $item) {
$object = $modx->newObject($classname);
$object->fromArray($item);
$object->set('resource_id', $resource->get('id'));
$object->save();
}
}
}
}
}
[[migxLoopCollection?
&packageName=`awards`
&classname=`awAward`
&where=`{"year":"2015"}`
&groupby=`resource_id`
&tpl=`@CODE:[[+resource_id]]`
&outputSeparator=`,`
&toPlaceholder=`resource_ids`
]]
[[pdoResources?
&parents=`537`
&limit=`0`
&showHidden=`0`
&sortby=`publishedon`
&sortdir=`DESC`
&tpl=`overviewAwardTpl`
&where=`{"id:IN":[ [[+resource_ids]] ]}`
]]
&sortConfig=`[{"sortby":"name","ASC"},{"sortby":"status","sortdir":"DESC"}]`