$childs = $modx->getChildIds($_GET['p'], '1');
$c = $modx->newQuery('modResource');
$c->select('id, pagetitle, createdby, parent, publishedon, editedon, alias');
$c->andCondition(array(
'template' => $_GET['t'],
'deleted' => 0,
'published' => 1
$c->sortby('template','ASC');
$c->limit(15);
$elements = $modx->getCollection('modResource',$c);
));
Hy, i tried to make a condition where i call this code, in the first line i get all child id in depth 1 where parent = x.
After that i want to make a query where first check if template = x AND deleted = 0 and published = 1 and parent in ($childs). But how can i check first that i get all these params and than filter it by the child ids?
<?php
$c = $modx->newQuery('modResource', array('template'=>$_GET['t'], 'parent'=>$_GET['p'], 'published'=>'1', 'deleted'=>'0'));
$c->select('id, pagetitle, createdby, parent, publishedon, editedon, alias, template');
$c->sortby('template','ASC');
$c->limit(15);
$elements = $modx->getCollection('modResource',$c);
'parent:IN' => $childs
You also need to select the class_key column; without this, the objects returned in the collection will not be of the proper derivative class, e.g. modDocument, modWebLink, modStaticResource, etc. You may want the context_key as well.
Quote from: OpenGeek at Mar 06, 2011, 02:28 PM
You also need to select the class_key column; without this, the objects returned in the collection will not be of the proper derivative class, e.g. modDocument, modWebLink, modStaticResource, etc. You may want the context_key as well.
I am new to modx so can you give me a code sample what you mean please?
$c->select('id,pagetitle,createdby,parent,publishedon,editedon,alias,template,context_key,class_key');$c->where(array('parent:IN' =>array('3','4','5','6','7','8')));