Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 08:05:31 PM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 60
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 50
Total: 50

Author Topic: [Block] Board Index Menu  (Read 54251 times)

0 Members and 1 Guest are viewing this topic.

Offline IchBin

  • Friends
  • *
  • Posts: 16231
[Block] Board Index Menu
« on: August 23, 2007, 07:31:47 AM »
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.

Code: [Select]
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 />';
}
         
}
}
« Last Edit: September 29, 2008, 07:09:36 AM by IchBinâ„¢ »

Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: Board Index Menu
« Reply #1 on: August 23, 2007, 07:40:54 AM »
Great work IchBin  :D

Bloodlvst

  • Guest
Re: Board Index Menu
« Reply #2 on: August 23, 2007, 07:53:02 AM »
IchBin, would it be possible to combine this with a javascript menu I have to make the categories collapsable?

3nd3r

  • Guest
Re: Board Index Menu
« Reply #3 on: August 23, 2007, 07:55:40 AM »
Works perfect!
Thank you very much for your effort

Offline Zetan

  • Friends
  • *
  • Posts: 3471
Re: Board Index Menu
« Reply #4 on: August 23, 2007, 07:59:02 AM »
 :up: Works well, I might just keep this in Admin view minimised. Top stuff.

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Board Index Menu
« Reply #5 on: August 23, 2007, 08:00:36 AM »
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

  • Guest
Re: Board Index Menu
« Reply #6 on: September 18, 2007, 08:18:44 AM »
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,.

Offline Nokonium

  • Aging Hippie
  • Friends
  • *
  • Posts: 1384
    • Our-Local
Re: Board Index Menu
« Reply #7 on: September 18, 2007, 11:49:25 AM »
I like it  :up:

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

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Board Index Menu
« Reply #8 on: September 18, 2007, 04:21:16 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

  • Guest
Re: Board Index Menu
« Reply #9 on: September 20, 2007, 06:01:37 AM »
Is it possible to do something very similar but for the Articles page listing Categories and Subcategories?