We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15505
    • 2 Posts
    Hi!
    I´m trying to create a new module which should help me maintain a custom database table.
    I started out using Susan´s tutorial the this subject: http://www.sottwell.com/create-module.html

    What I have, is a module in MODx, which includes a index.php file. This file starts out with if(IN_MANAGER_MODE!="true") die("Your INCLUDE_ORDERING_ERROR here");
    and the files works as intended. I can - from the index.php file - access the database tables and retrieve all the data from it.

    On the index.php file, I have added a link to a new page, called "insert_new_row.php", which just contains a form with some simple input-fields.
    What I want to do is this: set the form action to ’../assets/modules/myModule/index.php’, when the form is submitted, it sends the form-data back to the index.php file.
    I was thinking of having all the PHP/MySQL action on the index.php file.

    BUT here is the catch! When I submit the form, it goes back to the "index.php", but now the file is "accessed" from outside the manager, and I now get the "INCLUDE_ORDERING_ERROR".

    I have tried using the AJAX solution, but I ran into some other problems ( when using AJAX the DOM was not properly updated, and when I submitted the first form, everything worked, but the next time I submitted the form, all of the values where the same values as in the first form-submit).

    Anyone have any helpful suggestions?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Everything from the module must be accessed from the module’s frame. You need to pass the action and the module ID with every form, so that it gets loaded properly by the Manager. You should not be using any kind of html pages; it should all be PHP files and be included by the module code. The module code would contain your HTML and act as a switchboard, including your external files according to what needs to be done. You could have all of your code in the module as functions, or use just one external include file with all of the functions. The index.html files in assets/modules/modulename/ are only to prevent someone from directly accessing the directory and getting a list of files in the directory (if the server is configured to display a directory list, which it really shouldn’t be).

        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 15505
        • 2 Posts
        Ok - thanks for pointing me in the right direction, Susan!

        I now re-modeling my module, and so far things are looking good cool

        BTW, thank you for all the soft intro tutorials on MODx, I found them to be a really huge help getting me started on MODx - thx grin You have eased my learning curve by appx. 30 degrees - hehe.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I always find it best for myself to make a very minimalist "Hello, world" module to begin with, then get it to look the way I want (usually just imitating the others and including the manager/includes/header.inc.php and footer.inc.php files), then start cautiously adding one thing at a time. It saves all the aggravation of trying to figure out what I did to break it if I keep each step small!
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org