TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 19, 2024, 08:22:53 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,164
  • Total Topics: 21,219
  • Online today: 266
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 101
  • Total: 101

[Block] Board Index Menu

Started by IchBin, August 23, 2007, 02:31:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchBin

This little code snippet will create a menu consisting of all your Categories, boards, and child boards. A small screen shot is attached so you can see what it looks like. Just put this code into a phpbox type of block. I've put some comments in the code in case anyone would like to edit the style of the text, to indicate which line for the text.

global $db_prefix, $context, $user_info;

// Find the boards/cateogories they can see.
$request = db_query("
SELECT c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.numTopics, b.childLevel
FROM {$db_prefix}boards AS b
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
WHERE $user_info[query_see_board]", __FILE__, __LINE__);
$context['jump_to'] = array();
$this_cat = array('id' => -1);
while ($row = mysql_fetch_assoc($request))
{
if ($this_cat['id'] != $row['ID_CAT'])
{
$this_cat = &$context['jump_to'][];
$this_cat['id'] = $row['ID_CAT'];
$this_cat['name'] = $row['catName'];
$this_cat['boards'] = array();
}

$this_cat['boards'][] = array(
'id' => $row['ID_BOARD'],
'name' => $row['boardName'],
'child_level' => $row['childLevel'],
'is_current' => isset($context['current_board']) && $row['ID_BOARD'] == $context['current_board'],
'topics' => $row['numTopics']
);
}
mysql_free_result($request);

foreach ($context['jump_to'] as $category){
// edit the following line if you want to change the style of the category text.
echo '<span style="line-height: 10px; font-weight: bold;" class="normaltext" ><b>', strtoupper($category['name']), '</b></span><br />';

foreach ($category['boards'] as $board){
            if (!$board['child_level']){
//edit the following line for the regular board text
echo '<a href="',$scripturl,'?board=', $board['id'], '">', $board['name'], '</a><br />';
//this line you can edit for the topics count text
echo '<span class="smalltext" style="margin-left: 10px;">', $board['topics'],' ', $txt[330], '</span><br />';
}
else{
//this line you can edit to change the child board text
echo '<a class="normaltext" style="margin-left: 20px;" href="',$scripturl,'?board=', $board['id'], '">', $board['name'],'</a><br />';
}
         
}
}

G6Cad


Bloodlvst

IchBin, would it be possible to combine this with a javascript menu I have to make the categories collapsable?

3nd3r

Works perfect!
Thank you very much for your effort

Zetan

 :up: Works well, I might just keep this in Admin view minimised. Top stuff.

IchBin

Quote from: Bloodlvst on August 23, 2007, 02:53:02 PM
IchBin, would it be possible to combine this with a javascript menu I have to make the categories collapsable?
I'm sure its possible, but its beyond me at this point.

Tracy Beyer

I put this into a PHPBox but it does not show up. I see the header, but the script appears to not be working. I am not getting any errors listed below the header, just , a header bar and nothing following except the next box,.

Nokonium

I like it  :up:

Just added a couple of existing style classes and it blends in very nicely.  :)

IchBin

Quote from: Tracy Beyer on September 18, 2007, 03:18:44 PM
I put this into a PHPBox but it does not show up. I see the header, but the script appears to not be working. I am not getting any errors listed below the header, just , a header bar and nothing following except the next box,.
Have a link? I may need to look at the block so if you could provide a temp account with TP admin access I'll take a look at it.

Maddog452

Is it possible to do something very similar but for the Articles page listing Categories and Subcategories?