phpBB2Refugees.com Logo
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
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


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

This MOD has been validated and released at phpbb.com. 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 phpbb.com. 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.



local_links.1.0.0.zip
 Description:
MOD Install File (zipped)

Download
 Filename:  local_links.1.0.0.zip
 Filesize:  2.36 KB
 Downloaded:  782 Time(s)


_________________
phpBBDoctor Blog
Back to top
Ornette
Board Member



Joined: 16 Mar 2009

Posts: 37



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

Doh!

I had seen the link here: http://www.phpbbdoctor.com/post-182.html
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:

Code:
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:

http://www.thisdomain.com/folder/folder/...the_browser.htm
instead of:
http://www.thisdomain.com/folder/folder/folder/folder/folder/folder/folder/long_filename_goes_here_to_break_the_browser.htm

or even to do like what phpBB3 does with local forum links:
viewtopic.php?p=2805
instead of
http://www.phpbb2refugees.com/viewtopic.php?p=2805
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.0114 seconds using 17 queries. (SQL 0.0023 Parse 0.0023 Other 0.0068)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo