PDA

View Full Version : Forum list in sidebar block


LifesGreatestGift
04-10-2012, 01:05 AM
How would I go about getting the forum list (all forums viewable by current user) in a <select><option value="$forumid">$forumname</option></select> format?

I tried the following code

function construct_forum_list($parentid = -1, &$ret, $permission = '')
{
global $vbulletin;
global $stylevar, $vbphrase, $defaultselected;
if (!($vbulletin->userinfo['permissions']['forumpermissions']))
{
return;
}
if (empty($vbulletin->iforumcache))
{
require_once(DIR . '/includes/functions_forumlist.php');
cache_ordered_forums(1, 1);
}
if (empty($vbulletin->iforumcache["$parentid"]) OR !is_array($vbulletin->iforumcache["$parentid"]))
{
return;
}

$ret.= "<select>";
foreach($vbulletin->iforumcache["$parentid"] AS $forumid)
{
$forumperms = $vbulletin->userinfo['forumpermissions']["$forumid"];
if ((!($vbulletin->options['showprivateforums']) OR !($vbulletin->forumcache["$forumid"]['options'] OR !$vbulletin->forumcache["$forumid"]['displayorder'] OR !($vbulletin->forumcache["$forumid"]['options']))
{
continue;
}
else
{
$forum = $vbulletin->forumcache["$forumid"];
$ret.= "<option value=" . $forumid . ">";
$ret.= $forum[title_clean];
construct_forum_list($forumid, $ret, $forumperms);
$ret.= "</option>";
} // if can view
} // end foreach ($vbulletin->iforumcache[$parentid] AS $forumid)
$ret .= "</select>";
return $ret;

}

But I get the error
Fatal error: Cannot redeclare construct_forum_list() (previously declared in /home/krypto/public_html/forum/includes/block/html.php(95) : eval()'d code:1) in /home/krypto/public_html/forum/includes/block/html.php(95) : eval()'d code on line 39

Its a PHP block. Am I able to combine PHP/HTML?
How do I properly show a forum list dropdown selection?

I got some of the code from https://vborg.vbsupport.ru/showthread.php?t=246670 and removed the mod-specific conditionals on the fly so hopefully I didn't miss a ( or )

--------------- Added 1334036584 at 1334036584 ---------------

Ok, so I got rid of the error. Now my dropdown isn't showing all forums I am (as a user) able to post to. It may have something to do with the "-1"s?

--------------- Added 1334038241 at 1334038241 ---------------

nvm.