Jump to content

Access WHMCS menu through API


jmtech

Recommended Posts

Hi all,

 

I'm planning on using Wordpress for my KB and News articles and as such will be branding my Wordpress site the same as my WHMCS. I am planning on dynamically generating my Wordpress menu based on the WHMCS menu so I only need to update it in one place. The problem I have is enumerating through the list of menu items defined in WHMCS as there appears to be no API for Navigation.

 

Any ideas on the best way to get this info out of WHMCS?

 

Cheers,

Jason

Link to comment
Share on other sites

Hi Jason,

The menu is a object

You can use it in any whmcs. Here is de Doc: http://docs.whmcs.com/Editing_Client_Area_Menus

 

try this code inside any add-on

 

echo "<pre>";

var_dump(Menu::primaryNavbar());

echo "</pre>";

 

its a start

 

Thanks for that - I'm quite familiar with using and customising the menu objects within WHMCS - however, I'm trying to get access to the object from within Wordpress (outside of WHMCS). Some options that I have.

 

- Scrape the HTML from WHMCS. This would involve getting the HTML for the home page and searching for an element ID for the menu container and getting the inner HTML.

- Include WHMCS in Wordpress. Given my wordpress install is in the same physical location as WHMCS, I could try and find and include the relevant PHP file/s to include to gain access to the menu objects from within Wordpress.

- Create an Addon to expose the Menu. I could create an addon that presents the menu as a public JSON endpoint.

- Manually replicate the menu. Given the menu doesn't change very often, I could just manually update it in Wordpress when it changes.

- Control the menu from Wordpress. I've done this before - I could include wp_load.php in WHMCS and then dynamically generate the WHMCS menu based on the Wordpress menu.

 

Anyone know what the equivalent of wp-load.php is for WHMCS? Would save me some time trying to figure it out, if it's at all possible.

 

Cheers,

Jason

Link to comment
Share on other sites

  • 1 year later...

Hi all, 

Just thought I would update if anyone was interested. 

I decided to do it the other way round. I have my wordpress site as the main site and I load my Wordpress menu within WHMCS. I have then customised my WHMCS template to match my Wordpress site. Here's how I get my WHMCS menu to match my Wordpress menu. Basically I start by removing all the standard WHMCS menu items. Then I iterate through all the wordpress menu items and add them to WHMCS.

// ----- Main Nav Bar -----
add_hook('ClientAreaNavbars', 1, function ()
{
    require("../pathToWordpress/wp-load.php");
    $wpMenu = wp_get_nav_menu_items('Top Menu');
 
// Get the current navigation bars.
$primaryNavbar = Menu::primaryNavbar();
$secondaryNavbar = Menu::secondaryNavbar();
    
    // Remove unecessary menu items
 $primaryNavbar->removeChild('Announcements');
 $primaryNavbar->removeChild('Knowledgebase');
 $primaryNavbar->removeChild('Network Status');
$primaryNavbar->removeChild('Home');
$primaryNavbar->removeChild('Store');
$primaryNavbar->removeChild('Contact Us');
 
$order = 1;
 
foreach($wpMenu as $item) {
$primaryNavbar->addChild($item->title)
->setUri($item->url)
->setOrder($order);
$order++;
}
}
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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