Plug-in example: how to add a menu item
This article walks you through the steps you need to perform to add a custom menu item into the interface module.
Interface description
To add a new menu item:
- create an xml file ispmgr_mod_menu.xml
 
The path must necessarily be /usr/local/mgr5/etc/xml/ and the name must be ispmgr_mod_<any name>.xml
The XML file must have read and write permissions for the root user.
touch /usr/local/mgr5/etc/xml/ispmgr_mod_menu.xml- add the following description to this file:
 
<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
        <mainmenu level="admin+">
                <modernmenu>
                        <node name="my_group">
                                <node name="myfunc" />
                        </node>
                </modernmenu>
        </mainmenu>
        <handler name="myaddon.sh" type="xml">
                <func name="myfunc" />
        </handler>
        <lang name="ru">
                <messages name="desktop">
                        <msg name="modernmenu_my_group">New menu item</msg>
                        <msg name="modernmenu_myfunc">Test</msg>
                </messages>
        </lang>
</mgrdata>As you can see from the file, the mainmenu tag specifies at what level the section will be visible. In the example - admin+ - super administrator level.
node_name='administrator' - the new menu item will be added to the 'Administrators' section;
node_name='my_group' - the new menu item will be added to the section created by the user;
node_name='myfunc' - declare your function. In order for the panel to start displaying our menu item, it is necessary to have a function with the corresponding name in the panel.
Adding a custom function
- Add a handler for the myaddon function (already added in the ispmanager_mod_menu.xml file):
 
<handler name="myaddon.sh" type="xml"> 
<func name="myfunc" /> 
</handler>
- The addon must be located in the /usr/local/mgr5/addon/ directory
 - Create myaddon.xml file in the /usr/local/mgr5/addon directory:
 
touch myaddon.xmlAdd a plugin to the file (what will be displayed on the page of the created section, don't forget to specify the name of the function we added func="myfunc".
<?xml version="1.0" encoding="UTF-8"?>
<doc lang="ru" func="myfunc" binary="/ispmgr">
        <metadata name="myfunc" type="list" key="name" mgr="ispmgr">
                <toolbar view="buttontext">
                        <toolgrp name="new">
                                <toolbtn name="new" func="webdomain.edit" type="new" img="t-new" sprite="yes"/>
                                <toolbtn name="delete" func="webdomain.delete" type="group" img="t-delete" sprite="yes"/>ls 
                        </toolgrp>
                </toolbar>
                <coldata>
                        <col type="data" name="name" sort="alpha" convert="punycode" sorted="-1"/>
                        <col type="data" name="value" sort="alpha" level="reseller+"/>
                </coldata>
        </metadata>
        <messages name="myfunc" checked="6b49a92f5cc5153c76b78446d0d74eb4">
                <msg name="title">Test</msg>
                <msg name="hint_name">Name</msg>
                <msg name="hint_value">Value</msg>
                <msg name="short_new" added="common">Create</msg>
                <msg name="short_delete" added="common">Delete</msg>
                <msg name="hint_delete" added="common">Delete</msg>
                <msg name="hint_new" added="common">Create</msg>
                <msg name="name" added="common">Name</msg>
                <msg name="value" added="common">Value</msg>
                <msg name="hint_export">Save in CSV</msg>
                <msg name="hint_selectall">Select all elements of the list</msg>
                <msg name="hint_reloadlist">Update list</msg>
                <msg name="hint_print">Open print version</msg>
                <msg name="hint_autoupdate_stop">Cancel auto-update of the current list</msg>
                <msg name="hint_takefavorite">Add to favorites</msg>
                <msg name="hint_takeunfavorite">Remove from favorites</msg>
                <msg name="msg_tsetting">Customize table view</msg>
        </messages>
        <tparams>
                <out>devel</out>
                <func>myfunc</func>
        </tparams>
        <p_sort>name</p_sort>
        <p_order>desc</p_order>
        <page>test.ru — domain.mary</page>
        <elem>
                <name>One</name>
                <value>Hello</value>
        </elem>
        <elem>
                <name>Two</name>
                <value>World!</value>
        </elem>
        <p_num>1</p_num>
        <p_elems>6</p_elems>
</doc>Create a file myaddon.sh in the addon folder (add a handler)
touch myaddon.shSet permissions for the handler with the following commands:
chmod 750 /usr/local/mgr5/addon/<handler_file_name>
chown 0:0 /usr/local/mgr5/addon/<handler_file_name>- Add two lines to the myaddon.sh file
 
#!/bin/bash 
cat /usr/local/mgr5/addon/myaddon.xmlTo make the panel re-read all changes, restart it with the command pkill -9 core.
When you click on the Test section (which is the name given to it in the lang block), myaddon.sh will be called, which should return a full xml with the necessary data to the panel.
Result

