public function searchResources()
{
$type = 'resources';
$typeLabel = $this->modx->lexicon('search_resulttype_' . $type);
$contextKeys = array();
$contexts = $this->modx->getCollection('modContext', array('key:!=' => 'mgr'));
foreach ($contexts as $context) {
$contextKeys[] = $context->get('key');
}
$c = $this->modx->newQuery('modResource');
$c->leftJoin('modTemplate', 'modTemplate', 'modResource.template = modTemplate.id');
$c->select($this->modx->getSelectColumns('modResource', 'modResource'));
$c->select("modTemplate.icon as icon");
$c->where(array(
array(
'modResource.pagetitle:LIKE' => '%' . $this->query .'%',
'OR:modResource.longtitle:LIKE' => '%' . $this->query .'%',
'OR:modResource.alias:LIKE' => '%' . $this->query .'%',
'OR:modResource.description:LIKE' => '%' . $this->query .'%',
'OR:modResource.introtext:LIKE' => '%' . $this->query .'%',
'OR:modResource.id:=' => $this->query,
),
array(
'modResource.context_key:IN' => $contextKeys,
)
));
$c->sortby('modResource.createdon', 'DESC');
$c->limit($this->maxResults);
$collection = $this->modx->getCollection('modResource', $c);
/** @var modResource $record */
foreach ($collection as $record) {
$this->results[] = array(
'name' => $this->modx->hasPermission('tree_show_resource_ids') ? $record->get('pagetitle') . ' (' . $record->get('id') . ')' : $record->get('pagetitle'),
'_action' => 'resource/update&id=' . $record->get('id'),
'description' => $record->get('description'),
'type' => $type,
'class' => $record->get('class_key'),
'type_label' => $typeLabel,
'icon' => str_replace('icon-', '', $record->get('icon'))
);
}
}
}
return 'modSearchProcessor2';
Может для кода будешь pastebin использовать?)
Обсуждают сегодня