We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    For the Captcha component, I need a url to captcha.php -- which stores the $_SESSION variable and returns the generated image.

    In my current organization, it resides in MODX_BASE_PATH. ’assets/captcha/core/processors/captcha.php’

    I expect to have the captcha namespace path set to MODX_BASE_PATH. ’assets/captcha/’

    In the existing code, where captcha is part of the core, the results look like this:

    $captcha_image= '<a href="'.$_SERVER['PHP_SELF'].'" class="loginCaptcha"><img src="'.$modx->config['connectors_url'].'security/captcha.php?rand='.rand().'" alt="'.$alt.'" /></a>';

    I’m thinking it should be

    $namespace = $modx->getObject('modNamespace','captcha');
    $namespacePath = $namespace->get('path');
    
    $captcha_image= '<a href="'.$_SERVER['PHP_SELF'].'" class="loginCaptcha"><img src="'.$modx->config['base_url'].$namespacePath.'core/processors/captcha.php?rand='.rand().'" alt="'.$alt.'" /></a>';

    but thought I’d better check.
      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
      I would be inclined to use MODX_ASSETS_PATH . ’captcha/’ for full path includes and MODX_ASSETS_URL . ’captcha/’ for an image URL. This will be a configurable path as well and if you want to put this in the traditional assets/ directory to make it available to all possible contexts, that would be the best approach IMHO. I don’t see any reason to involve the namespace object (I don’t think we even know why we added a path to it), but I’ll have to give this some consideration.
      <?php
      $captcha_image= '<a href="'.$_SERVER['PHP_SELF'].'" class="loginCaptcha"><img src="' . MODX_ASSETS_URL . 'captcha/core/processors/captcha.php?rand='.rand().'" alt="'.$alt.'" /></a>';
      ?>

      Also, why captcha/core/processors/captcha.php? Why not just captcha/captcha.php?
        • 3749
        • 24,544 Posts
        Quote from: OpenGeek at Aug 21, 2008, 11:35 PM

        I would be inclined to use MODX_ASSETS_PATH . ’captcha/’ for full path includes and MODX_ASSETS_URL . ’captcha/’ for an image URL. This will be a configurable path as well and if you want to put this in the traditional assets/ directory to make it available to all possible contexts, that would be the best approach IMHO. I don’t see any reason to involve the namespace object (I don’t think we even know why we added a path to it), but I’ll have to give this some consideration.
        <?php
        $captcha_image= '<a href="'.$_SERVER['PHP_SELF'].'" class="loginCaptcha"><img src="' . MODX_ASSETS_URL . 'captcha/core/processors/captcha.php?rand='.rand().'" alt="'.$alt.'" /></a>';
        ?>

        Looks good. I was afraid you’d tell me to scatter the files around in the various existing MODx directories. smiley I like being able to keep them all together in the assets/captcha dir.


        Also, why captcha/core/processors/captcha.php? Why not just captcha/captcha.php?

        I was trying to follow the advice in Shaun’s article on 3rd-party components, but since I have no context, you’re right -- I might as well shorten up the path. As I think about it, it’s not really a processor anyway.

          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