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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 230
  • Total: 230

Tricky Block Request

Started by Xarcell, June 01, 2006, 04:18:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gbingo

Catmenu block? There is such a thing! Boy, do I feel like a newbie!  :laugh: I'll look into this now.

JPDeni

The menu block is for articles. You want boards.


global $db_prefix, $scripturl;
$perm= $GLOBALS['user_info']['groups'][0];
if ($perm <>1)
  $where = 'WHERE FIND_IN_SET(' . "'" . $perm . "'" . ',memberGroups)';
else
  $where = '';

$query = db_query(
    "SELECT ID_BOARD, name
     FROM {$db_prefix}boards
     $where
     ORDER BY boardOrder", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
  echo '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '">'. $row['name'] . '</a><br />';
}


Tested in a php block. No errors.  :)

Jpg

#12
This works? Let me test it out. :)

Edit: Sadly it doesn't work. :(

jacortina

The base code is pretty much already done in the loadJumpTo function of Load.php (which gets the arrays for the Jump To drop-down.


global $db_prefix, $context, $user_info;

if (!isset($context['jump_to']))
{
// 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.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']
);
}
mysql_free_result($request);
}

foreach ($context['jump_to'] as $category)
{
echo '<span class="smalltext" style="text-decoration: underline; font-weight: bold;">', $category['name'], '<br /></span>';
foreach ($category['boards'] as $board)
echo '<span class="smalltext"><a href="' . $scripturl . $board['id'] . '.0">'. str_repeat('..', $board['child_level'] + 1) . '&nbsp' . $board['name'] . '</a><br /></span>';
}

JPDeni

Quote from: Jpg on August 23, 2006, 06:50:16 PM
Edit: Sadly it doesn't work. :(
It doesn't work? Or it doesn't do what you wanted it to do? It works, but I may have misunderstood what you wanted.

Assistance

Quote from: jacortina on August 24, 2006, 05:09:50 PM
The base code is pretty much already done in the loadJumpTo function of Load.php (which gets the arrays for the Jump To drop-down.


thats cool code, but it shows ..&nbsp instead of space

jacortina

Quote from: Assistance on August 24, 2006, 09:18:22 PM
thats cool code, but it shows ..&nbsp instead of space

Really?

Neither IE 6 nor FF on either of two PC's that I tried it on did that.

But you can just change that line in the code.

Assistance


jacortina

I left out the global declaration for $scripturl.

Add that to the others in the first line or you'll get all sorts of errors logged (though the code works with that undefined).

snoopy_inc

This code works perfectly in display on the main page.  100%  BUT  it is linking to unknown places.  IE The requested URL /forum/index.php20.0 was not found on this server. that is the error im getting.
When the board url for that one is something totally different.

Somone help me with this plz


ie
The requested URL /forum/index.php9.0 was not found on this server. from the code you gave me.

This is what it should be linking to
http://*****/forum/index.php/board,9.0.html

Any help on this would be much appriciated as this will help with getting new visitors to access the forums easier.
Thanks

This website is proudly hosted on Crocweb Cloud Website Hosting.