I have improved the mod a bit. I've added an option to exclude forums from the changes and I've tweaked the CSS a bit. I hope these changes can be integrated into the next official release.
To add the setting for excluding forums, add this to settinggroup name="VSa_SFA":
Code:
<setting varname="vsasfm_excludedforums" displayorder="12">
<datatype>free</datatype>
</setting>
You also need this phrase in vBulletin Settings group:
Code:
<phrase name="setting_vsasfm_excludedforums_desc" date="1328301371" username="TiKu" version=""><![CDATA[Leave alone sub-forums in these forums (comma separated ID list)]]></phrase>
This is the updated MN hook:
Code:
if ($vbulletin->options['vsasfm_enable'] AND ($vbulletin->options['vsasfm_coltarget']>0))
{
if (!function_exists('vsa_construct_subforumbit'))
{
function vsa_construct_subforumbit($parentid, $cancontainthreads, $output = '', $depthmark = '--', $depth = 0)
{
global $vbulletin, $vbphrase;
global $lastpostinfo, $lastpostarray;
static $splitter;
if ($cancontainthreads)
{
$canpost = true;
}
else
{
$canpost = false;
}
if (!isset($vbulletin->iforumcache["$parentid"]))
{
return $output;
}
foreach($vbulletin->iforumcache["$parentid"] AS $forumid)
{
$forum = $vbulletin->forumcache["$forumid"];
$forumperms = $vbulletin->userinfo['forumpermissions']["$forumid"];
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) AND ($vbulletin->forumcache["$forumid"]['showprivate'] == 1 OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND !$vbulletin->options['showprivateforums'])))
{
continue;
}
if (!$forum['displayorder'] OR !($forum['options'] & $vbulletin->bf_misc_forumoptions['active']))
{
continue;
}
else
{
$lastpostinfo = $vbulletin->forumcache["$lastpostarray[$forumid]"];
$forum['statusicon'] = fetch_forum_lightbulb($forumid, $lastpostinfo, $forum);
$show['newposticon'] = ($forum['statusicon'] ? true : false);
switch ($vbulletin->options['vsasfm_tr_counts'])
{
case 1: $vsasfm_trcounts = ' ('.$forum['threadcount'].')'; $vsasfm_trcounttitle = $vbphrase['threads']; break;
case 2: $vsasfm_trcounts = ' ('.$forum['replycount'].')'; $vsasfm_trcounttitle = $vbphrase['posts']; break;
case 3: $vsasfm_trcounts = ' ('.$forum['threadcount'].'/'.$forum['replycount'].')'; $vsasfm_trcounttitle = $vbphrase['threads'].'/'.$vbphrase['posts']; break;
}
if ($vbulletin->options['vsasfm_csscounts']!='')
{
$vsasfm_trcounts = '<span class="shade" style="'.$vbulletin->options[vsasfm_csscounts].'" title="'.$vsasfm_trcounttitle.'">'.$vsasfm_trcounts.'</span>';
}
$vsasfm_blankline = $vsasfm_trcount = $vsasfm_change = false;
eval('$vsasfm_blanklinesub = in_array($forum[forumid], array(' . $vbulletin->options['vsasfm_blankline_subs'] . '));');
if (in_array($forum['forumid'], array($vsasfm_blanklinesub)))
{
$vsasfm_blankline = '<br /><br />';
$vsasfm_change = true;
}
if (($vbulletin->options['vsasfm_tr_counts']>0) AND ($forum['threadcount']>0))
{
$vsasfm_trcount = $vsasfm_trcounts;
$vsasfm_change = true;
}
if ($vsasfm_change)
{
$forum[title] .= '</a>'.$vsasfm_trcount.$vsasfm_blankline.'VSa';
}
$templater = vB_Template::create("vsa_sfm_subforumbit");
$templater->register('forum', $forum);
$templater->register('canpost', $canpost);
$templater->register('depth', $depth+1);
$subforum = $templater->render();
if ($depth < $vbulletin->options['subforumdepth'])
{
$output .= vsa_construct_subforumbit($forumid, $cancontainthreads, $subforum, $depthmark . '--', $depth + 1);
}
}
}
return $output;
}
}
// ---- START inserted by TiKu ----
$affectforum = !in_array($forum['forumid'], explode(',', $vbulletin->options['vsasfm_excludedforums']));
// ---- END inserted by TiKu ----
if (($subsonly OR $depth == MAXFORUMDEPTH) AND $vbulletin->options['subforumdepth'] > 0)
{
$vsasfm_subforumdata = vsa_construct_subforumbit($forumid, ($forum['options'] & $vbulletin->bf_misc_forumoptions['cancontainthreads'] ) );
}
else
{
$vsasfm_subforumdata = '';
}
$vsasfm_reqcol = $vbulletin->options['vsasfm_coltarget'];
$vsasfm_colwid = round(100 / $vbulletin->options['vsasfm_coltarget']);
if ($vbulletin->options['vsasfm_csstable']!='')
{
$vsasfm_css_table = $vbulletin->options[vsasfm_csstable];
}
if ($vbulletin->options['vsasfm_csscell']!='')
{
$vsasfm_css_cell = $vbulletin->options[vsasfm_csscell];
}
unset($vsasfm_cols, $vsasfm_subf, $vsasfm_table);
$vsasfm_left = vB_Template_Runtime::fetchStyleVar('left');
// ---- START inserted by TiKu ----
$subforumstitle = '<h4 class="subforumlistlabel"';
if($vbulletin->options['vsasfm_subphrase'])
$subforumstitle .= ' style="display:none;"';
$subforumstitle .= '>' . $vbphrase['subforums'] . ':</h4>';
// ---- END inserted by TiKu ----
// ---- START changed by TiKu (width of 100%) ----
$vsasfm_table = '<div style="width:100%;">';
// ---- END changed by TiKu (width of 100%) ----
if ($vbulletin->options['templateversion'] >= '4.1.8')
{
// ---- START changed by TiKu (width of 100%, Padding, use $subforumstitle) ----
$vsasfm_table .= '<div class="subforums" style="width:100%;padding-left:5px;">' . $subforumstitle . '<ol class="subforumlist commalist" style="width:100%;padding-bottom:3px;">';
// ---- END changed by TiKu (width of 100%, Padding, use $subforumstitle) ----
}
// ---- START inserted by TiKu (if clause) ----
if($affectforum)
{
$vsasfm_table .= '<div style="width:100%;'.$vsasfm_css_table.'"><div style="vertical-align:top;clear:both;">';
}
// ---- END inserted by TiKu (if clause) ----
$vsasfm_getsubs = explode("<li",ltrim($vsasfm_subforumdata,"<li"));
foreach ($vsasfm_getsubs AS $vsasfm_subf)
{
$vsasfm_cols++;
// ---- START inserted by TiKu (if clause + else branch) ----
if($affectforum)
{
if ($vsasfm_cols % $vsasfm_reqcol == 0)
{
$vsasfm_table .= '<div style="float:'.$vsasfm_left.';width:'.$vsasfm_colwid.'%;text-align:'.$vsasfm_left.';'.$vsasfm_css_cell.'"><ul><li'.$vsasfm_subf.'</ul></div></div><div style="vertical-align:top;clear:both;">';
}
else
{
$vsasfm_table .= '<div style="float:'.$vsasfm_left.';width:'.$vsasfm_colwid.'%;text-align:'.$vsasfm_left.';'.$vsasfm_css_cell.'"><ul><li'.$vsasfm_subf.'</ul></div>';
}
}
else
{
$vsasfm_table .= '<li ' . $vsasfm_subf;
}
// ---- END inserted by TiKu (if clause + else branch) ----
}
// ---- START inserted by TiKu (if clause) ----
if($affectforum)
{
$vsasfm_table .= '</div></div>';
}
// ---- END inserted by TiKu (if clause) ----
if ($vbulletin->options['templateversion'] >= '4.1.8')
{
$vsasfm_table .= '</ol></div>';
}
$vsasfm_table .= '</div>';
$vsasfm_table = str_ireplace('<li<', '<', $vsasfm_table);
$vsasfm_table = str_ireplace('VSa</a>', '', $vsasfm_table);
$vsasfm_table = trim(preg_replace('/-\s*\([^)]*\)VSa/', '', $vsasfm_table));
$forum['subforums'] = $vsasfm_table;
// ---- START removed by TiKu ----
/*if ($vbulletin->options['vsasfm_subphrase'])
{
$forumbits = str_ireplace('class="subforumlistlabel"', 'style="display:none;"', $forumbits);
$childforumbits = str_ireplace('class="subforumlistlabel"', 'style="display:none;"', $childforumbits);
}
$forumbits = str_ireplace(' commalist', '', $forumbits);
$childforumbits = str_ireplace(' commalist', '', $childforumbits);*/
// ---- END removed by TiKu ----
}
Regards
TiKu
|