We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33657
    • 128 Posts
    like the title says... OnWebPagePrerender doesn’t fire.

    i can make a simple echo("hello"); php script and set OnWebPagePrerender and it never fires....

    i go into a 2.0.8 installation and it works great. I look in the 2.1 release notes and I explicitly see that OnWebPagePrerender has been fixed where instances of it not firing... so it seems like for me at least, this is exactly the opposite... its gone from actually working on 2.0.8 to not working at all (at least on a upgrade) Kinda sucks cause without this feature its completetly unusable as a ugprade... any thing I can do? at this point i am restoring my web server from last nights backup so i don’t have this issue, but that means i am back at 2.0.8 What else can I do? wait for 2.1.1? Looking forward to any help, I know themodx team is great and I love MODX, so I know this will get worked out smiley I am just letting you know its not working for me. smiley

    Thanks!
      • 3749
      • 24,544 Posts
      Zurie, I’m not doubting you, but echo can be unreliable in plugins. Try this instead:

      Create a chunk called debug and put this code in the plugin:

      $chunk = $modx->getObject('modChunk', array('name'=>'debug'));
      /* Put any debugging information in the string, $s */
      $s = 'Plugin Fired";
      $chunk->setContent($s);
      $chunk->save();
      


      Then look at the debug chunk with Quick Update Chunk.

      If it’s really not firing, please report it here: http://bugs.modx.com/ so it will get the attention it deserves.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 33657
        • 128 Posts
        Bob, I couldn’t for the life of me get your concept to work... I don’t really understand what you want me to do???

        I made a plugin named "test" and pasted your code into the plugin. Then I went into the plugin and set OnWebPagePrerender to Checked.

        Then I made a chunk called "debug"

        then what? do i call debug in my content of my test page? like [[$debug]] or do i just leave it. either way, i get this"
        Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/mysite/public_html/testsite/core/cache/includes/elements/modplugin/1.include.cache.php on line 9


        I looked at your code and I think you mean ’ instead of a " so i fixed that and now it doesn’t seem to do anything?

        what should I be looking for?
        <?php
        $chunk = $modx->getObject('modChunk', array('name'=>'debug'));
        /* Put any debugging information in the string, $s */
        $s = 'Plugin Fired';
        $chunk->setContent($s);
        $chunk->save();



        ok, got it.. I put anytthing in my chunk - debug, then when I call debug its replaced with "Plugin Fired" which makes sense, looking at your code. So its working... now to test this theory in 2.0.8 to 2.1 upgrade
          • 33657
          • 128 Posts
          OnWebPagePrerender works fine. using Bob’s code proved it was a error on my part and not on the pre-render part, and he was right, echo was unreliable and not the right way to test it smiley

          Thanks for all your help! and for modx 2.1! awesome!
            • 3749
            • 24,544 Posts
            Thanks for reporting back. smiley

            Before anyone else chimes in, you can also use the $modx->log() to write debugging info to the error log, but I like my method because you don’t have to leave your work to see the debug info (and I can never remember the constants and syntax for the log() statement).
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting