[[+createdby:userinfo=`state`]]
<?php /* first, build the query */ $criteria = $modx->newQuery('modUserProfile'); /* &state= provided in the snippet call */ $criteria->where(array( 'state' => $state, )); /* get the users as xPDOObjects */ $users = $modx->getCollection('modUserProfile',$criteria); /* next query */ $c = $modx->newQuery('modResource'); /* only published resources add more params later */ $c->where(array( 'published' => true, )); $c->sortby('createdon','DESC'); /* get the resources as xPDOObjects */ $resources = $modx->getCollection('modResource',$c); $output = ' '; foreach ($users as $user) { $id = $user->get('id'); foreach ($resources as $resource) { $creator = $resource->get('createdby'); if ($creator == $id) { $output .= $modx->getChunk('testTPL',array( 'pagetitle' => $resource->get('pagetitle'), 'id' => $resource->get('id'), )); } } } return $output;
$c = $modx->newQuery('modResource'); $c->innerJoin('modUser', 'CreatedBy'); $c->innerJoin('modUserProfile', 'Profile', 'CreatedBy.id=Profile.internalKey'); $c->where(array( 'published' => TRUE, 'Profile.state' => 'Croatia', )); $resources = $modx->getCollection('modResource',$c); foreach($resources as $resource){ echo $resource->id; //do what ever you want }
<?php /* first, build the query */ $criteria = $modx->newQuery('modUserProfile'); /* &state= provided in the snippet call */ $criteria->where(array('state' => $state, )); /* get the users as xPDOObjects */ $users = $modx->getCollection('modUserProfile', $criteria); foreach ($users as $user) { $ids[] = $user->get('internalKey'); } $where['createdby:IN']=$ids; return $modx->toJson($where);
[[!getResources? ... ... &where=`[[!yoursnippet? &state=`devon`]]` ]]
[[!getResources:ifempty=`No Results`? ... ... [[!mysnippet? &state=`[[+fi.state]]`]] ]]
<?php /* first, build the query */ $criteria = $modx->newQuery('modUserProfile'); /* &state= provided in the snippet call */ $criteria->where(array('state' => $state, )); /* get the users as xPDOObjects */ $users = $modx->getCollection('modUserProfile', $criteria); foreach ($users as $user) { $ids[] = $user->get('internalKey'); } $where['createdby:IN']=$ids; $output = ''; if (!empty($state)) { $output .= '&where=`'; $output .= $modx->toJson($where); $output .= '`'; } return $output;