[[!getPage? &elementClass=`modSnippet` &element=`getResources` &parents=`-1` &resources=`[[!GetUserProducts? &depth=`3` &count=`0` &parent=`2` &commentList=`[[!QuipCount? &type=`user` &user=`active` &listId=`1`]]`]]` &limit=`20` &pageVarKey=`page` &tpl=`kategorie-tpl` ]]
<?php /* * $parent - where to look * $depth - how deep * $commentList - list of comment by logged user */ $ids = $modx->getChildIds($parent,$depth,array('context' => 'web')); $c = $modx->newQuery('modResource'); $c->leftJoin('modUser','Author','modResource.createdby = Author.id'); $user = $modx->user->get('id'); $commentList = explode(",",$commentList); $c->where(array( 'id:IN' => $ids, 'id:NOT IN' => $commentList, 'isfolder' => '0', 'published' => 1, 'deleted' => 0, 'Author.id' => $user, )); if ($count) { return $modx->getCount('modResource',$c); //return only count } $docs = $modx->getCollection('modResource',$c); foreach ($docs as $doc) { $output .= $doc->get('id') . ','; } return substr($output, 0, -1) ; //remove last comma
This question has been answered by kudykam. See the first response.
<?php /* * $parent - where to look * $depth - how deep * $count - 1- return number, 0-return list of id */ $user = $modx->user->get('id'); if (empty($user)) return "Not logged in!"; $ids = $modx->getChildIds($parent,$depth,array('context' => 'web')); $c = $modx->newQuery('modResource'); $c->leftJoin('modUser','Author','modResource.createdby = Author.id'); $profile = $modx->user->getOne('Profile'); $fields = $profile->get('extended'); $commentList = explode(",",$fields['Quip']); // get id of all commented resources $c->where(array( 'id:IN' => $ids, 'id:NOT IN' => $commentList, 'isfolder' => '0', 'published' => 1, 'deleted' => 0, 'Author.id' => $user, )); if ($count) { return $modx->getCount('modResource',$c); } $docs = $modx->getCollection('modResource',$c); foreach ($docs as $doc) { $output .= $doc->get('id') . ','; } return substr($output, 0, -1) ;