Drupal - Forum Container / New Topic

Kevin's picture

[b]Q:[/b] How do I remove or delete the forum container entries from the 'Forums:' dropdown on the 'New Topic' form? If a user chooses a forum container rather than an actual forum and then tries to create a post an error message like 'The item [Container Name] is only a container for forums. Please select one of the forums below it.' is displayed - this is really annoying the client!

[b]A:[/b] One way to get around this problem is to install the Banish Forum Containers module that we developed specially to get us out of this particular hole. It removes the forum containers from the dropdown list and instead displays the forum names pre-pended with the container name in a format like this:

[Forum Container Name] - [Forum Name]

Shane and I spent quite a bit of time searching for a solution to this problem, while our client was quite rightly jumping up and down and shaking his fists! The problem can arise when developing a website that has multiple forums partitioned into different forum containers. Websites running [url=http://drupal.org/project/og]Organic Groups[/url] with [url=http://drupal.org/project/og_forum]OG Forum[/url] often fall into this category.

When users create a new topic they are presented with a drop-down from which they choose a forum to post into. The drop-down shows the forums grouped by forum container, and it is possible (and quite easy) to choose a forum container, rather than a forum, by accident. If you do this and try to save the new topic you just get an annoying error message like: [i]'The item [Container Name] is only a container for forums. Please select one of the forums below it.'[/i]

It is not always obvious which are forums and which are containers and so this problem can be encountered quite a bit.

[img]/sites/default/files/images/forum_before.PNG[/img]

In the screenshot above, the forums begin with '-', it is easy to get them mixed up with the containers that don't!

We spent ages looking for a module or some other fix for the problem, but couldn't find anything, that's not to say that there isn't one - but we couldn't just didn't find it, please lt us know if there is another solution!

We ran out of time and decided to try to fix it ourselves. What we figured we'd do was write some code to remove the containers from the dropdown and modify the forum names so that they start with the container name. In this way the error can't occur and you can still tell which container each forum belongs to.

[img]/sites/default/files/images/forum_after.PNG[/img]

In the screenshot above, the containers have been removed and the forum names have been changed...

We decided to write a module to implement hook_form_alter() which would modify the select options for the 'Forums:' dropdown. The module's details are a bit on the dry side for explaining here, but the module can be downloaded from Drupal.org.

To install it just copy it to your [i]sites/all/modules/[/i] directory and enable it in the modules page, there are no settings.

If you want to change the format of the altered forum names, and are feeling brave, then you can edit [i]banishforumcontainers_forum_name.tpl.php[/i] which is to be found in the [i]banishforumcontainer[/i] directory. Just copy it into your theme folder, edit as required and flush your cache.

We haven't released it to the drupal community as a proper module yet as we don't know if it is the best solution and we don't have time to properly support it etc. (what with being so busy designing & developing cracking websites for our clients in Cork!). If you guys find it useful, please let us know and we will consider releasing it properly to the community.

The module has worked out great for us, but please use it at your own risk...

If you do find it useful, or you encounter problems please let us know!

Share this post: 

Recent Work

Some of Ireland's biggest brands use Pride Design to Design, Build, Manage, Market and Maintain their websites.

Website design for St.Patricks Credit Union in Dublin, Including Loan Calculators.

Website design and development for a step by step wedding and other stationary ordering website f

New website designed and developed for Cork's newest café, which is based in Merchants Quay in Co

New Website design for Pain Relief clinic based in Cork City.

Website for a busy Dublin city centre pub.

We redrafted the Ballymaloe house website to modernise the look and feel of the site and to also

We revamped the website for the Ballymaloe Cookery School.

We revamped the Cully & Sully website onto Drupal.

Rachel Allen was brought up in Dublin and left home at eighteen to study at the world-famous Ball

Clóna Dairy Products are a Dairy Company based in Clonakilty, Co. Cork, since 1919.

Project Arts Centre is Ireland’s leading centre for the presentation and development of c