Создание пунктов меню
С помощью Perfex CRM вы можете легко добиться этого, написав всего несколько строк кода.
Информация
Приведенные ниже примеры кода следует поместить в файл инициализации модуля.
Административная часть
php
hooks()->add_action('admin_init', 'my_module_init_menu_items');
function my_module_init_menu_items(){
$CI = &get_instance();
$CI->app_menu->add_sidebar_menu_item('custom-menu-unique-id', [
'name' => 'Custom Menu Item', // Название пункта меню
'href' => 'https://perfexcrm.com/', // ссылка на файл, роут
'position' => 10, // Позиция меню.
'icon' => 'fa fa-question-circle', // Font awesome иконка
]);
}Элемент с элементами подменю
php
hooks()->add_action('admin_init', 'my_module_menu_item_collapsible');
function my_module_menu_item_collapsible()
{
$CI = &get_instance();
$CI->app_menu->add_sidebar_menu_item('custom-menu-unique-id', [
'name' => 'Parent Item', // The name if the item
'collapse' => true, // Indicates that this item will have submitems
'position' => 10, // The menu position
'icon' => 'fa fa-question-circle', // Font awesome icon
]);
// The first paremeter is the parent menu ID/Slug
$CI->app_menu->add_sidebar_children_item('custom-menu-unique-id', [
'slug' => 'child-to-custom-menu-item', // Required ID/slug UNIQUE for the child menu
'name' => 'Sub Menu', // The name if the item
'href' => 'https://perfexcrm.com/', // URL of the item
'position' => 5, // The menu position
'icon' => 'fa fa-exclamation', // Font awesome icon
]);
}Внимание!
Не забудьте заменить префикс my_module в функциях на свой собственный префикс модуля
Расположение пунктов меню администратора по умолчанию
Пункты меню по умолчанию расположены в разных местах, поэтому вы можете разместить свои новые пункты в центре. Найдите пункт по умолчанию и в зависимости от того, куда вы хотите добавить свой пользовательский пункт, настройте атрибут position.
- Панель управления — 1
- Клиенты — 5
- Продажи — 10
- Подписки — 15
- Расходы — 20
- Контракты — 25
- Проекты — 30
- Задачи — 35
- Тикеты — 40
- Лиды — 45
- База знаний — 50
- Сервисы — 55
- Отчёты — 60
Зона обслуживания клиента
php
hooks()->add_action('clients_init', 'my_module_clients_area_menu_items');
function my_module_clients_area_menu_items()
{
// Item for all clients
add_theme_menu_item('unique-item-id', [
'name' => 'Custom Clients Area',
'href' => site_url('my_module/acme'),
'position' => 10,
]);
// Show menu item only if client is logged in
if (is_client_logged_in()) {
add_theme_menu_item('unique-logged-in-item-id', [
'name' => 'Only Logged In',
'href' => site_url('my_module/only_logged_in'),
'position' => 15,
]);
}
}Расположение пунктов меню в клиентской зоне по умолчанию
- База знаний 5
- Регистрация — 99
- Вход — 100
- Проекты — 10
- Счета — 15
- Контракты — 20
- Сметы — 25
- Предложения — 30
- Подписки — 40
- Поддержка — 45
