Create Menu Items

If you are creating your custom modules, probably you will want to create menu items that will be shown on admin area sidebar or clients area navigation.

With Daedelix PSA you can easily achieve this with few lines of code.

The code samples below, should be places in the module init file.

Admin Area

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', // The name if the item
'href' => 'https://DaedelixPSA.com/', // URL of the item
'position' => 10, // The menu position, see below for default positions.
'icon' => 'fa fa-question-circle', // Font awesome icon
]);
}

Item With SubMenu Items

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://DaedelixPSA.com/', // URL of the item
'position' => 5, // The menu position
'icon' => 'fa fa-exclamation', // Font awesome icon
]);
}
Make sure to replace the my_module functions prefix with your own unique function prefix.

Default Admin Menu Items Positions

The default menu items have different positions, so you can hook your new items in the middle, find below the default position, based on where you want to add your custom item, you can adjust the position attribute.
  • Dashboard – 1
  • Customers – 5
  • Sales – 10
  • Subscriptions – 15
  • Expenses – 20
  • Contracts – 25
  • Projects – 30
  • Tasks – 35
  • Tickets – 40
  • Leads – 45
  • Knowledge Base – 50
  • Utilities – 55
  • Reports – 60

Clients Area

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,
]);
}
}

Default Clients Area Menu Items Positions

  • Knowledge Base 5
  • Register – 99
  • Login – 100
  • Projects – 10
  • Invoices – 15
  • Contracts – 20
  • Estimates – 25
  • Proposals – 30
  • Subscriptions – 40
  • Support – 45

Did you find this article useful?

  • Introduction to modules

    The modules documentation is valid starting from version 1.2.3.2 Daedelix PSA version 1.2.3.0 comes ...
  • Module Basics

    The modules documentation is valid starting from version 2.3.2 Daedelix PSA modules use the Code...
  • Module File Headers

    Each module in Daedelix PSA consist of init file which contains the general module configuration an...
  • Common Module Functions

    register_activation_hook /** * Register module activation hook * @param string $module module s...
  • Module Security

    So, you created your module and works fine, but is it secure? You must ensure that your module is se...