Jump to content

Some Questions about hooks and adding to the Shortcuts menu


RN2013

Recommended Posts

Hi All

I am trying to figure out a few things regarding hooks. 

Firstly sorry for probably asking some daft questions. 

I have managed to hide some sidebar  items like the "Contacts" and "My Info" as well as some of the default "homePagePanel" items like Recent News etc. So I have made some progress. 

 

I am now left with the "Shortcuts" sidebar. 

Is it possible to add "login to cPanel" and "login to Webmail" if the client is a hosting client as an example. 

Also how can I tell the what a "primarySidebar" and a "secondarySidebar" is, is there a reference of what these are?

Also in 

add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)

What does the 1 signify, all the examples i have seen seem to be 1, but i am guessing that it may be related to priority, i.e. 1 before 2, before 3 etc

 

Thanks in advance

Lyndon

Link to comment
Share on other sites

I have done a bit more around this, and have added some menu items to the Shortcuts Menu but these are custom links to external resources like access to a coverage map etc. 

Does anyone know if it is possible to add a menu item from another menu, to the Shortcuts Menu, as per the original post, I would like to add "Login to cPanel" from the Actions Menu, to the Shortcuts Menu. 

Link to comment
Share on other sites

I have done a bit more around this, and have added some menu items to the Shortcuts Menu but these are custom links to external resources like access to a coverage map etc. 

Does anyone know if it is possible to add a menu item from another menu, to the Shortcuts Menu, as per the original post, I would like to add "Login to cPanel" from the Actions Menu, to the Shortcuts Menu. 

 

I have tired this and a few variations but I don't have the skills and can't find the supporting documentation to point me in the right direction, some of this code has been picked on the community and from a few examples online

 

add_hook('ClientAreaPrimarySidebar', 2, function (MenuItem $secondarySidebar) {
    // Get the "Client Shortcuts" menu
    $clientShortcutsMenu = $secondarySidebar->getChild('Client Shortcuts');

    // Get information about the current service
    $service = Menu::context('service');
    $domain = $service->domain;
    $servertype = $service->product->servertype;

    // Check if the "Client Shortcuts" menu exists
    if ($clientShortcutsMenu) {
        // If the server type is not cPanel, do nothing
        if ($servertype != "cpanel") {
            return;
        }

        // Check if the "Service Details Actions" menu exists
        if (!is_null($clientShortcutsMenu->getChild('Actions'))) {
            // Get Service Details "Login to cPanel" link
            $clientShortcutsMenu->getChild('Actions')
                ->getChild('Log in to cPanel')
                ->addChild('Log in to cPanel');

            // Set the URI for the "Login to Webmail" link
            $clientShortcutsMenu->getChild('Actions')
                ->getChild('Login to Webmail')
                ->addChild('Login to Webmail');
        }
    }
});
 

Any assistance would be much appreciated. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated