Здравствуйте!
Подскажите как выбрать ресурсы из родительской папки по нескольким TV полям?
Никак не могу понять как адаптировать этот код, который отлично работает для выборки по одному полю:
$where = $modx->newQuery('modResource');
$where->leftJoin('modTemplateVarResource', 'TemplateVarResources');
$where->leftJoin('modTemplateVar', 'tv', "tv.id=TemplateVarResources.tmplvarid");
$where->limit(5);// Лимит
$where->where(array(
array(
'tv.name' => 'tags', // Имя TV
'TemplateVarResources.value' => 'modx',// Значение TV
'parent' => '1'// Родитель
)
));
$resources = $modx->getCollection('modResource',$where);
foreach ($resources as $id => $res) {
$output .= '<p>['.$id.'] => '.$res->get('pagetitle').'</p>';
}
return $output;
));
$resources = $modx->getCollection('modResource',$where);
if (is_array($resources)) {
$output = '';
$request_objects_array = array();
$departmentToEntries = array();
$count_request = 1;
foreach ($resources as $request_object) {
$searhed_object = $modx->getObject('modResource',$request_object->get('id'));
$department_name = $searhed_object->getTVValue('RequestDepartment');
$departmentToEntries[$department_name] = array('department_name' => $department_name, 'entries' => array());
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['position'] = $count_request;
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['id'] = $request_object->get('id');
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['pagetitle'] = $request_object->get('pagetitle');
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['user'] = $request_object->getTVValue('RequestUser');
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['department'] = $request_object->getTVValue('RequestDepartment');
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['status'] = $request_object->getTVValue('RequestStatus');
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['archive'] = $request_object->getTVValue('RequestArchive');
$departmentToEntries[$department_name]['entries'][$request_object->get('id')]['comment'] = $request_object->getTVValue('RequestComment');
$count_request++;
}
echo "<pre>";
print_r($departmentToEntries);
foreach ($departmentToEntries as $department) {
$entriesoutput = '';
if (is_array($department['entries'])) {
foreach ($department['entries'] as $entry) {
$entriesoutput .= $modx->getChunk('RequestItemView', $entry);
}
}
$properties = array();
$properties['department'] = $department['department_name'];
$properties['entries'] = $entriesoutput;
$output .= $modx->getChunk('RequestSectionView', $properties);
}
}