Introduction
Are you using phpBB forum and want to create a menu that consists of all the forums of the site categorized correctly under their respective categories? Well, this would be your solution.
I made this for phpBB Version 3.0.5 but I'm sure that it would work for earlier versions as well.
The Instructions
Open
functions.phpFind:
$user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
}
- $user_lang = substr($user_lang, 0, strpos($user_lang, '-x-'));
- }
After that, add:
// Generating the forum's navigation
$sql = 'SELECT * FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('forum_links', array(
'IS_CATEGORY' => ($row['parent_id'] == 0) ? true : false,
'FORUM_NAME' => $row['forum_name'],
'FORUM_LINK' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
);
}
$db->sql_freeresult($result);
- // Generating the forum's navigation
- $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' ORDER BY left_id ASC';
- $result = $db->sql_query($sql);
- while($row = $db->sql_fetchrow($result))
- {
- $template->assign_block_vars('forum_links', array(
- 'IS_CATEGORY' => ($row['parent_id'] == 0) ? true : false,
- 'FORUM_NAME' => $row['forum_name'],
- 'FORUM_LINK' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']))
- );
- }
- $db->sql_freeresult($result);
The Template
To make this as dynamic as possible and to help create the code able to work with any template, I would only give you the HTML list of links which you should add CSS to... if you can't/don't know how, PM me and I'll try to help you out in that field.
Anyway, what you should do to actually get the link list to show up is put the following in an HTML template file found in
styles/{TEMPLATE_NAME}/template/ where the underlined text is the name of the template you are using.
Put this code anywhere wherever you want to links to appear:
<!-- BEGIN forum_links -->
<li<!-- IF forum_links.IS_CATEGORY --> class="head"<!-- ENDIF -->><!-- IF forum_links.IS_CATEGORY -->{forum_links.FORUM_NAME}<!-- ELSE --><a href="{forum_links.FORUM_LINK}">{forum_links.FORUM_NAME}</a><!-- ENDIF --></li>
<!-- END forum_links -->
- <!-- BEGIN forum_links -->
- <li<!-- IF forum_links.IS_CATEGORY --> class="head"<!-- ENDIF -->><!-- IF forum_links.IS_CATEGORY -->{forum_links.FORUM_NAME}<!-- ELSE --><a href="{forum_links.FORUM_LINK}">{forum_links.FORUM_NAME}</a><!-- ENDIF --></li>
- <!-- END forum_links -->
Almost a SPAM
To see this in action, you can
view my forum and look at the left navigation... this is how that is created.
Conclusion
No, needless to say, you know how to get a dynamically updated list of navigation. This solution might not be suitable for huge forums (as in a forum that has so many forums, the navigation would be endless

)
Learn PHP | I got 10 PHP tutorials! Check them out!
Dreamtale - Farewell
Just a note... I've giving up on web development and that stuff... Just lost all interest in it.