Picnic Website Code Tutorials

phpBB Make links Open in New Window

4/25/2013 phpBB open links in new window

How to make phpBB(v3) forum open links in posts in a new window? The following is how. It's very simply once you have the steps. It's a good idea to comment out the old lines instead of deleting in case you want to revert to old.

Step 1: Navigate to includes/functions_content.php and open the file. Search for this line $html = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append"; around line 629. Add target=\"_blank\" to it so it looks exactly like the following. Being sure to escape the quotes. Save and close.

$html	= "$whitespace<!-- $tag --><a$class href=\"$url\" target=\"_blank\">$text</a><!-- $tag -->$append";
		

Step 2: Navigate to styles/prosilver/template/bbcode.html and open the file. Search for this line <!-- BEGIN url --><a href="{URL}" class="postlink">{DESCRIPTION}</a><!-- END url --> around line 36. Add target="_blank" to it so it looks exactly like the following. Being sure to NOT escape the quotes. Save and close.

<!-- BEGIN url --><a href="{URL}" class="postlink" target="_blank">{DESCRIPTION}</a><!-- END url -->
		

Step 3: This last bit enables phpBB to parse the code correctly when making edits to posts after the fact. Navigate to includes/functions.php and open the file. Search for this line of code case 'bbcode_htm': return array within it's larger block around line 3462. Replace the entire block of code with the following. Again adding target="_blank", in two spots, so it looks exactly like the following. Being sure to escape the quotes. Save and close.

case 'bbcode_htm':
    return array(
        '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
        '#<!\-\- l \-\-><a (?:class="[\w-]+" )?href="(.*?)(?:(&amp;|\?)sid=[0-9a-f]{32})?" target=\"_blank\">.*?</a><!\-\- l \-\->#',
        '#<!\-\- ([mw]) \-\-><a (?:class="[\w-]+" )?href="(.*?)" target=\"_blank\">.*?</a><!\-\- \1 \-\->#',
        '#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#',
        '#<!\-\- .*? \-\->#s',
        '#<.*?>#s',
    );
		

Step 4: Navigate to the forums admin panel (ACP) >> General tab >> Purge the cache >> Run now

Sponsors

Top Donators

Friends of Mine