Author |
Message |
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Mon Jun 25, 2012 11:00 am Post subject: Long URL's |
|
|
Is my memory fading or was there a mod to truncate long url's?
Despite showing my users over and over again how to use the url bbcode many still post url's that occupy a couple of lines of text. They don't affect the board layout as I must have, in the dim and distant past, installed a mod to stop that but nevertheless still annoying to get the long ones.
If the answer is yes does anyone have the mod. I have looked on phpbbhacks but no joy.
Thanks
Jim |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Mon Jun 25, 2012 12:38 pm Post subject: Re: Long URL's |
|
|
I don't see one either, but it should be easy enough to make using substr_replace(). I don't have time now, but I could probably look into it tonight if you need help with it. |
|
Back to top |
|
|
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Mon Jun 25, 2012 12:47 pm Post subject: Re: Long URL's |
|
|
Salvatos wrote: | I don't see one either, but it should be easy enough to make using substr_replace(). I don't have time now, but I could probably look into it tonight if you need help with it. |
Thanks for the offer but the more I think about it the more I am sure that it exists. "Tiny url" keeps popping into my head.
The problem is that I have reached the age were only bits stick and not the full story.
Jim |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Mon Jun 25, 2012 6:15 pm Post subject: Re: Long URL's |
|
|
Well, there's a website called TinyURL, but you have to actually go there and create a custom link every time you need a new one.
Quote: | The problem is that I have reached the age were only bits stick and not the full story. |
I can relate, I got there before I was twenty... |
|
Back to top |
|
|
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Tue Jun 26, 2012 2:58 am Post subject: Re: Long URL's |
|
|
Salvatos wrote: | Well, there's a website called TinyURL, but you have to actually go there and create a custom link every time you need a new one. |
Illustrates what I mean - I remember that site and clearly not what I need for my users.
The search continues.
Jim |
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Tue Jun 26, 2012 3:06 am Post subject: Re: Long URL's |
|
|
Hi Jim:
I guess this is the one you have in mind, I use it and it works as expected.
Code: | ##############################################################
## MOD Title: Chunk Long URLs
## MOD Author: Joe Belmaati < belmaati@gmail.com > (Joe Belmaati) N/A
## MOD Description: Tired of long urls that strecth your phpBB layout?
## This mod will chunk long urls.
## MOD Version: 1.0.0
##
## Installation Level: Easy
## Installation Time: 1 Minute
## Files To Edit: includes/bbcode.php
##
## Included Files: N/A
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes: The long links will look like this:
## http://yoursite.com/fhjfgjf.....dfhdj.php. Short urls will
## not be touched
##############################################################
## MOD History:
##
## 2006-08-16 - 1.0.0
## - submitted to MODs datatbase at phpBB
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ 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);
}
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM |
_________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Tue Jun 26, 2012 3:11 am Post subject: Re: Long URL's |
|
|
Hi and thanks,
I will give it a go. I am tired of asking them to use bbcode to reduce link to text such as "Click here"
Jim |
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Tue Jun 26, 2012 3:14 am Post subject: Re: Long URL's |
|
|
There's this mod that ads a popup to the url bbcode button asking for anchor text and url.
But that seems quite useless as people don´t click on that button and tend to simply paste urls.
So yes, this mod seems to be the best you can do. _________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Tue Jun 26, 2012 5:00 am Post subject: Re: Long URL's |
|
|
Installed, tested and works great. Just what I was looking for.
Many thanks
Jim |
|
Back to top |
|
|
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Tue Jun 26, 2012 5:21 am Post subject: Re: Long URL's |
|
|
You're welcome Jim, glad I could help you out. _________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
lumpy burgertushie Board Member
Joined: 18 Nov 2008
Posts: 266
|
Posted: Thu Jun 28, 2012 12:48 pm Post subject: Re: Long URL's |
|
|
Jim_UK wrote: | Hi and thanks,
I will give it a go. I am tired of asking them to use bbcode to reduce link to text such as "Click here"
Jim |
just curious, why do you care if they use the bbcode or just paste the link?
robert |
|
Back to top |
|
|
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Thu Jun 28, 2012 1:53 pm Post subject: Re: Long URL's |
|
|
Just the appearance Robert although one or two users have claimed that they break the board layout. I have a mod installed that forces a text wrap so not sure why they experience it.
Jim |
|
Back to top |
|
|
|