kmike
05-20-2005, 10:00 PM
Description:
This hack makes navigation within forums from the same category much easier - no need to go to forum home or other aggregate page, just use popup menu similar to "Forum tools". See attached screenshot, it is really self-describing.
There're no new db queries, one .php file changed, one template edited and one template added.
Limitations:
Obviously, this is for forums which are categorized. Also, it will list all sub-forums of a parent forum, including subforums of the current forum and all subforums of forums from the current category. In other words, it's not for boards with advanced tree-like forum structure (more than 1 level deep).
Another issue: it will only work when DHTML popups are enabled. Required code is missing from the part of FORUMDISPLAY template responsible for displaying non-DHTML navigation.
Updates:
1.2 - Add check for active forum state when listing forums.
1.01 - Check forum permissions to hide forums which can't be accessed by user.
Code changes:
In forumdisplay.php, find this code fragment (vb 3.0.7):
else
{
$lastread = $bbuserinfo['lastvisit'];
}
Add these lines below:
// HACK: display sibling forums as related topics menu
require_once('./includes/functions_misc.php');
$childforums = fetch_child_forums($foruminfo['parentid'], 'ARRAY');
foreach ($childforums AS $val)
{
if ($val <> $forumid)
{
$relatedperms = $bbuserinfo['forumpermissions']["$val"];
if (!($relatedperms & CANVIEW) AND $vboptions['hideprivateforums'])
{
continue;
}
$relatedinfo = fetch_foruminfo($val);
if (! ($relatedinfo['options'] & $_FORUMOPTIONS['active']) )
{ // forum isn't active
continue;
}
eval('$relatedtopicbits .= "' . fetch_template('relatedtopicbit') . '";');
}
}
// HACK
In the same file, find this code (near the top):
'none' => array(
'FORUMDISPLAY',
Add this beneath:
'relatedtopicbit',
Template changes:
In the FORUMDISPLAY template, find this line:
<td class="tcat" width="100%">$vbphrase[threads_in_forum]<span class="normal">: $foruminfo[title]</span></td>
underneath it, add this:
<td class="vbmenu_control" id="relatedtools"><a href="#goto_relatedtools">Related Topics</a> <script type="text/javascript"> vbmenu_register("relatedtools"); </script></td>
Find this fragment:
<if condition="$show['popups']">
<br />
<!-- popup menu contents -->
Add underneath it:
<!-- related tools menu -->
<div class="vbmenu_popup" id="relatedtools_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr><td class="thead">Forums<a name="goto_relatedtools"></a></td></tr>
$relatedtopicbits
</table>
</div>
<!-- / related tools menu -->
Create new template named "relatedtopicbit". Populate it with this:
<tr><td class="vbmenu_option"><a href="forumdisplay.php?$session[sessionurl]f=$relatedinfo[forumid]">$relatedinfo[title]</a></td></tr>
That's it.
This hack makes navigation within forums from the same category much easier - no need to go to forum home or other aggregate page, just use popup menu similar to "Forum tools". See attached screenshot, it is really self-describing.
There're no new db queries, one .php file changed, one template edited and one template added.
Limitations:
Obviously, this is for forums which are categorized. Also, it will list all sub-forums of a parent forum, including subforums of the current forum and all subforums of forums from the current category. In other words, it's not for boards with advanced tree-like forum structure (more than 1 level deep).
Another issue: it will only work when DHTML popups are enabled. Required code is missing from the part of FORUMDISPLAY template responsible for displaying non-DHTML navigation.
Updates:
1.2 - Add check for active forum state when listing forums.
1.01 - Check forum permissions to hide forums which can't be accessed by user.
Code changes:
In forumdisplay.php, find this code fragment (vb 3.0.7):
else
{
$lastread = $bbuserinfo['lastvisit'];
}
Add these lines below:
// HACK: display sibling forums as related topics menu
require_once('./includes/functions_misc.php');
$childforums = fetch_child_forums($foruminfo['parentid'], 'ARRAY');
foreach ($childforums AS $val)
{
if ($val <> $forumid)
{
$relatedperms = $bbuserinfo['forumpermissions']["$val"];
if (!($relatedperms & CANVIEW) AND $vboptions['hideprivateforums'])
{
continue;
}
$relatedinfo = fetch_foruminfo($val);
if (! ($relatedinfo['options'] & $_FORUMOPTIONS['active']) )
{ // forum isn't active
continue;
}
eval('$relatedtopicbits .= "' . fetch_template('relatedtopicbit') . '";');
}
}
// HACK
In the same file, find this code (near the top):
'none' => array(
'FORUMDISPLAY',
Add this beneath:
'relatedtopicbit',
Template changes:
In the FORUMDISPLAY template, find this line:
<td class="tcat" width="100%">$vbphrase[threads_in_forum]<span class="normal">: $foruminfo[title]</span></td>
underneath it, add this:
<td class="vbmenu_control" id="relatedtools"><a href="#goto_relatedtools">Related Topics</a> <script type="text/javascript"> vbmenu_register("relatedtools"); </script></td>
Find this fragment:
<if condition="$show['popups']">
<br />
<!-- popup menu contents -->
Add underneath it:
<!-- related tools menu -->
<div class="vbmenu_popup" id="relatedtools_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr><td class="thead">Forums<a name="goto_relatedtools"></a></td></tr>
$relatedtopicbits
</table>
</div>
<!-- / related tools menu -->
Create new template named "relatedtopicbit". Populate it with this:
<tr><td class="vbmenu_option"><a href="forumdisplay.php?$session[sessionurl]f=$relatedinfo[forumid]">$relatedinfo[title]</a></td></tr>
That's it.