UseBB Community

The official board for UseBB help and discussion

UseBB Community » Resources & Customization » Is there a way to make the URl BBcode less confusing?

Is there a way to make the URl BBcode less confusing?

Moderators: Gaia.

Page: 1

Author Post
Member
Registered: Jun 2007
Posts: 122
Location: Gatineau, QC, Canada
Hi,

I noticed on my previous UseBB forum that people would easily get confused using the URL BBcode wich shows:
[url=http://www.example.com][/url]

Most users would insert their URL between the .com][/url (where the cursor goes and when clicked on, would of course get an error message because it would link to "example.com".

Is there a workaround or fix for this? Removing the =http://www.example.com would work as in most BBS software but then there's the possibility that the user might input a long URL that would break up the page. :roll:

There is a phpBB code Mod that breaks up long URL's without affecting navigation to it. For example, it would transform:

http://www.somesite.com/community/articles/johndoe/sept07/article65518B123
To:
http://www.somesite.com/commun.....e65518B123

Here's the code for this, I wonder if it could be implemented in useBB
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
// matches an email@domain type address at the start of a line, or after a space.
#
#-----[ BEFORE, ADD ]------------------------------------------
#
chunk_url($ret);

#
#-----[ FIND ]------------------------------------------
#
/**
* Nathan Codding - Feb 6, 2001
#
#-----[ BEFORE, ADD ]------------------------------------------
#
/**
* Chunk long urls to avoid page stretching. This function splits a
* long url into chunks, then glues it back together with a couple
* of dots. This gaggle of code could be boiled down to fewer lines,
* but it would make it hard to read.
*/
function chunk_url(&$ret)
{
/**
* Split the string into an array. Then loop through
* the array and process each link separately.
*/
$links = explode('<a', $ret);
$countlinks = count($links);
for ($i = 0; $i < $countlinks; $i++)
{
$link = $links[$i];

/**
* If the array element is a hyperlink then put the missing
* '<a' back in, as we will not be imploding...
*/
$link = (preg_match('#(.*)(href=")#is', $link)) ? '<a' . $link : $link;

$begin = strpos($link, '>') + 1;
$end = strpos($link, '<', $begin);
$length = $end - $begin;
$urlname = substr($link, $begin, $length);

/**
* We chunk urls that are longer than 50 characters. Just change
* '50' to a value that suits your taste. We are not chunking the link
* text unless if begins with 'http://', 'ftp://', or 'www.'
*/
$shorturlname = (strlen($urlname) > 50 && preg_match('#^(http://|ftp://|www\.)#is', $urlname)) ? substr_replace($urlname, '.....', 30, -10) : $urlname;
$ret = str_replace('>' . $urlname . '<', '>' . $shorturlname . '<', $ret);
}
}


Cheers,
Gene
Member
Registered: Jun 2007
Posts: 122
Location: Gatineau, QC, Canada
Hmm, what happened? I was notified that there was a post and when I clicked on the link, it said that post #XXXX didn't exist.

Gene
Member
Registered: May 2005
Posts: 298
Location: 98671
I had posted, deleted post before time ran out, had posted in error.

1st part of what you ask is editing sources/functions.php at or around line 1885.

You'll see...
array('[url=http://www.example.com]', '[/url]', $lang['URL'], ''),

Change to... I think its what your asking.
array('[url]', '[/url]', $lang['URL'], ''),

As for 2nd part of what you wanted no idea, sorry.
Moderator
Registered: Oct 2005
Posts: 462
Location: canada

[url]http://domain.com[/url]


That is already implemented within the code. I think be means he wants long URL's truncated.
Member
Registered: Jun 2007
Posts: 122
Location: Gatineau, QC, Canada
Gaia wrote

[url]http://domain.com[/url]


That is already implemented within the code. I think be means he wants long URL's truncated.


I agree with you Gaia and would like to keep it that way but as I mentioned in first post:

Quote
Most users would insert their URL between the .com][/url (where the cursor goes and when clicked on, would of course get an error message because it would link to "example.com".


I've seen other forum software that eliminates this confusion by having 2 small panels that drop down when inserting a link, the first one is to input the URL and the 2nd one would be for the URL description and once those 2 steps are done, the proper code is inserted in the post.

There's also the phpBB Mod that also takes care of this problem.

The average user really gets confused over this BBcode issue...

Damned if you do and damned if you don't...

Cheers,
Gene
Member
Registered: Jun 2007
Posts: 122
Location: Gatineau, QC, Canada
William wrote
I had posted, deleted post before time ran out, had posted in error.

1st part of what you ask is editing sources/functions.php at or around line 1885.

You'll see...
array('[url=http://www.example.com]', '[/url]', $lang['URL'], ''),

Change to... I think its what your asking.
array('[url]', '[/url]', $lang['URL'], ''),

As for 2nd part of what you wanted no idea, sorry.


Thanks William, I'll look into it but if I use it, I'll have to keep a close eye on my forum for long URL's.

Cheers,
Gene
Member
Registered: May 2005
Posts: 298
Location: 98671
I tried to rewrite the phpBB code Mod, but ended up getting myself lost, I just don't know enough PHP to tackle it.
Member
Registered: Jun 2007
Posts: 122
Location: Gatineau, QC, Canada
William wrote
I tried to rewrite the phpBB code Mod, but ended up getting myself lost, I just don't know enough PHP to tackle it.


Did the same thing but got lost also... :oops:

As I said, most users get confused when using that bbcode and insert the link where the cursor goes, between .com] and [/url and end-up with an error.

Cheers,
Gene

Page: 1

UseBB Community » Resources & Customization » Is there a way to make the URl BBcode less confusing?

UseBB Community is powered by UseBB 1 Forum Software