PHP / iframes


Well-known member
One of the critical mods to my vB forum I'd need to find a solution to is my advert banners. Because I sell direct I use my own PHP script to randomly select a banner from x number of banners, with each page load.

It took me about four weeks and 481 cups of coffee to get my head around the vB plugin system. XenForo seems to be light years ahead and terms like handles and listeners really frighten me :)

So, I will probably take the short cut and use an iframe, as suggested in this post:

Looking at that members site I think they did use iframes in the end and it looks like they work.

As I will never be using external pages within the iframe, am I right in assuming there is no risk involved?

If I put the iframe in the sidebar, I'd create a new place for it by ripping off the Staff Online or Members Online, changing the title to "Advertisement" and then putting the iframe in that. My last question is, would that automatically pad out to the height of the iframe, or do I need to do any CSS trickery to make sure the "Advertisement" box matched the iframe?

As you can gather I have never used iframes before :)


XenForo moderator
Staff member
An iframe is just a means of embedding content, usually another site, on a page.
As you will be defining the iframe content yourself in the templates, the only risk involved is the content you embed.

You will need to wrap the iframe in the appropriate code to make it match other sidebar elements.
This can be copied quite easily from the other templates though.

It will be something like this:
<div class="section">
<div class="secondaryContent">


XenForo moderator
Staff member

I used to use iframe BB Code on my old forum for embedding weather forecasts in posts.
It really is that easy.

Here's a generic BB Code I did for someone who wanted to embed any page in a post:
Of course you can't download it but it shows that it's possible.

That one does have a risk associated with it though as it allows anyone to embed any code as it's generic.
On my old site the BB Code was limited to weather forecasts only so there was no risk.