Jump to content

Accessing addon modules with the new v7.3 routing system.


(Amr)

Recommended Posts

Before WHMCS v7.3, developers used to post Ajax requests to "addonmodules.php?module=module_name". With WHMCS v7.3, that doesn't work if the current URL is a virtual path "i.e /admin/setup/authn/view".

After checking the new JavaScript files, it seems that, there is an internal method to translate/get valid paths, and it's called as follows :

WHMCS.adminUtils.getAdminRouteUrl('/path/to/get');

Since this is not -yet- a documented method , could you please let me know, how to use this method to get addon modules valid path ?

Edited by (Amr)
Link to comment
Share on other sites

In-case someone else is wondering, here is the official reply I just received, thanks to @WHMCS Nate :

 

Quote

 

Hello Amr,

We provide two variables in global scope for JS that should allow you to build ajax calls to addon modules within pages in the new v7.3 admin routes. You can provide absolute paths to your AJAX request utilizing the following:

  • 'whmcsBaseUrl': a global scope variable available in either client or admin areas. It's value the absolute path of the WHMCS directory on the domain
  • 'adminBaseRoutePath': a global scope variable available in the admin area. It's value is the name of the (custom) admin directory (ie, the relative path from 'whmcsBaseUrl' that leads to the admin area)

Two Examples:

"http://foo.bar/somedir/whmcs/admin/fancy/route"
- whmcsBaseUrl = "/somedir/whmcs"
- adminBaseRoutePath = "/admin"

"http://foo.bar/mycustomadminpath/some_admin_endpoint.php"
- whmcsBaseUrl = ""
- adminBaseRoutePath = "/mycustomadminpath"

So, in your example, you could use the following


var mypath = 'addonmodules.php?module=module_name'
var request_path = whmcsBaseUrl + adminBaseRoutePath + '/' + mypath;

Have a great day,

Nate C

 

 

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