Helping out a frequent visited phpbb3 based forum – I’ve been looking for a simple banner system for phpbb3, the search have been dreadfull…

I ended up doing this simple thing in 10 minutes.

Added the following in styles/themename/template/overall_header.html in the theme:

  1. <div id="banner">
  2.   <!– INCLUDE ../../../banners.html –>
  3. </div>

Added the file banners.html in the root of the board:

  1. <script type="text/javascript">
  2.  
  3. function Banner(src, url) {
  4.   this.url = url;
  5.   this.src = src;
  6. }
  7.  
  8. function applyBanners() {
  9.   if (banners.length == 0) return;
  10.   with (banners[Math.floor(Math.random() * banners.length)]) {
  11.     document.write(’<a href="’ + url + ‘"><img src="’ + src + ‘" alt="Banner"/></a>‘);
  12.   }
  13. }
  14.  
  15. // Apply banners here
  16. var banners = [];
  17. banners[banners.length] = new Banner(’http://anotherdan.com/banner1.gif’, ‘http://anotherdan.com’);
  18. banners[banners.length] = new Banner(’http://anotherdan.com/banner2.jpg’, ‘http://music.anotherdan.com’);
  19.  
  20. // render banners if any…
  21. applyBanners();
  22.  
  23. </script>

This could be alot cleaner so the guy maintaining only had the array of banners in the file, but this was a proof of concept.

Enjoy…