Overview

An Advanced Forum style is a collection of template files, CSS stylesheets, images, and a .info file. Of these, only the .info is required. Because the style system supports inheritance from parent styles, the rest of the files can be added as needed to give your forum style a distinct look. A style is not a full site theme and so is meant to be used in conjunction with your theme. Advanced Forum comes with some styles that you can use as is or use as a base for your own style. If you are using a pre-made theme, that may also have come with a style.

Info files

Every style needs a .info file named after the style. (Ex: blue_lagoon_stacked.info)

  • name: Name of style as shown to the user. (Ex: Blue Lagoon Stacked)
  • description: Some text describing the file (Ex: Same as Blue Lagoon except the Author Pane is on top.)
  • version: Version of Advanced Forum the style is meant for. 1.x styles will not work on 2.x. (Ex: 2.x)
  • base style: If this is a substyle, the name of the style to inherit from (Ex: blue_lagoon)
  • extra style: One other style to inherit from. Any parents to this other style are ignored so it's best to use a base style for this. (Ex: naked_stacked)

Template files

Advanced Forum comes with a number of template files to control the content and markup of your forum. For each template file, Advanced Forum will look in a sequence of directories and use the first matching template file it finds. The sequence is as follows:

Drupal 6

  1. The active theme, including subdirectories. A template file named advanced_forum.TEMPLATE_NAME.tpl.php (note no style name) will be used no matter what style you are using. Core will find this file even in subdirectories under your theme.
  2. The active theme, not including subdirectories. A .tpl.php file from Advanced Forum that is named like advanced_forum.STYLE_NAME.TEMPLATE_NAME.tpl.php where STYLE_NAME is the name of the active style will be used if #1 is not found.
  3. The active style directory. If there is no match on the template file in the theme, Advanced Forum will look next at the active style for a match. Again, the file must be named advanced_forum.STYLE_NAME.TEMPLATE_NAME.tpl.php.
  4. The extra style directory. The .info of the active style may specify an "extra style" directory. This throws one more style into the inheritance chain. The main purpose is for changes in structure that is shared by multiple styles, such as the "stacked" version, but all files are eligible for inheritance from this style. Advanced Forum will look for a file where STYLE_NAME matches this style and not the active style's name.
  5. The base style directory. The .info of the active style may specify a "base style" directory. This is the parent style. Advanced Forum will look for a file where STYLE_NAME matches this style and not the active style's name.
  6. The base style directories up the chain. While in practice you will likely only do one substyle, it is possible to do sub substyles and so on. You can keep specifying base styles in each .info and Advanced Forum will continue looking up the chain until it finds the template file it is looking for. In each case, Advanced Forum will look for a file where STYLE_NAME matches this style and not the active style's name.
  7. The Naked style directory. As a safety precaution, the Naked style will act as an ultimate base style to ensure a template is always found. This is only true of templates, not CSS, so you should always specify Naked as the base if you want to use its CSS.

Drupal 7

The directory structure is the same, but the template names are slightly different. Replace the dot before the template name with a dash, like this:
advanced_forum-TEMPLATE_NAME.tpl.php

A list of every template file included with Advanced Forum as well as a description of its use can be found here.

Stylesheets

There are three stylesheets involved in an Advanced Forum style:

  • advanced_forum.STYLE_NAME.structure.css: As the name implies, this stylesheet handles structuring the content. Floats, margins, padding, and similar items are in here.
  • advanced_forum.STYLE_NAME.style.css: This stylesheet handles the "decorative" parts of the styling. Colors, borders, font styles, and similar items are in here.
  • advanced_forum.STYLE_NAME.images.css: This stylesheet handles all images in the style. Only the bare minimum needed to place images is in here to make it easy to change out for a different set of images.

Stylesheets are additive in that all eligible stylesheets are added to the page. This has the advantage that only the base style needs a full stylesheet and substyles contain only changes. The disadvantage is that you can quickly end up with a large number of stylesheets on forum pages. Using CSS compression is highly recommended.

Stylesheets are added in a set order. First all the "structure" ones from all styles, then the "style" one from all styles and finally the "images" one from all styles. Styles do not need to contain all three. Advanced Forum will look through the style directories in the following order and add them as it finds them:

  1. The active theme, not including subdirectories. If you have a stylesheet named advanced_forum.STYLESHEET_NAME.css (not including the active style name), it will be used, no matter what style you are using. If this style sheet is found, no more stylesheets are added.
  2. The base style directory. If using sub sub styles, this is the style at the end of the chain with no base style specified in the .info. Unlike template files, this will not default to the Naked style automatically. If there is no matching stylesheet in the chain, the stylesheet will simply not be used. The file must be named advanced_forum.STYLE_NAME.STYLESHEET_NAME.css where STYLE_NAME matches this style and not the active style's name.
  3. The base style directories down the chain. Since each style can specify a base style, there could be a chain of these. In each case, Advanced Forum will look for a file where STYLE_NAME matches this style and not the active style's name.
  4. The active style drectory. The file must be named advanced_forum.STYLE_NAME.STYLESHEET_NAME.css where STYLE_NAME matches the active style's name.
  5. The active theme, not including subdirectories. The file must be named advanced_forum.STYLE_NAME.STYLESHEET_NAME.css where STYLE_NAME matches the active style's name.
  6. Your theme's style sheet. The stylesheets that are part of your theme will always be added after all Advanced Forum styles. You can use this to make minor changes that will affect all styles.

Putting it all together - An example

We'll use Blue Lagoon Stacked as an example. The .info file looks like this:

name = Blue Lagoon Stacked
description = Same as Blue Lagoon except the Author Pane is on top.
version = 2.x
base style = blue_lagoon
extra style = naked_stacked

The base style is Blue Lagoon, which only has CSS files for the style and images. But Blue Lagoon has a base style of Naked. From Naked, it gets the structural CSS and all of the template files. Between those, you get a style that looks just like Blue Lagoon.

But this is Blue Lagoon Stacked. What makes it stacked? That's where the "extra style" comes into play. That is set to Naked Stacked, which has a changed Author Pane template as well as some additional structure CSS. So we suck those in as well. Because the extra style is added right before the current style, it overrides the stuff we are getting from both Naked and Blue Lagoon to make the changes needed to be stacked.

You may notice that Naked Stacked lists Naked as its base theme. That is ignored. When you add an "extra style" only that style is added, not its parent. It's simply a one off style tossed in at the last minute to allow variations on a style.

Telling Advanced Forum about your style

Now that you know all the ins and outs of styles, the last thing you need to know is how to tell Advanced Forum about it. There are two ways: theme and module.

Theme

  1. Copy your style directory to your theme. If you are going to include multiple styles in your theme, you might want to make a subdirectory to hold them all.
  2. Add this line to your theme's .info file: plugins[advanced_forum][styles] = 'your_style_directory_here' Replace 'your_style_directory_here' with either the directory of your style or the directory you created to hold multiple styles.
  3. You may need to clear your cache before the new style shows up on the list.

Module

  1. Copy your style directory to your module. If you are going to include multiple styles in your module, you might want to make a subdirectory to hold them all.
  2. Add this code to your module:
    function MODULE_NAME_ctools_plugin_directory($module, $plugin) {
      if ($module == 'advanced_forum') {
        return 'STYLE_DIRECTORY';
      }
    }
    

    Replace MODULE_NAME with the name of your module, STYLE_DIRECTORY with the directory holding your styles (or an individual style directory if only one) and leave the rest as is.

  3. You may need to clear your cache before the new style shows up on the list.

Comments

mr.andrey’s picture

On D7 and Zen subtheme, I had to use "advanced_forum-post.tpl.php".

"advanced_forum.post.tpl.php" and "advanced_forum.naked.post.tpl.php" (or other theme) had no effect.

beauKC’s picture

A list of every template file included with Advanced Forum as well as a description of its use can be found [[HERE]].

Any chance this has ever been created, yet? I specifically came here looking for exactly that. :)

Thanks.

pwiniacki’s picture

same here - I would like to theme forums page (list of forums) so I would like to know what is the name of tpl.php file responsible for this.

EDIT: https://www.drupal.org/node/234042

Drupal beginer

beauKC’s picture

Thanks for the link. I've updated the page.