Links Opening New Windows For PHBB
Compared to phpBB3, links in phpBB2 had a slightly different behavior: When you clicked them, they opened a new window with the requested page. This was changed in phpBB3 for a couple of reasons, but one of the most important ones was the goal to achieve XHTML 1.0 Strict-validation for the whole board.
If you still want to get the same behaviour on your new phpBB3 board, there are a couple of small modifications have you to make, which this guide should hopefully explain in enough detail.
Modifying auto-detected links
First of all, make auto-detected links (those that you didn’t wrap with the url-BBCode) open new windows when getting clicked. Therefor open the includes/functions_content.php and look for following line (which should be around line 592):
$html = “$whitespace<!– $tag –><a$class href=\”$url\”>$text</a><!– $tag –>$append”;
And replace it with following line:
if ($type == MAGIC_URL_EMAIL)
{
$html = “$whitespace<!– $tag –><a$class href=\”$url\”>$text</a><!– $tag –>$append”;
}
else
{
$html = “$whitespace<!– $tag –><a$class href=\”$url\” onclick=\”window.open(this.href);return false;\”>$text</a><!– $tag –>$append”;
}
BBCode URLs
Next open the bbcode.html of your style (if you’re using prosilver, this would be the styles/prosilver/template/bbcode.html file) and look for following line:
<!– BEGIN url –><a href=”{URL}”>{DESCRIPTION}</a><!– END url –>
Now replace it with this line:
<!– BEGIN url –><a href=”{URL}” onclick=”window.open(this.href);return false;”>{DESCRIPTION}</a><!– END url –>
Help phpBB read the output again
Last but not least, you should also do the following change which will allow the created HTML output to be parsed again by phpBB: Open the includes/functions.php and replace this segment which you should find around line 2740…
case ‘bbcode_htm’:
return array(
‘#<!\-\- e \-\-><a href=”mailto:(.*?)”>.*?</a><!\-\- e \-\->#’,
‘#<!\-\- l \-\-><a (?:class=”[\w-]+” )?href=”(.*?)(?:(&|\?)sid=[0-9a-f]{32})?”>.*?</a><!\-\- l \-\->#’,
‘#<!\-\- ([mw]) \-\-><a (?:class=”[\w-]+” )?href=”(.*?)”>.*?</a><!\-\- \1 \-\->#’,
‘#<!\-\- s(.*?) \-\-><img src=”\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#’,
‘#<!\-\- .*? \-\->#s’,
‘#<.*?>#s’,
);
… with this one:
case ‘bbcode_htm’:
return array(
‘#<!\-\- e \-\-><a href=”mailto:(.*?)”>.*?</a><!\-\- e \-\->#’,
‘#<!\-\- l \-\-><a (?:class=”[\w-]+” )?href=”(.*?)(?:(&|\?)sid=[0-9a-f]{32})?” onclick=”window\.open\(this\.href\);return false;”>.*?</a><!\-\- l \-\->#’,
‘#<!\-\- ([mw]) \-\-><a (?:class=”[\w-]+” )?href=”(.*?)” onclick=”window\.open\(this\.href\);return false;”>.*?</a><!\-\- \1 \-\->#’,
‘#<!\-\- s(.*?) \-\-><img src=”\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#’,
‘#<!\-\- .*? \-\->#s’,
‘#<.*?>#s’,
);
And since you’ve updated also a template file, don’t forget to also purge your board’s cache through the respective button on the frontpage of your board’s admin panel.
Note: The change will not affect existing posts, you must edit them so they can be reprocessed.