We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16702 ☆ A M B ☆
    • 536 Posts
    luv this module! nice work...
      palma non sine pulvere
      • 22797
      • 134 Posts
      This seems to be a great contribution to MODx. I had to modify your code to get it to work on my site though. I have the short php tags turned off, so all of your references to <? had to be changed to <?php and all of your references to <?= had to be changed to <?php echo

      I have the short php tags turned off to facilitate easier references to xml documents which use the <? syntax.

      EDIT: This is probably the reason why the PHP source code is appearing on the other person’s installation as mentioned previously in the forum. The same thing happened to me, which is why I had to change the code as described above.
        • 20413
        • 2,877 Posts
        Now my modx is a bmw! cool
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 22797
          • 134 Posts
          Feature request:

          (EDIT: It looks like I wasn’t the first to ask for this feature. I missed Ryan’s suggestions when I skimmed through the discussion board the first time. Sorry for the redundancy.)

          It would be great if you could add the ability to choose which replacements to perform. Right now, it seems to be all or nothing. You either replace all instances across the entire site, or none. It would be more useful we could see a list of all the potential replacements, with a checkbox next to each one, giving us the option to perform that particular replacement or not. The checkboxes could be all checked by default, allowing us to unselect the ones we don’t want to perform. As it is right now, I can’t realistically use the replace feature on large web sites because I can’t see exactly what’s going to happen. I see which pages have the string, but I don’t know if all instances of the string on that page should be replaced or not. Maybe there’s a config option that I missed, but I don’t see a way to do it with the current version.
            • 22797
            • 134 Posts
            Another feature request:

            It would be very helpful if the module invoked the relevant system events when saving each element. When altering a document or its TVs, invoke the onBeforeDocFormSave event and the onDocFormSave event (both of them, at the appropriate time in the script). When altering a chunk, invoke the OnBeforeChunkFormSave and the OnChunkFormSave events, and so on. http://wiki.modxcms.com/index.php/System_Events

            If these aren’t invoked, other snippets, plugins, or modules that depend on these events will be bypassed. This will essentially break the functionality of those other pieces of code. I’m working on a plugin that requires the faithful execution of these events to ensure data accuracy, so this is of particular concern to me.

            For examples of how this is done in the MODx manager, refer to the scripts in manager/processors. For example, when updating a document, here’s how MODx invokes the two events:

            // invoke OnBeforeDocFormSave event
            		$modx->invokeEvent("OnBeforeDocFormSave", array (
            			"mode" => "upd",
            			"id" => $id
            		));

            (The mode is "upd" for "update," as opposed to "new.") And:
            // invoke OnDocFormSave event
            		$modx->invokeEvent("OnDocFormSave", array (
            			"mode" => "upd",
            			"id" => $id
            		));


            Thanks!
              • 3785
              • 143 Posts
              Hi Paul,

              thanks for you feedback! There are indeed plans to extend the Doc Finder results with checkboxes, where you can choose several actions for the selected entries. However, at the moment I don’t have the time to implement it. But you can solve the problem you are describing pretty well with the currently available possibilities of the Doc Finder Module:

              The replace function replaces the very same instances that are shown to you when you just search for a string. And this results can be narrowed down with options like:

              • Search places (Documents, Templates, TVs, Chunks, Snippets, Plugins, Modules)
              • Case sensitivity
              • Document parents
              • Document Search in (ID, Pagetitle, Longtitle, Description, Alias, Introtext, Menutitle, Content, TVs)
              • Date options (created and edited dates)

              In this way you can first search for what you like to replace, then narrow you results down using the above options, after that check the results to see what will be replaced later on and if you are happy with this "preview" enter a replace string and hit the replace button.

              I see which pages have the string, but I don’t know if all instances of the string on that page should be replaced or not.
              Yes, it would be nice to see all instances inside a document that will be replaced like TextMate does it for example. However that would mean I would have to load all the content of many documents into the browser and somehow display it optionally beneath the result line we have now. For big sites the loading content would become quite big, but maybe some AJAX would do the trick.

              But I will keep this in mind for later versions!
                Medianotions – Studio für Webdesign
                http://www.medianotions.de
                • 3785
                • 143 Posts
                It would be very helpful if the module invoked the relevant system events when saving each element. When altering a document or its TVs, invoke the onBeforeDocFormSave event and the onDocFormSave event (both of them, at the appropriate time in the script). When altering a chunk, invoke the OnBeforeChunkFormSave and the OnChunkFormSave events, and so on.

                Thanks for that tipp Paul, I indeed never thought about the events! I will update a Version 1.5.1 containing the events as you posted them for the replace function today.
                  Medianotions – Studio für Webdesign
                  http://www.medianotions.de
                  • 22797
                  • 134 Posts
                  I took a look at your updated code. I see that you added the call to the OnBeforeDocFormSave and OnDocFormSave events. The way the code is set up now, though, you’re assuming that the only events that need to be invoked are those two. But if the user is replacing content in a snippet or chunk or TV or something else, your script will not work as intended. You will need to use the other events too:

                  • OnBeforeChunkFormSave,
                  • OnChunkFormSave,
                  • OnBeforeSnipFormSave,
                  • OnSnipFormSave,
                  • OnBeforeTVFormSave,
                  • OnTVFormSave,
                  • OnBeforeTempFormSave,
                  • OnTempFormSave,
                  • OnBeforePluginFormSave,
                  • OnPluginFormSave,
                  • OnBeforeModFormSave, and
                  • OnModFormSave

                  You’ll need to set up a condition -- a php switch, for example -- to take into account which type of content is being saved.

                  Not all of the calls to the events are exactly the same. You will need to look at the files in the manager/processors folder to see how each one is called.

                  Also, on a separate topic, it would be helpful if you could replace all instances of <? (short php tag) with <?php (the long php tag), and all instances of <?= with <?php echo . Those of us who have the short tags turned off can’t use your module unless we search and replace all of those instances.
                    • 3232
                    • 380 Posts
                    So I just read through this thread and didn’t see my problem. I just installed DocFinder using the instruction and now when I click on the Doc Finder button under the modules tab and get a blank page. Nothing renders, I tried re uploading all of the files and it doesn’t help.

                    Anyone have any ideas?
                      • 22797
                      • 134 Posts
                      Quote from: betoranaldi at Dec 05, 2008, 11:20 AM

                      when I click on the Doc Finder button under the modules tab and get a blank page. Nothing renders

                      You might check to see if the php short_open_tag option is turned off in the php.ini file. (You can create a file with nothing but this in the content to test it: <?php phpinfo(); ?>) If short tags are off, the module won’t work until you either turn short tags on (not recommended) or search and replace all the short tags with long tags (see the last paragraph of my previous post above).

                      I don’t know if that’s the problem or not, but it’s something worth checking.