• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Easiest way to have one banner at top and one at bottom for all


Well-known member
I already have a old banner program which works well for the management and rotation, etc. - I simply call it via javascript. On my old forums (EE) I wrote a JS statement which grabs the forum number (from the source of the page) and then builds a call from that.

If the forum number was 22, it would grab just that segment from a url in the page source and build a query like:
http://www.hearth.com/cgi-bin/forumbottom22.pl (for the bottom banner) - there would be another script for the top banner)

which would call the banner rotator just fine....

So, my desire is to reproduce this on XF in the simplest way. The main thing is that I want the banners to show to every level of visitor - registered or not - and, again, a different call in different nodes. This should be quite simple compared to what some of the others here seem to be looking for....

I know where to place the code - so that part is easy. I guess all I need to know is:
1. Should I use custom JS as before and build my own urls, or should I use a XF variable (node number?) and pass that to JS? How?
2. Does putting this into the top and bottom ad containers - by default - make it seen to all users and guests always?

Just for kicks, my old hacked together JS was something like this - it grabbed the forum id in the first line - from the path....split it up and grabbed the number from it, and then if the number was larger than 2 (all were) it built a query based on the page it was located on. I then had a matching script in the cgi-bin, one for the top and bottom of each forum. That worked out well with the banner rotation program I have.
var myForumString = "{path:rss}";
var myFSResult = myForumString.split("/");
//var numres = myFSResult[7];
function staticLoadScript(url)
document.write('<script src="', url, '"type="text/JavaScript"><\/script>');
if (myFSResult[7] >= 2)
staticLoadScript("/cgi-bin/goldtop" + myFSResult[7] + '.' + "pl?jscript");


XenForo moderator
Staff member
The ad templates will show to all visitors, unless you use conditional statements.

To show ad's in a specific forum, you can use the following xen:if statement and incorporate the variable from your script.

<xen:if is="{$forum.node_id} == x">


Well-known member
Great - I suspected it was that simple, but it's always good to check with the experts rather than overlook something!

Happy New Year, all.