Tuesday, September 20, 2011

phpbb relative url howto - bbcode

Forum can host a lot of information and, from time to time, same or similar topics can be asked again and again. It is, therefore, not unusual, that forums contain links to pointed to one of its other threads - just like links in web pages that pointed to pages in the same web site.

Lot of times, relative URLs are used for these links for various reasons. For one, if the site is to be moved from a developing host to the production server, with the relative URL, none of those links need to be updated. From time to time, we also see companies got purchased and need to moved to a new domain and, hence the new URL. All of these justify the use of relative URL in web pages.

For the phpBB, up to version 3.0, the [url=][/url] BBCode does not support the use of relative URL. To overcome that, one solution is to create a customized BBCode called, say, [rel=][/rel].

Customized BBCode can be defined through the phpBB's administrator panel. Log into the forum as an administrator and click the 'Administration Control Panel' at the bottom. Re-confirm the administrator password. Click the 'POSTING' tab at the top menu bar and click the BBCodes link under the MESSAGE title in the left side bar. Click Add a new BBCode and enter the following information. In BBCode usage textbox, enter '[rel={LOCAL_URL}]{TEXT1}[/rel]' and, in HTML replacement textbox, enter <a href="{LOCAL_URL}">{TEXT1}</a>. Click the submit button.

If you would like to save the typing even more you could use <a href="/phpBB/{LOCAL_URL}">{TEXT1}</a> instead. In this case, all you need is the the URL part that run off your phpBB root directory.

2 comments: