TinyPortal

Development => Resources => Topic started by: Tron420 on June 21, 2007, 01:32:55 PM

Title: forum in a center block
Post by: Tron420 on June 21, 2007, 01:32:55 PM
anyone know how i could put the forum board index in a center block?
Title: Re: forum in a center block
Post by: Zetan on June 21, 2007, 07:02:09 PM
Why would you want to?
Title: Re: forum in a center block
Post by: Reality12 on June 21, 2007, 07:05:49 PM
LOL. Didn't mean to laugh, but that response caught me off guard there zetan! :D
Title: Re: forum in a center block
Post by: Zetan on June 21, 2007, 07:09:36 PM
Well, I guess there is a reason.. I just find some requests odd at times.

Don't want a front page, set the front page to go straight to forums and still have blocks showing.
Recent topics I can understand, and there are snippits that can do this. Have the whole forum index in a block.... ?
Title: Re: forum in a center block
Post by: Reality12 on June 21, 2007, 08:51:14 PM
I understand exactly what you mean. :D

OP?? Was there a reason? Just curious.
Title: Re: forum in a center block
Post by: Tron420 on June 22, 2007, 01:08:36 AM
omg..

welll if u must know. I'm using a theme that has blocks that cant be disabled and if i could put the forum in a block i can arrange my site the way i want it
Title: Re: forum in a center block
Post by: vanguard on June 22, 2007, 01:16:16 AM
I got this somewhere on these forums but for the sake of time I will just put a copy here. This has a simple text based output but works like a champion. Not sure how it would look in a center block but not much to lose by trying.

If you wanted to get fancy you could grab the code from your forum front page, like I did, and copy the code into an html block for the front page. Problem with this option is if you add or remove categories you'll have to copy the new code in again.

Here you go:

global $db_prefix, $context, $user_info, $scripturl;

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=' . $board['id'] . '.0">'. str_repeat('-', $board['child_level'] + 1) . $board['name'] . '</a><br /></span>';
}
Title: Re: forum in a center block
Post by: vanguard on June 22, 2007, 01:27:18 AM
Oh,

Example of working block on my page in right block column:

www.ufodbase.com
Title: Re: forum in a center block
Post by: Tron420 on June 22, 2007, 01:52:58 AM
that code isnt working for me

ive even tried it in html/bbc -  php block-  etc and get this error -

Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /home/content/h/i/t/hitthosting/html/cz/Sources/Load.php(1733) : eval()'d code(35) : eval()'d code on line 6
Title: Re: forum in a center block
Post by: vanguard on June 22, 2007, 02:51:24 AM
Double checking:

Ok on my site the code is right and the block type is PHPBox. Make sure you click the source button before pasting code.

:)

If that doesn't work pehaps there is a difference in tp or smf versions or something different with your theme.

I hope you can make it work.
Title: Re: forum in a center block
Post by: MYBESTHOMESnet on July 17, 2007, 01:00:49 AM
nice one.