Go Back   Computer Forums > General Computing > Software and Operating Systems
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 12-29-2010, 01:27 PM   #1
Beta Member
Join Date: Dec 2010
Posts: 4
Default Hide Specific Forum Containers

After a long time, the Drupal Tips are back, with a new series of 4 tips. We hope you'll enjoy them.

When you support a large forum community, which could contain dozens of categories (in the Drupal terminology, they are called container), it is not always relevant to
display all of them in the main forum index page. This could be easily customized using one of the existing forum preprocessor.

To achieve this, you simply need to modify your template.php file:

* @param $variables
function yourtheme_preprocess_forum_list(&$variables) {

// Remove forum containers & forum that are related to reviews for the Discussion Root
// See page-forum.tpl.php
if (count($variables["parents"]) == 0) {
$forum_container_ids = array(12, 30, 40); // Ids of the container you want to hide
foreach($variables['forums'] as $id => $forum) {
if (in_array($id, $forum_container_ids)) {

if (in_array($forum->parents[0], $forum_container_ids)) {

In this snippet, $forum_container_ids contains the Drupal identifiers of forum containers you want to hide. You can obtain these ids in the Forum Administration page, by hovering the Edit Container buttons and see the related URL: e.g. in admin/content/forum/edit/container/40 the container id is 40.

Remark: This hack works to hide anything. You can also hide forum section using this trick: the only thing you need to do is to get the related ids, by hovering the Edit Forum button: for example, the forum URL admin/content/forum/edit/forum/226 stands for forum id 226.

It is even possible to filter them on other pages, by comparing the content of the $variables["parents"]. In our example above, we ensure that the total of parents equals to 0, to only apply the filtering at the root of the hierarchy, i.e. the index page. This could be for example relevant if you want to restrict some part to specific user groups (roles), but it will obviously require additional security checks.

This is applied in our forum for hiding support sections, which are too big and complete. These sections are however displayed as simple links at the bottom of the forum list.

steve.56 is offline   Reply With Quote
Old 12-29-2010, 01:48 PM   #2
Beta Member
Join Date: Dec 2010
Posts: 4
Default Re: Hide Specific Forum Containers

Microsoft is said to be bringing a bigger focus to PC gaming in the next version of Windows. Citing anonymous sources, TechRadar reported yesterday that PC gaming will be part of a "new push" by Microsoft, as well as a "key component f...
peter.15 is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 03:45 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0