Adding external links to the menu

From ISPWiki

Jump to: navigation, search

Following is an example on how you can add a link to your application (for example, monitoring or statistics system) into the control panel's menu.

Requirements

  • ISPmanager
  • Your application is accessible at https://your.domain.com/mystat/
  • A menu item should be called "My statistics" that should be located in the "Statistics" section on the administrator access level.

Operations

1) Create a file that will describe the plug-in /usr/local/ispmgr/etc/ispmgr_mod_mystat.xml with the following contents

<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
  <mainmenu level="7">
    <node name="stat">
      <node name="myfunc"/>
    </node>
  </mainmenu>
  <lang name="ru">
    <messages name="desktop">
      <msg name="menu_myfunc">My statistics</msg>
    </messages>      
  </lang>
  <lang name="en">
    <messages name="desktop">
      <msg name="menu_myfunc">My statistic</msg>
    </messages>      
  </lang>
</mgrdata>

2) Execute the command

/usr/local/ispmgr/sbin/mgrctl extaction.add name=myfunc url=/mystat/

or add the following line into ispmgr.conf

extaction myfunc /mystat/

3) Restart ISPmanager

4) Refresh the control panel's page

Comments

Menu description


<mainmenu level="7">
   <node name="stat">
     <node name="myfunc"/>
   </node> 
</mainmenu>

This block defines that a new menu item called "myfunc" will be added into the "stat" section to the user's main menu (server administrator with access level 7). Using the mainmenu tag in the ispmgr.xml file you can learn the names of existing modules and internal names of the sections.

To add a menu item into several access levels, for example into user and administrator levels, you need to describe all these levels. Following is the XML that describes the menu:

<mainmenu level="7">
   <node name="stat">
     <node name="myfunc"/>
   </node>
</mainmenu>
<mainmenu level="5">
   <node name="stat">
     <node name="myfunc"/>
   </node>
</mainmenu>

Message descriptions


 <lang name="ru">
   <messages name="desktop">
     <msg name="menu_myfunc">My statistics</msg>
   </messages>      
 </lang>

This block defines that you need to add a "My statistics" message with the internal name myfunc into the desktop function (one that forms a menu). This text box relates to a "ru" (Russian)locale (user's interface language) called. We have added the following block to show messages in other languages:

 <lang name="en">
   <messages name="desktop">
     <msg name="menu_myfunc">My statistic</msg>
   </messages>      
 </lang>

"en" (English) is a default locale, i.e. if a message in a user's language is missing, one from the en locale will be used, that's why we recommend that you describe this locale. If you want to add a message in other languages, add a corresponding block for each language. Following is the example in French:

 <lang name="fr">
   <messages name="desktop">
     <msg name="menu_myfunc">Mes statistiques</msg>
   </messages>      
 </lang>

Activating a module


Since the modules described in the menu may be inactive (for example, an application may not be installed), the control panel may hide them. You need to activate a menu item and provide the action that will be performed when the item is selected. To do that, add the following line into the configuration file:

extaction myfunc /mystat/

the command provided above performs the same operations; if you activate the module with a script, you'd better execute the command rather than modify the configuration file.


Restarting the control panel


Restart the control panel to enable it to connect and process our file ispmgr_mod_mystat.xml, as well as to re-read the configuration file.

Was this helpful? Yes | No
Views
Personal tools