Всем привет. Подскажите как получить записи выбранного типа контента. Или всем списком или в виде поиска. Начинаем указывать название записи и появляются записи, выбираем именно ту которую нужно и сохраняем её id. Это касается в компоненте в backend.
Категории получаю так.
new fieldList
('ctype_id', array( 'title' => 'Тип категории',
'default' => 1,
'generator' => function($ctype) use ($content_model) {
$tree = $content_model->getContentTypes();
$items = [];
if ($tree) {
foreach ($tree as $item) {
$items[$item['id']] = $item['title'];
}
}
return $items;
},
'visible_depend' => array('tip_ctypes' => array('hide' => array('content', ''))) )),
new fieldList
('category_id', array( 'title' => 'Под категории',
'list' => 'ctype_id',
'url' => href_to('content', 'widget_cats_ajax')
),
'generator' => function($item, $request) use ($content_model) {
$list = ['' => ''];
$ctype_id = is_array($item) ? array_value_recursive
('ctype_id', $item) : false; if (!$ctype_id && $request) {
$ctype_id = $request->get('ctype_id', 0);
}
if (!$ctype_id) {
return $list;
}
$ctype = $content_model->getContentType($ctype_id);
if (!$ctype) {
return $list;
}
$cats = $content_model->getCategoriesTree($ctype['name']);
if ($cats) {
foreach ($cats as $cat) {
if ($cat['ns_level'] > 1) {
$cat['title'] = str_repeat('-', $cat['ns_level']) . ' ' . $cat['title']; }
$list[$cat['id']] = $cat['title'];
}
}
return $list;
},
'visible_depend' => array('tip_ctypes' => array('hide' => array('content', ''))) )),