News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

How to hide child board display on main forum index

Started by SMiFFER, April 23, 2021, 04:56:24 AM

Previous topic - Next topic

SMiFFER

Hey friends of SMF !

Is there a way to hide the sub / child board (sub boards = child boards) on the main index display?
I would like to hide them so only the "top boards" (categories) are listed.

Where to go?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SMiFFER

Quote from: Kindred on April 23, 2021, 05:01:24 AM
You will have to modify boardindex.template.php
Ah! And I was searching for such a configuration setting and was not able to find it...

Understood, so which lines must be amended and in what way?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

ozp

Search for

// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)

and remove the whole if case. That will probably remove all child boards, though I haven't tested it.

shadav

or if you are just looking to clean them up so they don't take up so much space you could install the
Childboards as Dropdown mod

drewactual

or... don't jack with 'out of the box' code beyond index.template at all and simply add this before just before the /head tag on your theme's index.template.php:

find:

</head>


replace with:

';
// begin for the express purpose to hide child boards on main index
   if(isset($_REQUEST['board'])){}
     elseif(isset($_REQUEST['topic'])){}
     elseif(isset($_REQUEST['action'])) {}
   else  {echo' <style>.children{display:none;}</style>';}
// end for the express purpose to hide child boards on main index
echo'
</head>


untested, but should work, and can be easily removed... leave the comments intact so you know exactly what to remove should you need or want to later.  the reason to do this is to allow the indexers (google, ect) to see the markup and know there is structure there (and get credit for the internal link), but to keep it tidy for your UI/UX. 

SMiFFER

@DREWACTUAL

I did the find and replace exactly as instructed. Does not work. Sorry.
=> The subboards are still shown.

Where is the bug?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

SMiFFER

@KINDRED and OZP
Quote from: Kindred on April 23, 2021, 05:01:24 AM
You will have to modify boardindex.template.php
Quote from: ozp on April 23, 2021, 06:11:23 AM
Search for

// Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...)

and remove the whole if case. That will probably remove all child boards, though I haven't tested it.

Tried that as well. Went into my forum theme folder, it has no boardindex.template.php,
so I went into DEFAULT and modified that one as instructed, so the portion now looks like this:


// // 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="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']) . ')"><img src="' . $settings['lang_images_url'] . '/new.gif" class="new_posts" alt="" />' : '') . '</a>';
// else
// $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $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">
// <td colspan="3" class="children windowbg">
// <strong>', $txt['parent_boards'], '</strong>: ', implode(', ', $children), '
// </td>
// </tr>';
// }


Does not work. Sorry.
=> The subboards are still shown.

Where is the bug?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

GL700Wing

Life doesn't have to be perfect to be wonderful ...

Kindred

Refresh the server and local cache after changes
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: