Skip to content

FAQ Item

« Return to FAQ database

Add custom link to menu or a new page

Create a new folder called includes/plugin_custom_link/ and create a new file in this folder called custom_link.php

Open this new file includes/plugin_custom_link/custom_link.php and add this PHP code to the file:

<?php
class module_custom_link extends module_base{
    public function init(){ }
    public function get_menu($holding_module=false,$holding_page=false,$type=false){
        $links=array();
        if(!$holding_module){
            // rendering the main menu:
            $links[]=array(
                 'm'=>'custom_link', 'p'=>'your_custom_page',
                'name'=>'Main Menu Link',
                'order'=>999999,
            );
        }else if($holding_module == 'customer'){
            // rendering the customer menu              $links[]=array(
              'name'=>'Customer Submenu Link',
              'm'=>'custom_link',
              'p'=>'your_custom_page',
              'order'=>999999,
              'args'=>array(
              'user_id'=>false,
              'some_other_id'=>123,
              ),
              'holder_module' => 'customer',
              'holder_module_page' => 'customer_admin_open',
              'menu_include_parent' => 0,
              'icon_name' => 'user',
              );
        }
        return $links;
    }
}

this will create a link named "Main Menu Link" in the main menu, and a new link called "Customer Submenu Link" when viewing a customer.
if you don't want to display the main menu, remove the first $links[] array from above. If you don't want to display the submenu, remove the second. 

Create a new folder called 'includes/plugin_custom_link/pages/' and create a new file in this folder called 'your_custom_page.php'

Edit this file, anything inside this file will display when the user selects the menu item.

Have fun!

© dtbaker.net