Create Menu Items

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 Our CRM 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://ourcrm.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://ourcrm.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


    • Related Articles

    • Add Items/Products

      Create new item To create new items from the main admin menu navigate to Sales->Items and click on the top left button New Item. Description – Give the item short description of item heading. Long Description – Item long description for more detailed ...
    • Create proposal

      Create a proposal From the main menu navigate to Sales->Proposals and on the top left side click the Create Proposal button You can create a proposal to lead or to a customer. Choose Related to Lead or Customer. Choose which lead/customer is related. ...
    • Create Estimate

      To create new estimate go to Sales -> Estimates -> Create New Estimate or by clicking on the Build icon on the top left side and click Create Estimate Client – Before selecting a client you must have added clients Customers->New Customer. When ...
    • Create Invoice

      To create new invoice go to Sales -> Invoices and click on the button Create new invoice Select Customer, when selecting a Client the customer information's will be fetched directly from the customer’s profile. Another option is that you can click on ...
    • Create New Task

      In order to create a new task, from the main menu navigate to Tasks and click on the New Task button. Subject – Enter the subject for the task in order to easily identify it. Hourly Rate – Set task hourly rate Start Date – Set the date when the task ...