вот процессор для выборки ВСЕХ дочерних категорий.
<?php
/*
Получаем все дочерние категории.
По умолчанию поиск выполняется во всем каталоге
*/
require_once dirname(dirname(dirname(__FILE__))).'/resources/getdata.class.php';
class modWebCatalogCategoryGetdataProcessor extends modWebResourcesGetdataProcessor{
public function initialize(){
$this->setDefaultProperties(array(
'category_id' => 85,
'image_url_schema' => 'base',
));
if(!(int)$this->getProperty('category_id')){
return "Не была указана категория";
}
return parent::initialize();
}
public function prepareQueryBeforeCount(xPDOQuery $c) {
$c = parent::prepareQueryBeforeCount($c);
$categories = array();
$where = array(
'id:in' => $this->getCategories((int)$this->getProperty('category_id'), $categories),
);
$c->where($where);
return $c;
}
protected function getCategories($parent, array & $categories){
$q = $this->modx->newQuery('modResource', array(
'deleted' => 0,
'published' => 1,
'hidemenu' => 0,
'isfolder' => 1,
'parent' => $parent,
));
$q->select(array(
'id',
));
if($s = $q->prepare() AND $s->execute()){
while($row = $s->fetch(PDO::FETCH_ASSOC)){
$categories[] = $row['id'];
$this->getCategories($row['id'], $categories);
}
}
return $categories;
}
//
public function afterIteration(array $list){
$list = parent::afterIteration($list);
switch($this->getProperty('image_url_schema')){
case 'base':
$images_base_url = $this->modx->runSnippet('getSourcePath');
break;
case 'full':
$images_base_url = $this->modx->getOption('site_url');
$images_base_url .= preg_replace("/^\//", "", $this->modx->runSnippet('getSourcePath'));
break;
default: $images_base_url = '';
}
foreach($list as & $l){
$l['image'] = '';
if(!empty($l['tvs']['image']['value'])){
$l['image'] = $images_base_url . $l['tvs']['image']['value'];
}
else{
$l['imageDefault'] = $images_base_url . 'products/No-Photo.jpg';
}
}
return $list;
}
}
return 'modWebCatalogCategoryGetdataProcessor';
где что подкрутить чтобы выводился только один уровень категорий.