<?xml version="1.0" encoding="UTF-8"?>
<model package="migxresourcerelations" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="rrResourceRelation" table="rr_resource_relations" extends="xPDOSimpleObject">
<field key="source_id" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />
<field key="target_id" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />
<field key="active" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />
<field key="extended" dbtype="text" phptype="json" null="false" default="" />
<field key="rel_type" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />
<index alias="source_id" name="source_id" primary="false" unique="false" type="BTREE">
<column key="source_id" length="" collation="A" null="false" />
</index>
<index alias="target_id" name="target_id" primary="false" unique="false" type="BTREE">
<column key="target_id" length="" collation="A" null="false" />
</index>
<index alias="rel_type" name="rel_type" primary="false" unique="false" type="BTREE">
<column key="rel_type" length="" collation="A" null="false" />
</index>
<aggregate alias="Source" class="modResource" local="source_id" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Target" class="modResourse" local="target_id" foreign="id" cardinality="one" owner="foreign" />
</object>
</model> "MIGX_id":5,
"name":"source_parent",
"label":"parent",
"emptytext":"filter Parent",
"type":"treecombo",
"getlistwhere":{
"parent":"[[+source_parent]]"
},
"getcomboprocessor":"gettreenode",
"combotextfield":"pagetitle",
"comboidfield":"id",
"comboparent":"",
"default":18
},3. In the main grid i need to include not only the children of the filter parent but their childrens's children and so on all the way to the bottom of the sub-branch. How would i do that?
{"id:IN":[ [[getChildIds? &parent=`[[+source_parent]]` &context=`web`]] ]}
$parent = $modx->getOption('parent', $scriptProperties, 0);
$depth = $modx->getOption('depth',$scriptProperties,10);
$context = $modx->getOption('context',$scriptProperties,$modx->context->get('key'));
$c = $modx->newQuery('modResource');
$c->select('id');
$c->where(array('id:IN' => $modx->getChildIds($parent,$depth,array('context'=>$context))));
$ids = array();
if ($resources = $modx->getCollection('modResource', $c)) {
foreach ($resources as $resource) {
if ($resource->checkPolicy('list')) {
$ids[] = $resource->get('id');
}
}
}
return implode(',', $ids);
<?php
$this->customconfigs['sortConfig'] = '
[{"sortby":"Parent.pagetitle","sortdir":"ASC"},{"sortby":"modResource.pagetitle","sortdir":"ASC"}]
';
$this->customconfigs['sourceortarget'] = 'source';
$this->customconfigs['selectfields'] = 'id,pagetitle';
//$configs = explode(',', $this->modx->getOption('configs', $_REQUEST, ''));
if (count($configs) > 1) {
$type_root_id = $configs[1];
$this->customconfigs['win_id'] = $this->customconfigs['win_id'] . $type_root_id;
$filters = '[
{
"MIGX_id":1,
"name":"source_parent'.$type_root_id.'",
"label":"parent",
"emptytext":"filter Parent",
"type":"treecombo",
"getlistwhere":"{\"id:IN\":[ [[getChildIds? &parent=`[[+source_parent'.$type_root_id.']]` &context=`web`]] ]}",
"getcomboprocessor":"gettreenode",
"combotextfield":"pagetitle",
"comboidfield":"id",
"comboparent":"",
"default":'.$type_root_id.'
},
{
"MIGX_id":2,
"name":"source_published'.$type_root_id.'",
"label":"published",
"emptytext":"filter published",
"type":"combobox",
"getlistwhere":{
"ResourceRelation.published":"[[+source_published'.$type_root_id.']]"
},
"getcomboprocessor":"getyesnocombo",
"combotextfield":"",
"comboidfield":"",
"comboparent":""
},
{
"MIGX_id":3,
"name":"source_active'.$type_root_id.'",
"label":"active",
"emptytext":"filter active",
"type":"combobox",
"getlistwhere":{
"ResourceRelation.active":"[[+source_active'.$type_root_id.']]"
},
"getcomboprocessor":"getyesnocombo",
"combotextfield":"",
"comboidfield":"",
"comboparent":""
},
{
"MIGX_id":4,
"name":"source_search'.$type_root_id.'",
"label":"search",
"emptytext":"Search...",
"type":"textbox",
"getlistwhere":{
"pagetitle:LIKE":"%[[+source_search'.$type_root_id.']]%",
"OR:id:=":"[[+source_search]]"
},
"getcomboprocessor":"",
"combotextfield":"",
"comboidfield":"",
"comboparent":""
}
]';
$this->customconfigs['filters'] = $this->modx->fromJson($filters);
}
Code: 401 Unauthorized
{"success":false,"message":"Access denied.","total":0,"data":[],"object":{"code":401}}
{
"formtabs":"",
"contextmenus":"",
"actionbuttons":"",
"columnbuttons":"activate||deactivate||publishtarget||unpublishtarget",
"filters":"",
"extended":{
"migx_add":"",
"formcaption":"",
"update_win_title":"",
"win_id":"relations_source",
"maxRecords":"",
"addNewItemAt":"bottom",
"multiple_formtabs":"",
"actionbuttonsperrow":4,
"winbuttonslist":"",
"extrahandlers":"",
"filtersperrow":4,
"packageName":"migxresourcerelations",
"classname":"modResource",
"task":"",
"getlistsort":"",
"getlistsortdir":"",
"use_custom_prefix":"0",
"prefix":"",
"grid":"",
"gridload_mode":1,
"check_resid":"0",
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":[
{
"alias":"Parent",
"selectfields":"id,pagetitle"
},
{
"alias":"ResourceRelation",
"classname":"rrResourceRelation",
"on":"ResourceRelation.target_id = modResource.id AND ResourceRelation.source_id =[[+resource_id]]"
}
],
"cmpmaincaption":"",
"cmptabcaption":"",
"cmptabdescription":"",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":4,
"header":"ID",
"dataIndex":"id",
"renderer":"",
"sortable":"false",
"show_in_grid":1
},
{
"MIGX_id":3,
"header":"Parent",
"dataIndex":"Parent_pagetitle",
"width":"",
"sortable":"false",
"show_in_grid":1,
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderoptions":""
},
{
"MIGX_id":1,
"header":"Pagetitle",
"dataIndex":"pagetitle",
"width":200,
"sortable":"false",
"show_in_grid":1,
"renderer":"this.renderRowActions",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":""
},
{
"MIGX_id":2,
"header":"Active",
"dataIndex":"ResourceRelation_active",
"width":"",
"sortable":"false",
"show_in_grid":1,
"renderer":"this.renderCrossTick",
"clickaction":"",
"selectorconfig":"",
"renderoptions":""
},
{
"MIGX_id":5,
"header":"Published",
"dataIndex":"ResourceRelation_published",
"width":"",
"sortable":"false",
"show_in_grid":1,
"renderer":"this.renderCrossTick",
"clickaction":"",
"selectorconfig":"",
"renderoptions":""
},
{
"MIGX_id":6,
"header":"Active",
"dataIndex":"Joined_active",
"width":"",
"sortable":"false",
"show_in_grid":"0",
"renderer":"this.renderCrossTick",
"clickaction":"",
"selectorconfig":"",
"renderoptions":""
},
{
"MIGX_id":7,
"header":"Published",
"dataIndex":"published",
"width":"",
"sortable":"false",
"show_in_grid":"0",
"renderer":"this.renderCrossTick",
"clickaction":"",
"selectorconfig":"",
"renderoptions":""
},
{
"MIGX_id":8,
"header":"Type",
"dataIndex":"ResourceRelation_rel_type",
"width":"",
"sortable":true,
"show_in_grid":1,
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":""
}
]
}
[{"alias":"Parent","selectfields":"id,pagetitle"},{"alias":"ResourceRelation","classname":"rrResourceRelation","on":"ResourceRelation.target_id = modResource.id AND ResourceRelation.source_id =[[+resource_id]]"}]