Вадим Малай - Developing for Panels. CTools Plugins.10. Декларация в модуле
function my_layout_ctools_plugin_directory($owner, $plugin_type) {
// Создайте папку 'plugins' в модуле и ставьте .inc файл туда.
if ($owner == 'panels' && $plugin_type == 'layouts') {
return "plugins/$plugin_type";
}}
wearepropeople.com
11. В .info Файл-е Темы
; Panels layouts. Можете создать несколько папок в папке "layouts", каждая из
которых будет содержать файлы макетов Panels.
plugins[panels][layouts] = plugins/layouts
wearepropeople.com
12. Декларация Макета
my_layout.inc
$plugin = array(
'title' => t('Layout Title'),
'category' => t('Layout Category'),
'icon' => 'my_layout_icon.png',
'theme' => 'my_layout', //Соответствует с названием файла
'css' => 'my_layout.css',
'regions' => array(
'feature' => t('Feature'), // Найменование Регионов
),
);
wearepropeople.com
15. Декларация в модуле
function module_ctools_plugin_directory($owner, $plugin_type) { if ($owner
== 'panels') { return "plugins/$plugin_type";
}
}
wearepropeople.com
16. В .info Файл-е Темы
; Panels styles. Можете создать несколько папок в папке "styles", каждая из
которых будет содержать файлы стилей Panels.
plugins[panels][styles] = plugins/styles
wearepropeople.com
17. Декларация Стиля
$plugin = array(
'title' => t('Style Title'),
'description' => t('Style Description.'),
'render region' => 'module_render_region',
'render pane' => 'module_render_pane',
'settings form' => 'module_raw_region_settings_form',
'pane settings form' => 'module_raw_pane_settings_form',
);
wearepropeople.com
21. Декларация Content Panes
function module_ctools_plugin_directory($owner, $plugin_type) { if ($owner
== 'ctools' && $plugin_type == 'content_types') { return 'plugins/' .
$plugin_type;
}
}
wearepropeople.com
22. Декларация Plugin-a
$plugin = array(
'single' => TRUE,
'title' => t('Title'),
'description' => t('Description'),
'category' => t('Category'),
'edit form' => 'module_edit_form',
'render callback' => 'module_render',
'admin info' => 'module_admin_info',
'defaults' => array( ),
'all contexts' => TRUE,
);
wearepropeople.com
23. Настройки
function module_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
// Implements Form API return $form;
}
function module_edit_form_submit(&$form, &$form_state) { foreach
(array_keys($form_state['plugin']['defaults']) as $key) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}
wearepropeople.com
24. Вывод Content-a
function module_render($subtype, $conf, $args, $contexts) { if
(!empty($contexts)) {
$content = ctools_context_keyword_substitute($conf['text'], array(),
$contexts);
}
$block = new stdClass();
$block->title = t('This is my title!'); $block->content = $content; return
$block;
}
wearepropeople.com
26. Декларация Плагина Доступа
function custom_module_ctools_plugin_directory($module, $plugin) {
if ($module == 'ctools' && !empty($plugin)) {
}
}
wearepropeople.com
return "plugins/$plugin";
27. Декларация Плагина
$plugin = array(
'title' => t('Title'),
'description' => t('Description'),
'callback' => 'module_custom_ctools_access_check',
'default' => array('some_value' => 0),
'settings form' => 'module_custom_ctools_settings',
'summary' => 'module_custom_ctools_summary',
'required context' => new ctools_context_required(t('Node'), 'node),
);
wearepropeople.com
29. Разрешение на Вывода
function module_custom_ctools_access_check($conf, $context) {
$context; // Context of row input
$conf; // Entered Settings
return FALSE; // Access Denied
return TRUE; // Allow Access
}
wearepropeople.com