Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 13

6apxatCrusoeconnectrgarygaryleafmonstersarowlwp422 +6 guests

BBCode url autolinker?

How would I go about making the BBCode plugin autolink urls?

Comments

  • Posts: 921
    Take a look at how the text formatter does it.
  • ADMADM
    Posts: 450
    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.
  • Posts: 5,574
    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)
  • ADMADM
    Posts: 450
    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.