Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

BBCode url autolinker?

ADMADM
edited November 2005 in Vanilla 1.0 Help
How would I go about making the BBCode plugin autolink urls?

Comments

  • Take a look at how the text formatter does it.
  • ADMADM
    edited November 2005
    Thanks for that, didn't think of that heh.

    For those that want to do it:

    Add this to your BBCode.php extension (at the bottom.. anywhere really, just not in another function):

    function AutoLink($String) {
    // autolink example from www.zend.com (Code Gallery ) by http://www.zend.com/search_code_author.php?author=goten
    return preg_replace("/(?<!<a href=\")(?<!\")(?<!\">)((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+)/","\\1",$String);
    }


    Then search for this:

    }
    return $String;

    and above that add:

    $String = $this->AutoLink($String);

    That's it.
  • Just to make sure that the comment //... all goes on one line when you copy and paste. There's no reason it shouldnt but if it doesnt then you need to move it onto one line or it'l break.
  • I'm having some issues with this. It seems to only autolink links when in text-only mode. when I switch text-only off, the addresses are no longer linked. (also, text-only mode removes the formatting bbcode too, like [b] and [i]. Is that normal? I'm new to setting up Vanilla)
  • You'll need to get the BBCode extension then add the changes I posted above to that extension file. That'll get everything working :)
This discussion has been closed.