Jump to content

Very Basic Need for Menu


GOT

Recommended Posts

I am not a developer and looking at tutorials about modifying menu structure are beyond me, plus I have a non-fixed item to add.

Basically, many (not all) clients of mine gets a custom coded url that integrates a key to facilitate one click log in, so I can't hard-code the url for every client.

What I am thinking is a custom client field that is their URL, and then a menu item that pulls that link from their client data and displays it in the side menu.  But only if that data exists, if that client field is blank then then menu item would not appear at all.

Is there an existing module for this kind of thing?  Is there some way to do this already built in to whmcs?

Otherwise, is there someone out there that can code me a module for this at a reasonable cost?  I'm guessing this would be reasonably simple for someone familiar with customizing whmcs.

 

Link to comment
Share on other sites

Thanks for the quick reply.

The URL looks like this

https://got-monitor.com/group.htm?id=0&username=XXXXXXXX&password=XXXXXXX

That's our domain, but its a different domain than our WHMCS is on.  URL is always the same save for the user/password.

This URL is for our clients that have managed services through us which is most of them but not all of them.  We would not want the url or menu item to show at all if they do not have a log in to the monitoring system to begin with.

We'd want a solution that is impervious to getting overwritten on whmcs updates.

An even better solution might be to store the username and password for their log in and just pull that data when crafting the url for the menu item.

If better to talk about the project in private, you can reach me at greenot on skype.

Link to comment
Share on other sites

the following action hook will check if client is logged in, and if the configured custom field has a value, then add new menu item to primary navbar as an example.

create new php file (eg. Navbar_MonitorLoginLink.php) inside "/includes/hooks/" directory, copy and edit the required lines:

<?php
/**
 * @author SENTQ
 */
use WHMCS\Database\Capsule;

# We are working on Primary Navbar
add_hook("ClientAreaPrimaryNavbar", 1, function($primaryNavbar){
    
    # Client Custom Field Name
    $customFieldName = "Username"; // **Change this value
    
    # Get Client
    $client = Menu::context("client");
    
    # Not Logged In!
    if ($client === null){
        return;
    }
    
    # Get Custom Field Value
    $getURL = Capsule::table("tblcustomfieldsvalues")
    ->join("tblcustomfields", "tblcustomfields.id", "=", "tblcustomfieldsvalues.fieldid")
    ->where("tblcustomfieldsvalues.relid", "=", $client->id)
    ->where("tblcustomfields.type", "=", "client")
    ->where("tblcustomfields.fieldname", "=", $customFieldName)
    ->select(["tblcustomfieldsvalues.value"])
    ->first();
    
    # Custom Field Value is Empty!
    if (!$getURL->value){
        return;
    }
    
    # Add New Menu Item To Primary Navbar -> Home
    $newLoginLink = $primaryNavbar->addChild('Home', array(
        "name" => "New_login_link",
        "label" => "New Login Link", // **Change this line as well
        "uri" => $getURL->value,
        "order" => 100
    ));
    
});

 

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