We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    print_r the value of $rt -- it may be an array...in which case we need to loop through all the plugin results and make sure there aren’t any messages instead of true values.
      • 3749
      • 24,544 Posts
      Quote from: OpenGeek at Aug 11, 2008, 05:11 PM

      print_r the value of $rt -- it may be an array...in which case we need to loop through all the plugin results and make sure there aren’t any messages instead of true values.

      I’m sure that’s it but now I have more serious problems.

      My SVN update failed and because the ext2 directory already existed.

      At Shaun’s suggestion, I deleted that directory and the upgrade succeeded.

      Unfortunately, I now have a blank manager page and a bunch of the MODx directories appear to no long be under version control. I tried a rebuild but to no effect.

        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
        • 3749
        • 24,544 Posts
        Ok. Did an upgrade install and can log in to the manager but trying to do anything gets a message from my browser saying:

        "Can’t load page" http://modx097/manager/index.php?id=0"

          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
          • 3749
          • 24,544 Posts
          The error only occurs in IE7. The manager works fine in FF.

          I have the plugin working as it should. $rt *is* an array and the value set in the plugin is in $rt[0]. I’m not sure if that’s reliable if other plugins are listening for the same event (which in this case they might be).

          The $_SESSION variable set in vericode.php is available in the plugin. The $captcha_code variable isn’t -- I haven’t figured out why -- but $_POST[’captcha_code’] is available so I used that.

          Now we need a way to inject the captcha field into the form and have it set the $_POST[’captcha_code’] value.
            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
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: BobRay at Aug 12, 2008, 03:10 AM

            I have the plugin working as it should. $rt *is* an array and the value set in the plugin is in $rt[0]. I’m not sure if that’s reliable if other plugins are listening for the same event (which in this case they might be).
            Yes, consider if you have three different plugins extending the login page; each one returns it’s own result. So you need to make sure each one of them returns true; in other words, if any one of the results in the array are !== true, it’s an error, and potentially a returned message.

            Quote from: BobRay at Aug 12, 2008, 03:10 AM

            The $_SESSION variable set in vericode.php is available in the plugin. The $captcha_code variable isn’t -- I haven’t figured out why -- but $_POST[’captcha_code’] is available so I used that.
            This is because we aren’t explicitly providing $captcha_code to the event; this was my comment about using the $_POST variables directly.

            Quote from: BobRay at Aug 12, 2008, 03:10 AM

            Now we need a way to inject the captcha field into the form and have it set the $_POST[’captcha_code’] value.
            All you need to do is add some Smarty variable assignments that can be rendered by the template. e.g.
            <?php
            $modx->smarty->assign('captcha_image', $captcha_image);
            $modx->smarty->assign('captcha_input', $captcha_input);
            ?>

            You could even use a standard name for all the content rendered by these plugins and simply append content onto one of those variables, i.e. OnBeforeManagerLoginOutput or something... just ideas...
              • 3749
              • 24,544 Posts
              Quote from: OpenGeek at Aug 12, 2008, 11:30 AM

              All you need to do is add some Smarty variable assignments that can be rendered by the template. e.g.
              <?php
              $modx->smarty->assign('captcha_image', $captcha_image);
              $modx->smarty->assign('captcha_input', $captcha_input);
              ?>

              You could even use a standard name for all the content rendered by these plugins and simply append content onto one of those variables, i.e. OnBeforeManagerLoginOutput or something... just ideas...

              Right. That was the gist of my suggestion earlier:

              We could put some of these between the existing fields in login.tpl:
              {$onManagerLoginFormExtraField1}
              {$onManagerLoginFormExtraField2}


              Using $modx->smarty->assign(’captcha_image’, $captcha_image); kind of works against the point of showing how easy it is to extend the manager. There aren’t that many fields in the form so adding a few extras and removing the current captcha fields might make sense. A user who wanted to add a hidden field, say, might want to control its placement.

              I have login.php handling the full array now.

              Can I assume that the return from $modx->invokeEvent() will always be an array or should I handle a single returned string?





                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
                • 3749
                • 24,544 Posts
                I have the login.php processor plugin working as it should (although I still need to know whether I can count on the event output being an array -- I’m guessing yes since it comes back as an array when set to a single string or to a boolean value).

                Now for the controller login.php and the smarty template.

                The $OnManagerLoginFormPrerender variable in the smarty template is in the wrong place for the captcha prompt and image. It doesn’t seem wise to move it.

                These guys are in the right place --
                {$captcha_image}
                {$captcha_input}

                But if we pull captcha out of the core, they’ll be gone (and there’s no place for the captcha prompt -- which needs to change when using the MathString). We could put a new, more generic, variable there like {$OnLoginSecurityCheck} or something similar, but it should probably have a system event of its own. I could use the OnManagerLoginFormPrerender event to populate it but that seems wrong.

                All this has me wondering about the MODx event model which I admit I don’t understand very well. What happens when a user sets up another system event to listen to OnManagerLoginFormPrerender and sends some additional output back? Does it just get appended or prepended to the array that comes back depending on the priority of the event? [[Edit: Yes -- tested it myself].

                Also, are there plans to let users create new system events in the Manager?
                  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
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: BobRay at Aug 14, 2008, 12:41 AM

                  I have the login.php processor plugin working as it should (although I still need to know whether I can count on the event output being an array -- I’m guessing yes since it comes back as an array when set to a single string or to a boolean value).
                  It can be an array or a single result. We’ll have to test for both possibilities.

                  Quote from: BobRay at Aug 14, 2008, 12:41 AM

                  Now for the controller login.php and the smarty template.

                  The $OnManagerLoginFormPrerender variable in the smarty template is in the wrong place for the captcha prompt and image. It doesn’t seem wise to move it.

                  These guys are in the right place --
                  {$captcha_image}
                  {$captcha_input}

                  But if we pull captcha out of the core, they’ll be gone (and there’s no place for the captcha prompt -- which needs to change when using the MathString). We could put a new, more generic, variable there like {$OnLoginSecurityCheck} or something similar, but it should probably have a system event of its own. I could use the OnManagerLoginFormPrerender event to populate it but that seems wrong.

                  All this has me wondering about the MODx event model which I admit I don’t understand very well. What happens when a user sets up another system event to listen to OnManagerLoginFormPrerender and sends some additional output back? Does it just get appended or prepended to the array that comes back depending on the priority of the event? [[Edit: Yes -- tested it myself].

                  Also, are there plans to let users create new system events in the Manager?
                  I think OnManagerLoginFormPrerender is the proper event and I don’t see any reason it can’t be moved to the proper location in the tpl. Also, I personally think the additional output should be injected by the plugin without overwriting any content that might be injected from other plugins registered to the event. IOW, each plugin should append any output to the same variable or we make the variable an array and do a loop through it, displaying each resulting output between the password field and the rememberme checkbox (replacing the old captcha variables).
                    • 3749
                    • 24,544 Posts
                    Quote from: OpenGeek at Aug 14, 2008, 09:53 AM

                    Quote from: BobRay at Aug 14, 2008, 12:41 AM

                    I have the login.php processor plugin working as it should (although I still need to know whether I can count on the event output being an array -- I’m guessing yes since it comes back as an array when set to a single string or to a boolean value).
                    It can be an array or a single result. We’ll have to test for both possibilities.

                    Looking at the MODx class file, invokeEvent appears to return false if the event isn’t found. Otherwise, you get this:

                    $results= array ();
                    
                    ...
                    
                    return $results;


                    So wrapping the code in if (is_array($rt)) { } should cover it, no? Unfound events will be ignored and every real event will return an array. It works as it should now.
                      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