News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to auto insert hyperlink or www. Prefix to DomainNames in SMF 2.0 RC5 posts?

Started by prs, April 10, 2011, 12:35:41 PM

Previous topic - Next topic

prs

How to automatically insert hyper link or www. Prefix to Domain Names in SMF 2.0 RC5 posts?

If someone types example.com [nofollow] or .net or .org or ......etc, after posting[ and in preview ] , the link must appear. if someone clicks that link, it must bring him/her to that site. How?

If member does not like links in their post, member can disable in his/her post. How?

Arantor

There's actually a very good reason *not* to include www. automatically: there are plenty of sites out there that do not use www. at the start of their address and adding www. will make it do something other than expected, if it even works at all. For example, on my site, dev.domain.com does something different to www.domain.com and additionally, www.dev.domain.com would do something else again...

prs

Quote from: Arantor on April 10, 2011, 01:14:45 PM
There's actually a very good reason *not* to include www. automatically: there are plenty of sites out there that do not use www. at the start of their address and adding www. will make it do something other than expected, if it even works at all. For example, on my site, dev.domain.com [nofollow] does something different to www.domain.com [nofollow] and additionally, www.dev.domain.com [nofollow] would do something else again...

Ok, avoid www. prefix to domain names but How to automatically insert hyper link to Domain Names in SMF 2.0 RC5 posts?

Arantor

If the link begins with http:// or www. it will automatically be linked. There's no other way to reliably do it without telling SMF of the hundreds and hundreds of valid domain extensions (it's not just .net, .com, .org, there's also .edu, .gov, .mil, .info, .biz, .me, .ws, .museum and that's even before I get into all the country specific ones)

To be brutally honest, it's probably better not to automatically attempt to correct user laziness.

prs

Quote from: Arantor on April 10, 2011, 01:29:15 PM
If the link begins with http:// or www. it will automatically be linked. There's no other way to reliably do it without telling SMF of the hundreds and hundreds of valid domain extensions (it's not just .net, .com, .org, there's also .edu, .gov, .mil, .info, .biz, .me, .ws, .museum and that's even before I get into all the country specific ones)

To be brutally honest, it's probably better not to automatically attempt to correct user laziness.

Forget about all other extensions, just i need it for .com, .net, .org ?

Arantor

Can't your users be bothered to put http:// in front of the link, or even press the little link button?

prs

Quote from: Arantor on April 10, 2011, 01:42:21 PM
Can't your users be bothered to put http:// in front of the link, or even press the little link button?

It does not mean that users are lazy, it is useful to the visitors.  i need like this domain.com [nofollow]

Arantor


prs

Quote from: Arantor on April 10, 2011, 02:07:22 PM
Well, you've just done it there... how is that any different?

I need to auto add this to all forum posts.

KTT Robot

Quote from: prs on April 10, 2011, 02:17:26 PM
Quote from: Arantor on April 10, 2011, 02:07:22 PM
Well, you've just done it there... how is that any different?

I need to auto add this to all forum posts.

You'd need to edit Sources/Post.php and use regular expressions to find them and turn them into links. Someone mentioned you having to check for every TLD, but that wouldn't be necessary considering the vast majority of links would be from the most popular TLDs, which wouldn't be very difficult to check for.

Advertisement: