We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27330
    • 884 Posts
    Hi all,
    can anyone direct me on where to look if I want to set "Continue editing" as default when saving docs in the manager?

      • 3785
      • 143 Posts
      Yes I also miss this feature some times, but I didn’t find a simple solution to that. Would be nice to have it customizable someday.
        Medianotions – Studio für Webdesign
        http://www.medianotions.de
        • 7231
        • 4,205 Posts
        Plug-ins are your friend for setting custom default values. I have not messed with this one but I have with other parameters. The principle is to identify the id/name for the button in question then either add the command to the InheritParentTemplate plug-in (this is convenient since it is already working anyway), or do your own custom plug-in (use the inherit one as a starting point).

        Like this you could write unlimited amount of custome settings based on parent id, action, etc...

        Here is some help to get you started:
        1) the identifier for the button is $_REQUEST[’stay’], the value that represents the create a new doc is 1.

        2) the button is looking for the $_REQUEST[’stay’] value in order to set the status of the push button. Add this into the plugin to tell it to select the "add another" option:
        $_REQUEST['stay'] = "1"; 


        In order to control when to use this you could set a few logic statements to look to see if the document belongs to a certain parent, uses a certain template, or if it is editing or adding new documents.

        Hope this helps and gives you a good idea of the possibilities. Also I am not sure but the ManagerManager plug-in may also have control over that button which will make it easy to manage and customize.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 27330
          • 884 Posts
          sorry too many posts I’m spacing out on the replies smiley

          Thanks everyone for the replies.
          @dev_cw , thanks for those tips on how to do the plugin. too bad my coding experience is based on copy/paste smiley
          I’ll install ManagerManager tonight as it sounds interesting whether it can do what I want or not. thanks for a nice find.
          @ganeshXL thanks for that hack. since my coding experience is based on copy/paste this was the fastest way to do that. thanks.


            • 7231
            • 4,205 Posts
            @sinbad - editing the file as ganeshXL offered is a good solution, however, once you update your modx site this file will most likely be replaced and you will loose the edit. By using it in a plug-in it will continue to work since it is stored on the database. In case you are interested here is the edited plug-in:

            /*
             * Inherit Template from Parent
             * Written By Raymond Irving - 12 Oct 2006
             *
             * Simply results in new documents inherriting the template 
             * of their parent folder upon creating a new document
             *
             * Configuration:
             * check the OnDocFormPrerender event
             *
             * Version 1.0
             *
             */
            
            global $content;
            $e = &$modx->Event;
            
            switch($e->name) {
              case 'OnDocFormPrerender':
                if(($_REQUEST['pid'] > 0) && ($id == 0)) {
                  if($parent = $modx->getPageInfo($_REQUEST['pid'],0,'template')) {
                    $content['template'] = $parent['template'];
                  }
                }
                // set continue editing as default
                $_REQUEST['stay'] = "2"; 
                break;
            
              default:
                return;
                break;
            }


            The only difference from the original is the $_REQUEST[’stay’] = "2" line. My recommendation is to make a duplicate of the original and deactivate it, then edit the copy by pasting the code above in place of the existing code. Make sure onDocFormPrerender is selected in the events tab and save. Then if you want to go back to the original settings you can either deactivate the edited version and then activate the original one, or simply comment out the bit of code by adding two slashes before it like this // $_REQUEST[’stay’] = "2"

            Edit: the correct value is 2, 1 is the add another option.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 27330
              • 884 Posts
              I’ve tried ganeshXL hack and it worked good. after reading dev_cw post I figured I’ll try that too and that worked good too...but I wanted to have the button checked by default also on snippets/chunks & tv edits. naively I went to system events and checked also OnSnipFormPrerender, OnPluginFormPrerender, OnModFormPrerender, OnChunkFormPrerender
              I tried ganeshXL changes again and that didn’t keep the button checked by default either.

              So after reading the plugin code I saw that it only has case ’OnDocFormPrerender’: in it.
              pardon the n00b question, how do I repeat that case for the other events in the same plugin?
              or could that make a mess to have the plugin run on these parts of modx?
                • 7231
                • 4,205 Posts
                Pulled a few hairs on that one. After some research it turns out that the parameter is referenced by the $_GET rather that the $_REQUEST method on the other functions.

                Here is what you do, create a new plug-in and tick all of the events you want. THen simply copy this in to it:
                $_GET['stay'] = "2"; 
                $_REQUEST['stay'] = "2";


                Thats it, now it should default to continue editing for all the actions.

                Observation: to me it seems that the switch statement that checks for the OnDocFormPrerender event in the original is redundant since by selecting an event from the event list it already filters out the other events.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don't know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Odd, indeed. $_REQUEST includes $_GET, $_POST and $_COOKIE, it should always pick them all up.

                  An associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.

                  This is a ’superglobal’, or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don’t need to do a global $_REQUEST; to access it within functions or methods.
                    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
                    • 10487 MODX Staff
                    • 1,535 Posts
                    So after reading the plugin code I saw that it only has case ’OnDocFormPrerender’: in it. pardon the n00b question, how do I repeat that case for the other events in the same plugin?
                    Stack up the case statements for each plugin event you want it to run on:
                    switch($e->name) {
                      case 'OnDocFormPrerender':
                      case 'OnSnipFormPrerender':
                      case 'OnPluginFormPrerender':
                      case 'OnModFormPrerender':
                      case 'OnChunkFormPrerender':
                      // ... rest of code ...
                    

                    Then, make sure you check the corresponding events in the ’Plugin Events’ tab when editing the plugin in the Manager and away you go smiley
                      Garry Nutting
                      Senior Developer
                      MODX, LLC

                      Email: [email protected]
                      Twitter: @garryn
                      Web: modx.com
                      • 7231
                      • 4,205 Posts
                      Stack up the case statements for each plugin event you want it to run on:
                      Just curious, is this not redundant since selecting the events check boxes in the plugin panel will make the plug-in only active with the selected events?
                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don't know what it is.
                        Do you, Mr. Jones? - [bob dylan]