I was previously asking for a smiliar function, but no o开发者_开发问答ne of them are like the vBulletin 4 has.
I mean if I paste some URL's in the vBulletins text box it will replace them for example like this:
Input:
http://www.stackoverflow.com/questions/1925455/how-to-mimic-stackoverflow-auto-link-behavior
http://yahoo.com/
Output:
php - How to mimic StackOverflow Auto-Link Behavior - Stack Overflow
Yahoo!
And this is the best of all, because if the URL doesn't exist (or don't have tags) it'll just stay with the URL path!
Input:
http://fake.url
Output:
http://fake.url
Then message BBCODE looks following:
[url=http://www.stackoverflow.com/questions/1925455/how-to-mimic-stackoverflow-auto-link-behavior]php - How to mimic StackOverflow Auto-Link Behavior - Stack Overflow[/url]
[url=http://yahoo.com/]Yahoo![/url]
[url]http://fake.url[/url]
How do they do that? Is it possible to do with PHP/JS? If so, could you direct me how?
Kind Regards,
Lucas.
You have to:
- parse the input to extract the URLs(there should be many related topics on SO)
- request the URL's to get the contents of the
<title/>
- Build the BBCode regarding to the response
This can be done using PHP, JS-only will not be able, because it may not parse external documents.(But of course you can setup a proxy-script on serverside that requests the document and returns the title to javascript/AJAX)
精彩评论