• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Add Rotation For Phpbb

Does anyone know how to do add rotation in phpbb in templates/TEMPLATE/overall_header.tpl? Please help! And make it so it rotates after each page refresh!

Thankyou!
 
Last edited:
So that there is a new template each time you refresh the page, or a new banner? What is rotating?
 
Code:
 <script type="text/javascript"><!-- 
  
 var currentdate = 0; 
 var core = 0; 
  
 function initArray() { 
  
 this.length = initArray.arguments.length; 
   for (var i = 0; i < this.length; i++) { 
   this[i] = initArray.arguments[i]; 
   } 
 } 
  
 link = new initArray( 
 "LINK TO AD 1", 
 "LINK TO AD 2", 
 "LINK TO AD 3" 
 ); 
  
 image = new initArray( 
 "IMAGE SOURCE FOR AD 1", 
 "IMAGE SOURCE FOR AD 2", 
 "IMAGE SOURCE FOR AD 3" 
 ); 
  
 text = new initArray( 
 "ALT. TEXT FOR AD 1", 
 "ALT. TEXT FOR AD 2", 
 "ALT. TEXT FOR AD 3" 
 ); 
  
 var currentdate = new Date(); 
 var core = currentdate.getSeconds() % image.length; 
 var ranlink  = link[core]; 
 var ranimage = image[core]; 
 var rantext  = text[core]; 
  
 document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>'); 
  
 //--> 
 </SCRIPT>
 
Last edited:
Tree_NC, there are a few issues with that code;

Code:
<script type="text/javascript"><!-- 
  
 var currentdate = 0; 
 var core = 0; 
  
 function initArray() { 
  
 this.length = initArray.arguments.length; 
   for (var i = 0; i < this.length; i++) { 
   this[i] = initArray.arguments[i]; 
   } 
 } 
  
 link = new initArray( 
 "LINK TO AD 1", 
 "LINK TO AD 2", 
 "LINK TO AD 3" 
 ); 
  
 image = new initArray( 
 "IMAGE SOURCE FOR AD 1", 
 "IMAGE SOURCE FOR AD 2", 
 "IMAGE SOURCE FOR AD 3" 
 ); 
  
 text = new initArray( 
 "ALT. TEXT FOR AD 1", 
 "ALT. TEXT FOR AD 2", 
 "ALT. TEXT FOR AD 3" 
 ); 
  
 var currentdate = new Date(); 
 var core = currentdate.getSeconds() % image.length; 
 var ranlink  = link[core]; 
 var ranimage = image[core]; 
 var rantext  = text[core]; 
  
 document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>'); 
  
 //--> 
 </script>

Firstly, all HTML code must be lowercase.
Secondly, you did not specify the <script> start tag (mine might to incorrect as xhtml is not my speicailty).
Thirdly, mac systems will ignore javascript, so there needs to be a better way than this...
Finally, you did not say were should should put it, in the header or what...

Here is the way i suggest.

PHP:
<?php
function randgif()
{
$path = "/home/robert/www/swedgamingportal/pathstobanners"; // full path to files on server

$handle = @opendir($path);
if($handle < 0)
 exit;
$count = 0;
$files = array();
while(($file = @readdir($handle)) !== false) {
 if($file != "." && $file != "..") {
  if(substr($file, 0, 1) == ".")
   continue;
  if(@is_dir("$path/$file"))
   continue;

  $lastdot = strrpos($file, ".");
  $ext = strtolower(substr($file, $lastdot+1));

  if(!($ext == "swf"))
   continue;

  $files[$count++] = $file;
 }
}
@closedir($handle);

return $files[rand(0, $count)];
}
?>

That will not just 'work' in phpBB, so at the end of every file just copy and paste the above. Then just place {randgif} in overall_header.tpl were you want the ads be.

Note: I am not tested this, it is based on the script from www.swed.us/randomgame.php.

It will be interesting if it works :D


Good points: Never need to edit the code

Bad points: All the banners have to be in 1 directry on your own server.
 
his script was javascript, yours was php. he did specify the <script> start tag (look harder) and html does not have to be in a specific case.

edit// oh and that code you just showed is only for .swf files, and not for numorous codes.
 
themoose said:
his script was javascript, yours was php. he did specify the <script> start tag (look harder) and html does not have to be in a specific case.

edit// oh and that code you just showed is only for .swf files, and not for numorous codes.
I looked and i saw no start tag...
 
XHTML and XML need to be a specific case. HTML does not.
Code:
<script type="text/javascript">
looks like a script start tag to me.

I'm not sure about JS not running on Mac systems, so you've got me there.
 
themoose said:
look at the top,

Code:
<script type="text/javascript">
that is the start code.
Did you get that from my post or Tree_ncs post. I edited Trees post so that it does have a start tag btw.
 
oh from yours :p I admit defeat on that part :D
but im sure JS works on Macs, and the rest i stand by
 
ok, maby JS does not work on Mac. However, the php code you provided is useless in what he wants. Maby a solution would be to put a decent php code between <noscript> tags.
 
The php code i provided is decent, and it worked for something else, so why exactly would it NOT work in this case?
 
because before it worked for rotation of swf files, with no links or other code involved. that code IS perfect for image/flash rotation, but not ad rotation. Example of ad code is:

Code:
 <!-- Begin BidVertiser code -->
<SCRIPT LANGUAGE="JavaScript1.1" SRC="http://bdv.bidvertiser.com/BidVertiser.dbm?pid=9094&bid=18939"></SCRIPT>
<noscript><a href="http://www.bidvertiser.com">make money online</a></noscript>
<!-- End BidVertiser code -->

. Get that script to rotate numoruos of them - you can't do it with out a re-write.
 
Back
Top