Adverts Per Forum

Have you ever wanted to display adverts on your Web Wiz Forum based on the forum the visitor is in? If so read on as this tutorial will tell you how.

There are various different ways to do this such as with ASP or with JavaScripts. For this tutorial I will be sticking to ASP, as it will help us to integrate into the forum software easier. I will also be focusing on the built in advertising space between the first and second posts. It will also be based on a single forum sponsor. How ever it is relatively easy to adapt for say a banner at the top of the page or for an advertising network such as Google AdSense.

Add Adverts List

The first thing we need to do is create a new ASP file in the "functions" folder, we are created a new file so that it is easier to upgrade and will not course conflicts with future releases. To do this navigate to the "forum/functions/" folder of your website on your computer (it is always best to have a local copy of the entire website).

Create a new text file (.txt) and re-name this file to "s2h_adverts.asp" and then open this file into a basic text editor such as Notepad. Avoid using a program such as Dreamweaver or Frontpage.

In our new file we will need to copy and paste the following code into it. Once that is done save and close the file, We will be coming back to it later.

<%
'******************************************
'***  	Forum Posts Adverts	 	***
'******************************************

Private Function SelectPostAdvert(intForumID, strForumPostAd)
    Dim strOutput

    Select Case intForumID
    Case 1
        strOutput = "<a href=""http://www.s2h.co.uk/"">S2H has a wide selection of Web Wiz Forum modifications to improve your forum.</a>"
    Case 2
        strOutput = "<a href=""http://www.s2h.co.uk/"">Get great advice on improving your Web Wiz Forum from S2H.</a>"
    Case else
        strOutput = strForumPostAd
    End Select

    SelectPostAdvert = strOutput

End function
%>

Integrating with the Forum

Now we have a central place to store our adverts, we will need to get the forum to load them. For this will we load the ASP Function file into the "forum_posts.asp" file, so go ahead and load up that file into Notepad. Add the part in coloured below to the relevant position at the top of the file.

...
<!--#include file="functions/functions_format_post.asp" -->
<!--#include file="includes/emoticons_inc.asp" -->
<!--#include file="functions/s2h_adverts.asp" -->
<%
...

Now we need to add the following code to replace the existing advertising code. Add this to around line 867 of the "forum_posts.asp" file, just before the start of the HTML head.

 strForumPostAd = SelectPostAdvert(intForumID, strForumPostAd) 

We have now finished with the "forum_posts.asp" file, so you can save the changes and close it.

Adding Our Adverts

Now for the part most important for you, adding your adverts. We will need to go back to our "functions/s2h_adverts.asp" file, so load that up

If you simply want to display one forum sponsor, as this tutorial is designed, then you an simply edit the coloured parts of the code we copied above.

The blue part is the forum's ID, we will be using this to link our advert with the correct forum. To find out the ID of your forum look for the 'FID=' part in the URL, an example is below with the ID highlighted:

http://www.s2h.co.uk/forum/forum_topics.asp?FID=3

If you have enabled URL Rewriting then your URL will look different, an example for you is below, with the forum ID highlighted.

http://www.s2h.co.uk/forum/web-wiz-forum-tips-tricks_forum3.html

The part highlighted in red is where your sponsors website address will go. You will notice that it has the quotation marks surrounding it duplicated, this is an important part for the ASP and required for it to work.

The part highlighted in green is where the text for your sponsor will go. If you wish to use an image instead then you can enter the HTML for an image. But remember any quotation marks will need to be doubled like so.

strOutput = "<a href=""http://www.s2h.co.uk/""><img src=""/location/to/image.jpg"" /></a>"

Adding More Forums

If you need to add more forums than the two examples provided you can do so by simply repeating the block of code for each forum. An example below shows the blocks for 3 forums.

    Select Case intForumID
    Case 1
        strOutput = "<a href=""http://www.s2h.co.uk/"">S2H has a wide selection of Web Wiz Forum modifications to improve your forum.</a>"
    Case 2
        strOutput = "<a href=""http://www.s2h.co.uk/"">Get great advice on improving your Web Wiz Forum from S2H.</a>"
    Case 3
        strOutput = "<a href=""http://www.s2h.co.uk/"">Change the look of your Web Wiz Forum with a new Skin from S2H.</a>"
    Case else
        strOutput = strForumPostAd
    End Select

Conclusion

Hopefully this tutorial will help you have specific adverts for your forum or serve as the basis for you to adapt to your own specific needs.

If how ever you are having problems following it or are trying to adapt the code for a more advanced system. The please dont hesitate to contact us using our support forum.

Written By S2H on 24st February 2012 based on Web Wiz Forums v10.03

Share This Page

Advertisement