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

Recent

Welcome to TinyPortal. Please login or sign up.

May 18, 2024, 10:30:47 PM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 112
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 52
  • Total: 52

[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.

MBry0

It works. It just needs some font adjustement. Thank you for the quick solution!

MBry0

I've made a litte modification to the IchBin code and added a very simple jquery toggle effect.
http://www.gamesandgamers.org

ZarPrime

Hi MBry0,

Very nice. O0

However, it seems that the + sign shows up next to the main board even if the Main Board has no child boards, at least that a guest can see.  I'm wondering, could you post the entire code you are using so that I could have a look at it to see if I can figure out how to remove the + sign if there are no child boards.

Thanks,
ZarPrime

MBry0

#73
Here it is :)

global $smcFunc, $context;

// Find the boards/cateogories they can see.
$request = $smcFunc['db_query']('', '
SELECT c.name AS catName, c.id_cat, b.id_board, b.name AS boardName, b.num_topics, b.child_level
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
WHERE {query_see_board}',
array()
);

$context['jump_to'] = array();
$this_cat = array('id' => -1);
while ($row = $smcFunc['db_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['child_level'],
'is_current' => isset($context['current_board']) && $row['id_board'] == $context['current_board'],
'topics' => $row['num_topics']
);
}
$smcFunc['db_free_result']($request);

$counter = 0;

foreach ($context['jump_to'] as $category){
// edit the following line if you want to change the style of the category text.
echo '<span><b>', strtoupper($category['name']), '</b></span><br />';

foreach ($category['boards'] as $board){
if (!$board['child_level']){
$counter++;
//edit the following line for the regular board text
echo '<a style="font-size: 12px;" href="',$scripturl,'?board=', $board['id'], '">', $board['name'], '</a><span id="more_', $counter, '" style="cursor:pointer;"> <img src="THE + IMAGE HERE"/></span>
<script type=text/javascript>
$(document).ready(function(){
$("#more_', $counter, '").click(function(){
$(".showhide_'.$counter.'").toggle();
});
});
</script>
<br />';
//this line you can edit for the topics count text
echo '<span>';
}
else{
//this line you can edit to change the child board text
echo '<span class="showhide_'.$counter.'" style="display:none;"><a style="font-size: 10px; margin-left: 20px;"
href="',$scripturl,'?board=', $board['id'], '"><img src="YOUR ARROW IMAGE HERE"/>', $board['name'].'</a><br /></span>';
}
         
}
}



EDIT: the block causes thousands errors. Those 2 in loop:

http://www.gamesandgamers.org/forum/index.php?
8: Undefined variable: scripturl
File: /web/htdocs/www.gamesandgamers.org/home/forum/Themes/default/languages/TPortal.italian-utf8.php (tp_below sub template - eval?)
String: 44


http://www.gamesandgamers.org/forum/index.php?
8: Undefined variable: scripturl
File: /web/htdocs/www.gamesandgamers.org/home/forum/Themes/default/languages/TPortal.italian-utf8.php (tp_below sub template - eval?)
String: 59


Whit eval enabled i get the same errors and same strings on /web/htdocs/www.gamesandgamers.org/home/forum/Themes/default/TPsubs.template.php

rocknroller

Quote from: MBry0 on March 30, 2012, 09:52:05 AM
Here it is :)

global $smcFunc, $context;

// Find the boards/cateogories they can see.
$request = $smcFunc['db_query']('', '
SELECT c.name AS catName, c.id_cat, b.id_board, b.name AS boardName, b.num_topics, b.child_level
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
WHERE {query_see_board}',
array()
);

$context['jump_to'] = array();
$this_cat = array('id' => -1);
while ($row = $smcFunc['db_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['child_level'],
'is_current' => isset($context['current_board']) && $row['id_board'] == $context['current_board'],
'topics' => $row['num_topics']
);
}
$smcFunc['db_free_result']($request);

$counter = 0;

foreach ($context['jump_to'] as $category){
// edit the following line if you want to change the style of the category text.
echo '<span><b>', strtoupper($category['name']), '</b></span><br />';

foreach ($category['boards'] as $board){
if (!$board['child_level']){
$counter++;
//edit the following line for the regular board text
echo '<a style="font-size: 12px;" href="',$scripturl,'?board=', $board['id'], '">', $board['name'], '</a><span id="more_', $counter, '" style="cursor:pointer;"> <img src="THE + IMAGE HERE"/></span>
<script type=text/javascript>
$(document).ready(function(){
$("#more_', $counter, '").click(function(){
$(".showhide_'.$counter.'").toggle();
});
});
</script>
<br />';
//this line you can edit for the topics count text
echo '<span>';
}
else{
//this line you can edit to change the child board text
echo '<span class="showhide_'.$counter.'" style="display:none;"><a style="font-size: 10px; margin-left: 20px;"
href="',$scripturl,'?board=', $board['id'], '"><img src="YOUR ARROW IMAGE HERE"/>', $board['name'].'</a><br /></span>';
}
         
}
}



EDIT: the block causes thousands errors. Those 2 in loop:

http://www.gamesandgamers.org/forum/index.php?
8: Undefined variable: scripturl
File: /web/htdocs/www.gamesandgamers.org/home/forum/Themes/default/languages/TPortal.italian-utf8.php (tp_below sub template - eval?)
String: 44


http://www.gamesandgamers.org/forum/index.php?
8: Undefined variable: scripturl
File: /web/htdocs/www.gamesandgamers.org/home/forum/Themes/default/languages/TPortal.italian-utf8.php (tp_below sub template - eval?)
String: 59


Whit eval enabled i get the same errors and same strings on /web/htdocs/www.gamesandgamers.org/home/forum/Themes/default/TPsubs.template.php

you must globalize $scripturl that will fix the errors
Tra

MrCare

how to make original board index layout in the block?

IchBin

Edit this section of the code to output what you would like it to be:

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 />';
}
         
}
}

MrCare


IchBin

There is no ssi function that does this.

MrCare

try to add this to block... but not succeed

function template_main()
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

echo '
<div id="boardindex_table" class="boardindex_table">
<table class="table_list">';

/* Each category in categories is made up of:
id, href, link, name, is_collapsed (is it collapsed?), can_collapse (is it okay if it is?),
new (is it new?), collapse_href (href to collapse/expand), collapse_image (up/down image),
and boards. (see below.) */
foreach ($context['categories'] as $category)
{
// If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
if (empty($category['boards']) && !$category['is_collapsed'])
continue;

echo '
<tbody class="header" id="category_', $category['id'], '">
<tr>
<td colspan="4">
<div class="cat_bar">
<h3 class="catbg">';

// If this category even can collapse, show a link to collapse it.
if ($category['can_collapse'])
echo '
<a class="collapse" href="', $category['collapse_href'], '" title="' ,$category['is_collapsed'] ? $txt['show'] : $txt['hide'] ,'">', $category['collapse_image'], '</a>';

echo '
', $category['link'], '
</h3>
</div>
</td>
</tr>
</tbody>';

// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{

echo '
<tbody class="content" id="category_', $category['id'], '_boards">';
/* Each board in each category's boards has:
new (is it new?), id, name, description, moderators (see below), link_moderators (just a list.),
children (see below.), link_children (easier to use.), children_new (are they new?),
topics (# of), posts (# of), link, href, and last_post. (see below.) */
foreach ($category['boards'] as $board)
{
echo '
<tr id="board_', $board['id'], '" class="windowbg2">
<td class="windowbg icon"', !empty($board['children']) ? ' rowspan="2"' : '', '>
<a href="', ($board['is_redirect'] || $context['user']['is_guest'] ? $board['href'] : $scripturl . '?action=unread;board=' . $board['id'] . '.0;children'), '">';

// If the board or children is new, show an indicator.
if ($board['new'] || $board['children_new'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'on', $board['new'] ? '' : '2', '.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />';
// Is it a redirection board?
elseif ($board['is_redirect'])
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'redirect.png" alt="*" title="*" />';
// No new posts at all! The agony!!
else
echo '
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'off.png" alt="', $txt['old_posts'], '" title="', $txt['old_posts'], '" />';

echo '
</a>
</td>
<td class="info">
<a class="subject" href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a>';

// Has it outstanding posts for approval?
if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
echo '
<a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';

echo '

<p>', $board['description'] , '</p>';

// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
if (!empty($board['link_moderators']))
echo '
<p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';

// Show some basic information about the number of posts, etc.
echo '
</td>
<td class="windowbg stats">
<p>', comma_format($board['posts']), ' ', $board['is_redirect'] ? $txt['redirects'] : $txt['posts'], '
', $board['is_redirect'] ? '' : '<br /> '.comma_format($board['topics']) . ' ' . $txt['board_topics'], '
</p>
</td>
<td class="lastpost">';

if (!empty($board['last_post']['id']))
echo '
<p>', $board['last_post']['last_post_message'], '</p>';
echo '
</td>
</tr>';
// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)
if (!empty($board['children']))
{
// Sort the links into an array with new boards bold so it can be imploded.
$children = array();
/* Each child in each board's children has:
id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
foreach ($board['children'] as $child)
{
if (!$child['is_redirect'])
$child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>';
else
$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>';

// Has it posts awaiting approval?
if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics']))
$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';

$children[] = $child['new'] ? '<strong>' . $child['link'] . '</strong>' : $child['link'];
}

echo '
<tr id="board_', $board['id'], '_children" class="windowbg2">
<td colspan="3" class="windowbg children">
<p><strong>', $txt['parent_boards'], '</strong>: ', implode(', ', $children), '</p>
</td>
</tr>';
}
}
echo '
</tbody>';
}
echo '
<tbody class="divider">
<tr>
<td colspan="4"></td>
</tr>
</tbody>';
}
echo '
</table>
</div>
<ul id="posting_icons">';

if ($context['user']['is_logged'])
echo '
<li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_some.png" alt="" /> ', $txt['new_posts'], '</li>';

echo '
<li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_none.png" alt="" /> ', $txt['old_posts'], '</li>
<li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_redirect.png" alt="" /> ', $txt['redirect_board'], '</li>
</ul>';

// Show the mark all as read button?
if ($context['user']['is_logged'] && $settings['show_mark_read'] && !empty($context['categories']))
echo '
<div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>';
}