We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7834
    • 4 Posts
    I am really new to MODx as a matter of fact I only started today with my investigation to see if this cms fits my needs.
    Up untill now it really looks that way except for one part, I cannot seem to find how I can add functionality to the admin section.

    My guess is that the modules are the key for this but the documentation does not go into detail about this.

    Did I just not search well enough or is this documentation not there yet, and if so is it planned to be written?
    • This is an area that is currently doable, but you have to know what you’re doing. In the next major release, which we’re working very hard on, not only will the manager be totally skinnable, but it will also be able to be easily customized and extended. Look for lots of good stuff through the remainder of 2005 and all of 2006. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • Modules are how you would extend the back-end.

        I am currently in the process of creating a module for controlling a glossary database that can be accessed read-only by certain Web users from the front-end, and managed from a module. Basically, the module is much like a snippet.

        The output of the module is in the right-hand panel of the Manager, just like the built-in functions. I use that as my interface, and otherwise write the application as I would any other PHP application, including files and classes and whatever else I need, into the main module. All of the include files are stored in a folder in the /assets/modules/ folder.

        All of the MODx API is available, so a lot of the work is already done as far as document manipulation goes.

        So far, this is my module code:

        $basePath = $modx->config['base_path'];
        
        // If we cant't find the module files...
        if(!file_exists($basePath.$mod_path)) {
        
         // Log an error
         $error_message = '<strong>Glossary module not found!</strong></p><p>Edit the Glossary module, click the Configuration tab and change the Module Path to point to the module.</p>';
         $modx->Event->alert($error_message);
         $modx->logEvent(0, 3, $error_message, 'Glossary');
        
        } else {
        
          $GLOBALS['glossary_path'] = $mod_path;
          // include the language file
          include($basePath.$mod_path.'/langs/en.php');
          // if Browse or Search
          if(!empty($_POST) && isset($_POST['browse']) || isset($_POST['search'])) {
            include($basePath.$mod_path.'/mutate_termbase.dynamic.action.php');
          } else {
            include($basePath.$mod_path.'/manage_termbase.dynamic.action.php');
          }
        
        }


        The $mod_path variable is set in the Configuration of the module:

        &mod_path=Module Path (from site root);string;assets/modules/glossary


        I wrote my include files to mimic the existing manager action and processor files. For example, the main manage_termbase file has (along with some functions and other stuff) this:

        <html>
        <head>
        	<title>termbase</title>
        	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        	<link rel="stylesheet" type="text/css" href="media/style/style.css?" />
        	<link rel="stylesheet" type="text/css" href="media/style/coolButtons2.css?>" />
        
        <style>
        
        body {
        
        	overflow-x : hidden; /* stupid hack for equally stupid MSIE */
        
        }
        
        </style>
        </head>
        <body>
        
        <div class="subTitle">
        
        	<span class="right"><?php echo $_lang['manage_termbase']; ?></span>
        
        </div>
        
        


        So it uses the same css files and button and background images as the rest of the Manager.

        Otherwise, it works just like any php application works. I can determine who can run it by what manager user groups it is assigned to.

        The method used in the Manager to run modules is a little obscure at this time; I’m sure it will be improved in future releases.


          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
          • 7834
          • 4 Posts
          That seems like what I need, I will try to create it simular to your example, thanks!
            • 19726
            • 239 Posts
            There is also an example in the MODx documentation.
            See http://www.modxcms.com/creating-a-module.html
              • 7834
              • 4 Posts
              Ok I finally had time to check this out, below is how I did it:

              If the next steps are not clear enough, it is always handy to look at an already existing template in the directory where you are going to make a new one.

              steps taken:

              • Create the text you want to use in the file manager/includes/lang/english.inc.php

              • Create a file doing the logic in the directory: manager/processors/action_modulename.processor.php
                The last lines in the file need to be:
                $header="Location: index.php?a=7";
                header($header);
                a=7 stands for a refresh of the page, you can also create another template and add a reference like in step 4

              • Create a file doing the presentation in the directory: manager/actions/dynamic/action_modulename.dynamic.action.php
                This file needs to post to index.php?a=896, the number after a is the one you will create yourself and add in step 4

              • Adjust the file manager/index.php add 2 cases at the bottom just after the last case like this:
                case "896":
                include_once "processors/save_percentage.processor.php";
                break;
                case "897":
                // get percentage edit screen
                include_once "header.inc.php";
                include_once "actions/dynamic/mutate_percentage.dynamic.action.php";
                include_once "footer.inc.php";
                break;
                Please note that as far as I can tell there is no real system in the numbering, just create something that does not exist.

              • open up the file: manager\frames\l1mnu.php and add a menu item here.
                Make sure that this menu will link to: index.php?a=897 where a= needs to be the number you have specified in step 4, make sure this is the edit screen version.

              • You are done.


              Now as far as I could tell there is no current use to create a module using the manager itself, if I bypassed the system then I would love to hear it because even though it is workable I see a lot of minor tweaks to make this work a bit better and more structured.

              If any of the MODx developers want to contact me about this, please feel free to send me an email.
                • 7834
                • 4 Posts
                The lack of response gives me the idea that there is no better way of doing this yet? wink
                • donovan:

                  i must have missed this original thread somehow, but modules do not need to be added to the manager; you run them from the Manage Modules area of the manager, by selecting a module and then hitting the Run button

                  sorry for not getting back to you sooner on this