We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6057
    • 26 Posts
    Hi,

    I'm starting work on a new feature for a MODX Evo site which will be a Mgr Module to manage data in some custom tables. I've developed Modules before and this time, due to the nature of the data being edited, I'd like to be able to use AJAX in the Module UI rather than having to rebuild the whole UI for every change.

    I've looked inside manager/index.php and can appreciate that there is a lot going on there to setup the manager environment. I've looked to see if anyone has developed an index-ajax.php version of the file but without any success.

    I have used AJAX inside a Mgr Module before to execute code in a snippet (preview it inside manager). It worked but AFAIK it is completely outside of any mgr session etc. At a minimum, I think it should confirm the user is logged in correctly to the manager and setup the $modx object to use the API.

    Is this possible?
    What are the challenges of using AJAX within a Mgr Module?

    Any help, as always, greatly appreciated.

    PS: I'm sure this question has been asked before but, for some reason, I find it hard to find things in the forums. I did find this: https://forums.modx.com/thread/25195/change-manager-to-use-frames-for-separate-sections which is relevant background to this subject.
      • 13428 ☆ A M B ☆
      • 1,031 Posts
      If you want to manage custom table data in a manager module and don't want to code very much, you could use the multiTV Database Manager module from https://github.com/Jako/multiTV/tree/feature/module branch. It will go beta today (it is wide tested on a customer website, but only on one).

      If you want to code your own system you could look into https://github.com/Jako/multiTV/blob/feature/module/assets/tvs/multitv/multitv.connector.php which does the ajax part of the module. It starts the session, creates a new document parser, gets the module settings/module config, does some checks and executes the processor for the action.

      There is no written documentation for the module now. But look into the multiTV documentation (part 1: custom template variable) to see the options for the configuration files and test the module with the https://github.com/Jako/multiTV/blob/feature/module/assets/tvs/multitv/moduleconfigs/event_log.moduleconfig.json configration.

      Hope that helps a bit.
        • 6057
        • 26 Posts
        Thanks for the reply Jako - the connector PHP was what I was expecting to need and that'll certainly get me on the right tracks.