How to use this hack to display rotating banners.
You can use the above hack on a php script to create any number of rotating banners above your forums (without any modification to the forum table as per other hacks). Create a .php file as follows:
PHP Code:
<?php
$banners = array (
"banner1.gif|link1.pl|Alt text for banner 1|0|468|60",
"banner2.gif|link2.pl|Alt text for banner 2|0|468|60",
"banner3.gif|link3.pl|Alt text for banner 3|0|468|60",
"banner4.gif|link4.pl|Alt text for banner 4|0|468|60"
);
$banner = $banners[mt_rand(0,sizeof($banners) - 1)];
list($imgsrc,$myurl,$alttext,$border,$width,$height) = explode ('|',$banner);
echo("<A HREF=\"http://www.yourdomain.com/cgi-bin/$myurl\" TARGET = \"_blank\"><IMG src=\"http://www.yourdomain.com/adverts/banners/$imgsrc?" . mt_rand(1,999) . "\" border=\"$border\" width=\"$width\" height = \"$height\" alt=\"$alttext\"></A>");
?>
Notes:
- banner1.gif to banner4.gif are the names of the banner files
- the banner files exist in the /adverts/banners/ folder on your website (change this to whatever you want)
- link1.pl to link4.pl are simple perl scripts which open up the target websites (see below)
- the perl scripts are in your cgi-bin folder
- the 0|468|60 are the border width (0=no border), banner width and banner height for each banner. Mine are all the same - no border and 468x60.
- using _blank for the target makes the new websites open in a new window. Remove the TARGET = \"_blank\" bit if you want it to open in the same window
Upload this php file to your server and have the above hack open it.
If you want to display the same set of banners on several forums, just have them open this file. If you want a different set of banners you'll need to create a different version of this file for each.
Other notes:
The reason for calling the perl scripts is so that a hit stats package like Webtrends can count the number of times the perl scrips have been run and provide you with the number of clicks for your banners in it's report.
A typical perl script would look like this:
HTML Code:
#!/usr/bin/perl
print "Location: http://www.targetdomain.com/";
Oh and adding
on to the end of the name of the image helps ensure that people's cache doesn't open up old versions of banners.
--------------------------------------------------------------------------------------------------
Give users a control panel option to change how the added information is displayed
I use this hack to include different news feed above certain forums but some users wanted it displayed at the bottom or not at all.
This is very easy and thanks to Colin F who helped me.
First create a new user option. I'll use my installation as an example.
Admin CP > User Profile Fields > Add New User Profile Field.
For the Profile field type choose Single Selection Radio Buttons or Single Selection Menu whichever you prefer. I chose the latter since it looks more similar to existing multiple choice user options.
Complete the new profile field information.
My forum users use this profile field to decide how to display the news and I set the Options to
Above threads
Below threads
Not shown
I set the default to Yes, but No First Blank Option. And the field IS required.
Lastly for the display page 'Which page displays this option?' choose Options: other.
Ok, now you have the new profile field. Take a look at the list of User Profile Fields in the User Profile Field Manager to find which field your new option is. Mine was field9.
Now all you have to do is edit the FORUMDISPLAY template.
Below $navbar insert
-------------------
<if condition="$mycustomheader AND $bbuserinfo[field9] == 'Above threads'">$mycustomheader</if>
-------------------
Note that this is the original hack altered to display the $customheader information IF the user has chosen to display it above threads.
--------------------
Then below
------------------------------
<!-- ############## END THREADS LIST ############## -->
</if>
-------------------------------
Insert
------------------------------
<if condition="$mycustomheader AND $bbuserinfo[field9] == 'Below threads'">$mycustomheader</if>
------------------------------
Note that if users have chosen the third option 'Not shown', then the $mycustomheader information is never shown