Ixonn Group

Add Admin Menu Items

You are here:
< All Topics

With Ixonn you have the ability to add your own menu item inside the admin area whether is for your own usage or you are creating a module.

The process is very easy you need to follow the steps. Adding a new item is available via the built-in Ixonn action hooks.

Create a file with name my_functions_helper.php in application/helpers/ and add the following code (include also the <?php opening tag if not already added):

Version 2.3.0 or above

Main Menu Item

hooks()->add_action(‘admin_init’, ‘my_custom_menu_admin_items’);

 

function my_custom_menu_admin_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://perfexcrm.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_custom_menu_item_collapsible’);

 

function my_custom_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

    ]);

}

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

Prior to version 2.3.0

You can’t add submenu items on existing menu items.

Eq. After the Dashboard menu item.

add_action(‘after_render_single_aside_menu’, ‘my_custom_menu_items’); function my_custom_menu_items($order)

{

    if ($order == 1) {

        echo ‘<li><a href=”#”>HRM App</a></li>’;

    }

}

Customer Admin Menu Items

Eq. After the Customers menu item including Font Awesome icon

add_action(‘after_render_single_aside_menu’, ‘my_custom_menu_items’); function my_custom_menu_items($order)

{

    if ($order == 2) {

        echo ‘<li><a href=”#”><i class=”fa fa-area-chart menu-icon” aria-hidden=”true”></i>Test</a></li>’;

    }

}

Multiple menu items

add_action(‘after_render_single_aside_menu’, ‘my_custom_menu_items’); function my_custom_menu_items($order)

{

    if ($order == 2) {

        echo ‘<li><a href=”#”><i class=”fa fa-area-chart menu-icon” aria-hidden=”true”></i>My First Custom Item</a></li>’;

        echo ‘<li><a href=”#”><i class=”fa fa-area-chart menu-icon” aria-hidden=”true”></i>My Second Custom Item</a></li>’;

    }

}

New menu item with subitems

add_action(‘after_render_single_aside_menu’, ‘my_custom_menu_items’); function my_custom_menu_items($order)

{

    if ($order == 1) {

        echo ‘<li>’;

        echo ‘<a href=”#” aria-expanded=”false”><i class=”fa fa-balance-scale menu-icon”></i>             My Custom Menu<span class=”fa arrow”></span>             </a>’;

        echo ‘<ul class=”nav nav-second-level collapse” aria-expanded=”false”>                <li><a href=”http://mydomain.com/url”>Sub item</a></li>              </ul>’;

        echo ‘</li>’;

    }

}

With conditions for permisisons access checker

add_action(‘after_render_single_aside_menu’, ‘my_custom_menu_items’); function my_custom_menu_items($order)

{

    if ($order == 2) {

        if (has_permission(‘invoices’, ”, ‘view’)) {

            echo ‘<li><a href=”#”><i class=”fa fa-area-chart menu-icon” aria-hidden=”true”></i>Custom Item</a></li>’;

        }

    }

}

Related Articles

Table of Contents
Scroll Up