хуйу нас не матерятся
Корневые категории представляют из себя всего лишь заголовки. И если учесть, что на fluxbb нельзя вкладывать разделы в несколько уровней, то единственная возможность добавить лишний уровень в структуру форума- задействовать корневые категории.
Так как в комплекте с fluxbb идёт много тем оформления, договоримся, что будем менять только тему по-умолчанию.
Открываем файл index.php и находим место генерации разделов:
<div id="idx<?php echo $cat_count ?>" class="blocktable">
<h2><span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span></h2>
<div class="box">
<div class="inbox">
<table>
<thead>
<tr>
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
<tbody>
Меняем вывод невидимого слова в ячейке:
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
На вывод заголовка раздела:
<th class="" scope="col"><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></th>
Класс "tcl" скрывает эту ячейку, поэтому его нужно удалить, что мы и сделали. Следующее, что нужно сделать - перенести все заголовки таблиц в 1 высший уровень. Выше строчки "// Print the categories and forums" вставляем следующее:
?>
<div id="" class="blocktable">
<div class="box">
<div class="inbox">
<table>
<thead>
<tr>
<th class="" scope="col"></th>
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<?php
Чтобы иметь возможность пересчитать темы внутри разделов, придётся переписать цикл обхода всех разделов, меняем:
while ($cur_forum = $db->fetch_assoc($result))
На:
while ($forum[] = $db->fetch_assoc($result));
$ftmp=$forum;
foreach($forum as $cur_forum)
И так же меняем вывод заголовка таблицы на:
$cur_category = $cur_forum['cid'];
$hd_topict=0;
$hd_posts=0;
$hd_lastpost=0;
foreach($ftmp as $tmp)
if($tmp['cid']==$cur_category)
{
$hd_topict+=$tmp['num_topics'];
$hd_posts+=$tmp['num_posts'];
if($hd_lastpost<$tmp['last_post'])$hd_lastpost=$tmp['last_post'];
}
if($cur_forum['cat_name']!='')
{
?>
<div id="idx<?php echo $cat_count ?>" class="blocktable">
<!-- <h2><span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span></h2> -->
<div class="box">
<div class="inbox">
<table>
<thead>
<tr>
<th class="" scope="col"><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></th>
<th class="tc2" scope="col"><?php echo $hd_topict ?></th>
<th class="tc3" scope="col"><?php echo $hd_posts ?></th>
<th class="tcr" scope="col"><?php if($hd_lastpost)echo format_time($hd_lastpost); else echo $lang_common['Never'];?></th>
</tr>
</thead>
<tbody>
<?php
}
В результате главная страница форума выводится в следующем виде:
Следующее, что нужно сделать - скрытие/ показ разделов внутри категорий. Для начала добавим ссылки в заголовки:
<th class="" scope="col"><a href="/index.php?cid=<?php echo $cur_forum['cid']; ?>"><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></a></th>
Принимаем гет-параметр cid, чуть ниже строчки:
// Print the categories and forums
вставляем:
$cid=0;
if(isset($_GET['cid']))$cid=$_GET['cid'];
И добавляем исключение для показа подразделов, меняем:
?>
<tr class="<?php echo $item_status ?>">
<td class="tcl">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo forum_number_format($forum_count) ?></div></div>
<div class="tclcon">
<div>
<?php echo $forum_field."
".$moderators ?>
</div>
</div>
</td>
<td class="tc2"><?php echo forum_number_format($num_topics) ?></td>
<td class="tc3"><?php echo forum_number_format($num_posts) ?></td>
<td class="tcr"><?php echo $last_post ?></td>
</tr>
<?php
на:
if(($cur_forum['cid']==$cid)&&($cur_forum['cid']!=''))
{
?>
<tr class="<?php echo $item_status ?>">
<td class="tcl">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo forum_number_format($forum_count) ?></div></div>
<div class="tclcon">
<div>
<?php echo $forum_field."
".$moderators ?>
</div>
</div>
</td>
<td class="tc2"><?php echo forum_number_format($num_topics) ?></td>
<td class="tc3"><?php echo forum_number_format($num_posts) ?></td>
<td class="tcr"><?php echo $last_post ?></td>
</tr>
<?php
}
Закрываем фигурную скобку }.
Теперь разделы внутри категории скрыты и покажутся только при щелчке по заголовку раздела: