Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to create subforums with individual themes?

I'm looking for to build a forum with several subforums (personalized themes for each one). The idea is to have the users to be able to use all of these subforums with single account.

It seems that Vanilla Forums doesn't support this sort of subforum functionality out of the box but I figured that I could achieve something like this with parent categories, having one parent category as a subforum. Idea would be to differentiate these different parent categories with unique body classes which would be used for creating the separate themes.

I could create a custom smarty function to retrieve the subforum's css class when you are browsing it's categories/sub categories and have that as the unique body class identifier to create the theme but is there are better way to achieve this?

So my question has two parts:

1. What would be the best way to create such subforum installation? Does it make sense have parent categories to act as subforums or is there some other way to do this?

2. What is the simplest way to add category ancestor (top level) css class for every other category/subcategory/discussions page under it? As I'm new with Vanilla forums I wasn't able to get the current pages category id to be used inside the smarty function.


  • Options
    R_JR_J Ex-Fanboy Munich Admin

    If you only want to have different styles on a per category basis you can achieve that easily by looking at your body classes. You can edit the class name of a category in /vanilla/settings/editcategory. That class name is used as body.Section-ClassName

    So you can style it like that:

    Section-Subforum1 > li,
    Section-Subforum2 li {
    margin-top: 1em;


  • Options

    Thanks for the quick reply!

    At least for my test setup the class name doesn't seem to be inherited to subcategories, I would prefer to have the class name only for the top level category (which would be in this case a 'subforum') and then have it inherit to all of the sub categories to get the same look and feel as the parent has.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Then I guess you would need something like that in a plugin or in your themehooks:

        public function base_render_before($sender, $args) {
            $categoryID = $sender->CategoryID;
            if (!$categoryID) {
            $categoryModel = new categoryModel();
            $category = $categoryModel->getID($categoryID);
            if ($category->ParentCategoryID > 0) {
                $parentCategory = $categoryModel->getID($category->ParentCategoryID);

    Maybe you have to include a check if CssClass is set...

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Oh, and if you have multiple levels of subcategories, you would have to loop through the parentCategory part as long as the parentCategory = -1 or Depth = 1

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @R_J said:
    Oh, and if you have multiple levels of subcategories, you would have to loop through the parentCategory part as long as the parentCategory = -1 or Depth = 1

    Check out CategoryModel::GetAncestors instead.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.