Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

[RELEASED] Local Links

Search this topic... | Search MOD Development... | Search Box
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Author Message
Board Member

Joined: 24 Jul 2008

Posts: 698
Location: Texas

PostPosted: Thu Dec 11, 2008 4:50 am 
Post subject: Local Links

This MOD has been validated and released at I am copying the text of the first few posts here. Note that this MOD will be moved into the MOD Releases forum once the MOD Catalog is complete. This MOD has been installed on this site.

MOD Name: Local Links
Author: drathbun
MOD Description: This MOD alters the way local links work. When someone posts a link from one topic to another topic within the same board it won't open in a new window.

MOD Version: 1.0.0

There are no screenshots or supplemental information for this MOD. A very simple description is this...

This MOD takes the configuration information for your site from the $board_config array. From there it compares any item processed by the make_clickable() function. If the item is "local" meaning that it is located on the same server and (optionally) within the same directory path as your board, then it removes the target="_blank" code from the URL that is created. That way when someone links from one post to another post within your board they stay in the same browser window instead of opening a new one. icon_cool.gif

The MOD as attached is what is released at However, there were some comments in the release topic there that implied some cases of local links were still opening in a new window. At some point I will investigate those and redo the release file, but for now this code as it is written is in use here on this site and other sites and working fine.
MOD Install File (zipped)

 Filesize:  2.36 KB
 Downloaded:  1193 Time(s)

phpBBDoctor Blog
Back to top
Board Member

Joined: 16 Mar 2009

Posts: 37

PostPosted: Mon Mar 16, 2009 7:59 pm 
Post subject: Re: Local Links


I had seen the link here:
I didn't know you had already turned it in to an EM script icon_rolleyes.gif

I done a couple of changes to it whilst in process of making an EM script. I gave it a couple of ACP controls, and I also fixed a couple of lines to improve parsing of local links:

switch($board_config['internal_links']) {
case "1": $script_path = '/' . strtolower(preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']))); break;
case "2": $script_path = ''; break;
default: return $text;

$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = (( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) : '');
$server_name = strtolower($board_config['server_name']);
$local_url = '<a href="' . $server_protocol . $server_name . $server_port. $script_path;

As you can see it ensures local links without a trailing '/' are correctly parsed.

A couple more improvements to this mod could be to have titles on the links, that state 'Local link' or 'External link', and even the full URL. Another idea to improve would be to implement a truncating algorithm (like Invision Power Board), to make links look more like:
instead of:

or even to do like what phpBB3 does with local forum links:
instead of
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0296 seconds using 17 queries. (SQL 0.0024 Parse 0.0025 Other 0.0246)
phpBB Customizations by the
Template Design by DeLFlo and Moments of Light Logo