Jump to content

addon module admin area


dtravlos

Recommended Posts

Hello,

I am trying to create an addon module only for the admins. Can you help me on how I can render templates from each controller action instead of simly echo the content? On the sample addon it says @see AddonModule\Admin\Controller::index() but I can't find the docs... 

Also for ajax calls I can simple create actions and just echo the result as json? 

Thanks

Link to comment
Share on other sites

In the sample addon module  open file: modules/addons/addonmodule/lib/Admin/Controller.php  .  Then find the "index" function.  That's all they mean by "see" as there isn't much more

In the addon modules's _output function that is used for the admin, it only expects HTML / string as a return and thus why they build it up using a string variable in the index function.  You could use the smarty engine, feed it a template file local to the addon's directory, assign the variables needed, and then use the fetch function instead of display to then get the HTML, which you then return and WHMCS spits it out.   I may have another post that details this a bit more.

Link to comment
Share on other sites

4 hours ago, dtravlos said:

Is there any way to have actions tha return only the json response i need and not the entire admin page? 

I would either create a new file for ajax calls or do a "exit;" after you echo the json output. That should work.

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