We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    We are over thinking this. If you want to limit this to Jot comments we can somply use a PHX custom modifier and apply it to the comments field. I took the code above and placed it in a phx modifier (a snippet with phx: name prefix):
    <?php
    /*
     * parse links
     */
    $t = $output;
    // match protocol://address/path/
    $t = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "<a href=\"\\0\">\\0</a>", $t);
    // match www.something
    $t = ereg_replace("(^| |\n)(www([.]?[a-zA-Z0-9_/-])*)", "\\1<a href=\"http://\\2\">\\2</a>", $t);
    return $t;
    
    ?>
    Then in the Jot comment tpl I added the modifier to the chunk.comment.inc.html file at around line 38

    <div class="jot-message">[+comment.content:wordwrap:esc:nl2br:parseLinks+]</div>
    THis worked for parsing any http:// items, the www items are not working. My guess is that there is something wrong with the regex.

    Anyway, this is a start. grin

    Edit: this code has been fixed as described bellow.
      [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&#39;t know what it is.
      Do you, Mr. Jones? - [bob dylan]
      • 29703
      • 217 Posts
      Quote from: dev_cw at Aug 27, 2008, 10:58 AM

      We are over thinking this. If you want to limit this to Jot comments we can somply use a PHX custom modifier and apply it to the comments field. I took the code above and placed it in a phx modifier (a snippet with phx: name prefix):
      <?php
      /*
       * phx:parseLinks
       */
      $t = $output;
      // match protocol://address/path/
      $t = ereg_replace("[a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*", "<a href=\"\\0\">\\0</a>", $t);
      // match www.something
      $t = ereg_replace("(^| )(www([.]?[a-zA-Z0-9_/-])*)", "\\1<a href=\"http://\\2\">\\2</a>", $t);
      return $t;
      
      ?>
      Then in the Jot comment tpl I added the modifier to the chunk.comment.inc.html file at around line 38

      <div class="jot-message">[+comment.content:wordwrap:esc:nl2br:parseLinks+]</div>
      THis worked for parsing any http:// items, the www items are not working. My guess is that there is something wrong with the regex.

      Anyway, this is a start. grin


      Absolutely Genius! This is working for both www. and http://www. for me!

      Now if anyone knows anything about AjaxSearch, that’s the only I’m left struggling with. View relevant post.

      Thanks so much, I really appreciate it.
        • 7231
        • 4,205 Posts
        I found a bug, it only parses the first instance. That is why I thought it was not working for www. Not sure how to make it work for multiple instances. Maybe we should post this in the in development forum and see if we can get some help.
          [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&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 29703
          • 217 Posts
          Quote from: dev_cw at Aug 27, 2008, 12:11 PM

          I found a bug, it only parses the first instance. That is why I thought it was not working for www. Not sure how to make it work for multiple instances. Maybe we should post this in the in development forum and see if we can get some help.

          I don’t understand. . . I’ve got it working on multiple instances fine. See the attached screenshot.
            • 7231
            • 4,205 Posts
            You have single instances multiple times, I mean multiple instances in the same comment.

            In any case I fixed it (well found the fix online). The fixed code is in this post.
              [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&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 29703
              • 217 Posts
              Quote from: dev_cw at Aug 27, 2008, 12:23 PM

              You have single instances multiple times, I mean multiple instances in the same comment.

              In any case I fixed it (well found the fix online). The fixed code is in this post.

              Oh I see, thanks for the fix - works like a charm.

              I think this should really be integrated into Jot, most blog comments these days have this function. Thanks again - brilliant.
                • 22303 MODX Staff
                • 10,725 Posts
                You might want to think about adding
                rel="noindex, nofollow"

                to those automatically generated URLs.