How to Add a Code Only in One / Some of vBulletin Folders / Sections

vBulletin LogoYou may need to put some warning message or an advertisement or .. whatever in only a part of the folders inside your vBulletin forums. I guess there are some modifications that may help but the simpler way is just to edit some templates using a little PHP conditioning.

OK let’s start, I already made a post on similar modifications for avatars & signature so I won’t be repeating all the steps but instead will refer you to there when needed. (You may find it useful to open that post in another tab from now ;) )

Note: This involves inserting PHP codes, so be very careful on how you do it. Also if you get warnings from vBulletin when trying to save the modified templates Do NOT save them, that can break your forum’s display!

1. Open & edit the FORUMDISPLAY template

Just like we found the postbit template (1.), only this time you need to expand Forum Display Templates », then choose the FORUMDISPLAY template.

2. Find the line to put the new codes

I don’t know in what placement you want your message / code to appear so you’ll have to find it in the FORUMDISPLAY template. What may help is to open one of your forum’s folders in your browser, view the source of the page & compare it with the template you want to edit (FORUMDISPLAY here).

3. Add an IF condition to the template

Now that you know where to display the code let’s insert it. Depending on what you want there are different codes:

a. You want the special code / message in one & only section

In this case you need the following code:

<if condition="$forumid == XX">
Your special codes go here.

XX should be replaced with your folder’s numeric ID. The easiest way to get this ID is to look at the URL of the folder (/forumdisplay.php?f=XX).

Note: Instead of putting your message right in the template, you could create a replacement variable, this would make editing the message later easier, follow my guide on creating variables (3.a.).

b. Special code in a few folders

In this case you want the warning, banner or whatever to appear in more than a folder. You need a code like this:

<if condition="$forumid == XX OR $forumid == YY">
Your special codes go here.

Replace XX & YY with your forums IDs & add as many ORs as you want, but don’t add more than 50% of your folders, if your aim is to exclude a few forums go to the next title ;)

c. Put code in most folders & exclude few ones

In this case you want the thingy widely in the forum but see no need to have it in 1 or 2 folders so decide to exclude them. Here’s the code:

<if condition="$forumid != XX AND $forumid != YY">
Your special codes go here.

The code above will display the message in all the forums except the ones with IDs XX & YY. You can add more ANDs to exclude more folders.

d. Have a certain code in some folders & another one in the others

The way to do this is to use one of the codes above (a., b. or c.) & to insert both messages separated with an <else /> tag, example:

<if condition="$forumid == XX OR $forumid == YY">
This message goes in forums XX & YY
<else />
This message is for all the other forums.

You could replace the messages with replacement variables (3.a.), let’s say @varXXYY@ & @varALL@ :

<if condition="$forumid == XX OR $forumid == YY">
<else />

Comment ( 1 )

Comments are closed.