News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Childboards as Dropdown

Started by Matthew K., March 12, 2009, 01:04:02 PM

Previous topic - Next topic

Matthew K.

Link to Mod

Brief Summary:


Childboards as Dropdown allows you to convert the normal list of Child Boards into a dropdown input to conserve space and improve the forum layout.

You can enable or disable this modification from the admin panel.  In addition, you can define a number of childboards allowed to be displayed normally, before that board is converted to the new layout.  This allows you to only convert boards with "X" amount of childboards to a dropdown so boards with few childboards still display normally.  You do have the option to over-ride and have all boards convert to the new layout however.

As of version 2.0.0, the modification was completely re-written, functions with JavaScript disabled, and covers both the BoardIndex, and the MessageIndex.

The original version of this modification was written by Rumbaar.

TinyPortal Bug Reported by: teos55.



Features:


  • Enable / Disable Mod
  • Boards Containing > "X" Children Become Dropdown



Changelog:


v2.0.4 (r12.22.12):
- Many improvements.
- TinyPortal Compatibility Bugfix.

v2.0.3 (r3.19.12):

  • ! bugfix: modification breaks when collapsing categories, and throws undefined errors. (!~./modifications.xml)
  • Special thanks to Tonyvic for reporting the bug.

v2.0.2 (r2.4.12):

  • + now compatible with portals. (!./modifications.xml)
  • + phpDocumentor utilized for all mod functions. (!./cad_source/main.php, !./cad_source/resources/hooks.php)

v2.0.1 (r1.23.12):

  • !bugfix: Settings conflict with other modifications. (!./resources/hooks.php)

v2.0.0 (r1.12.12):

  • + Complete rewrite
  • ! Modification Renamed



Mentions:



  • Version: 2.0.4
  • Written by: Labradoodle-360
  • Copyright: Matthew Kerle - All Rights Reserved
  • Dedicated To: LILM, my family, and Scotty Christianson.


heinandar

For DilberMC Themes??

How can i do that?

Rumbaar

They use a two column system right?  You'll need to replace the whole section that the theme uses to generate it's child board listing in BoardIndex.template.php with the code I've used.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

heinandar

ႊThis is the original code of BoardIndexTemplate.php of DilberMC. I can't figure out.

// 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)
{
$child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
$children[] = $child['new'] ? '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/onk.gif" alt="' . $txt[333] . '"/><b>' . $child['link'] . '</b>' : '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/offk.gif" alt="' . $txt[334] . '"/>' . $child['link'];
}

echo '
<table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td class="middletext" valign="middle" align="center" width="30%">
<b>', $txt['parent_boards'], ':</b>
';

$child_counter = 0;

if(empty($settings['child_boards_rows']))
{
echo '
</td>
<td class="middletext" valign="top">';

for(; $child_counter < ceil(count($children)/2); $child_counter++)
echo $children[$child_counter], '<br/>';
}

echo '
</td>
<td class="middletext" valign="top">';
for(; $child_counter < count($children); $child_counter++)
echo $children[$child_counter], '<br/>';
echo '
</td>
</tr>
</table>';
}
// Show some basic information about the number of posts, etc.
echo '
</td>
<td class="windowbg" valign="middle" align="center" style="width: 12ex;"><span class="smalltext">
', $board['posts'], ' ', $txt[21], ' <br />
', $board['topics'],' ', $txt[330], '
</span></td>
<td class="windowbg2" valign="middle" width="22%">
<span class="smalltext">';

/* The board's and children's 'last_post's have:
time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
link, href, subject, start (where they should go for the first unread post.),
and member. (which has id, name, link, href, username in it.) */
if (!empty($board['last_post']['id']))
echo '
<b>', $txt[22], '</b>  ', $txt[525], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['smf88'], ' ', $board['last_post']['link'], '<br />
', $txt[30], ' ', $board['last_post']['time'];
echo '
</span>
</td>
</tr>';
}
echo '
</table>';
}
echo '
</div>';
}

Rumbaar

For DilberMC

Find:
// 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)
{
$child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')">' . $child['name'] . '</a>';
$children[] = $child['new'] ? '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/onk.gif" alt="' . $txt[333] . '"/><b>' . $child['link'] . '</b>' : '<img style="margin-right:5px;" src="' . $settings['images_url'] . '/' . $settings['theme_main_color'] . '/offk.gif" alt="' . $txt[334] . '"/>' . $child['link'];
}

echo '
<table style="float:right; margin-top: 15px;" width="100%" cellspacing="0" cellpadding="3" border="0">
<tr>
<td class="middletext" valign="middle" align="center" width="30%">
<b>', $txt['parent_boards'], ':</b>
';

$child_counter = 0;

if(empty($settings['child_boards_rows']))
{
echo '
</td>
<td class="middletext" valign="top">';

for(; $child_counter < ceil(count($children)/2); $child_counter++)
echo $children[$child_counter], '<br/>';
}

echo '
</td>
<td class="middletext" valign="top">';
for(; $child_counter < count($children); $child_counter++)
echo $children[$child_counter], '<br/>';
echo '
</td>
</tr>
</table>';
}


Replace:
// Show the Child Boards as drop-down menu
if (!empty($board['children']))
{
echo '<table>
<tr>
<td>
<form action="', $scripturl, '" method="get" accept-charset="', $context['character_set'], '" name="jumptoForm">
<span class="smalltext"><label for="jumpto"><strong>', $txt['parent_boards'], '</strong></label>:</span>
<select name="jumpto" id="jumpto" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 || this.options[this.selectedIndex].value.substr(0, 1) != \'?\' ? 0 : 1);">
<option value="">' . $txt[251] . '</option>';

// Populate the dropdown with child boards
foreach ($board['children'] as $child)
{
echo '
<option value="?board=', $child['id'], '.0">' , $child['name'] , '</option>';
}

echo '
</select>&nbsp;
</form>
</td>
</tr></table>';
}
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

heinandar

#5
LoL.........Working fine....Thanks for ur help

tk2012


kingkingston

I want to ad the mod but got this problem

1. Execute Modification ./Themes/default/BoardIndex.template.php Test failed

how do i fix it ?

Rumbaar

Glad you like tk2012

@ kingkingston You must have a prior modifications that has affected that area of your BoardIndex.template.php.  You'll need to look to see what has been changed and manually edit the file as needed.  Run the mod through the parser and see what it needs to find and look for that section.
Manual Installation of Mods
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

kingkingston

Quote from: Rumbaar on March 12, 2009, 06:06:28 PM
Glad you like tk2012

@ kingkingston You must have a prior modifications that has affected that area of your BoardIndex.template.php.  You'll need to look to see what has been changed and manually edit the file as needed.  Run the mod through the parser and see what it needs to find and look for that section.
Manual Installation of Mods

I tried it manually but i got a error,i gather this is the place i have to alter the code "attached"

tk2012

@Rumbaar

Is the only change to the Board Index?  If someone goes into the main board, will the boards still all be shown?  I'm just trying to figure out if I can still use my Images On Board mod with this or if I have to choose between them.  I have board images for the child boards which I spent some time on.  If it just puts a dropdown on the board index, that's cool, but I still want to see the childboards if I clicked on through from the main category.

Rumbaar

I don't think that is a default CORE BoardIndex.template.php file, are you sure it's not from the Babylon theme?  But you should still be able to use the code by replacing the child board call.  Which has given me the idea to actually include the modification for other 'default installed' themes.
// 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)
{
$child['link'] = '<a href="' . $child['href'] . '" title="' . ($child['new'] ? $txt[333] : $txt[334]) . ' (' . $txt[330] . ': ' . $child['topics'] . ', ' . $txt[21] . ': ' . $child['posts'] . ')" style="color: '. $child['bcolor']. ';">' . $child['name'] . '</a>';
$children[] = $child['new'] ? '<b>' . $child['link'] . '</b>' : $child['link'];
}

echo '
<div style="padding-top: 1px;" class="smalltext"><i>', $txt['parent_boards'], ': ', implode(', ', $children), '</i></div>';
}


Replace:
            // Show the Child Boards as drop-down menu
            if (!empty($board['children']))
            {
               echo '
            <div style="padding-top: 1px;" class="smalltext">
               <form action="', $scripturl, '" method="get" accept-charset="', $context['character_set'], '" name="jumptoForm">
                  <span class="smalltext"><label for="jumpto"><strong>', $txt['parent_boards'], '</strong></label>:</span>
               <select name="jumpto" id="jumpto" onchange="if (this.selectedIndex > 0 &amp;&amp; this.options[this.selectedIndex].value) window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf(\'?\') == -1 || this.options[this.selectedIndex].value.substr(0, 1) != \'?\' ? 0 : 1);">
               <option value="">' . $txt[251] . '</option>';

            // Populate the dropdown with child boards
               foreach ($board['children'] as $child)
               {
               echo '
                     <option value="?board=', $child['id'], '.0">' , $child['name'] , '</option>';
               }

               echo '
               </select>&nbsp;
               </form>
            </div>';
            }


Yes tk2012 it only affects the display of the Child boards on the 'frontpage' BoardIndex.template.php and will not alter any child board displays within the MessageIndex.template.php sections.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Kreator

Thanks for that Mod Rumbaar, although I had to manually adjust the boardIndex template  file,
as the package installer threw up an error .

I have it now running  and the boards look very clean now !!

All I want now is drop down menus for the main menu bar!

Mine have started to go off the page!! hehe

Smoky "Rider" Blue

Quote from: Rumbaar on March 12, 2009, 01:04:02 PM

Note: For 2.0 RC1 users boards can have the (!) indicator for awaiting moderation.  Due to the nature of the dropdown menu there will only be a (!) indicator and any moderation will need to be handled via the moderate section of the forum.
Moderate->Post

lol, umm rumbaar, do you have a working demo of this?? or a snapshot for the defautl rc1?? sounds kewl and helpful and would love to see what the effect looks like first..

thanks my friend!!  ;)
**Take the time to remember friendships and family.. Sometimes it's all we have, and missed very much**

Rumbaar

Well the screenshot in the mods download section says about it.  The only difference would be if a child board had an outstanding moderation queue then it would look like "Child 1 (!)" instead of "Child 1".  But I'll look to include a sample screenshot in future.

Sorry can't really give a 'live' demo, as it would mean the test account would have to have moderation powers.  The mod in action can be viewed at : http://www.smf2.rumbaar.net for RC1 & http://www.rumbaar.net/test/ for 1.1
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Smoky "Rider" Blue

that is what im talking bout lol.. just to show me what it looks like, and you know, i like it.. great mod Rumbaar!!!  ;)
**Take the time to remember friendships and family.. Sometimes it's all we have, and missed very much**

victoryrock

Can someone please tell me where I am getting an error in my installation.

File Attached.

SgtMic

Anyway to change the background color?
Other than the white (for me), it's a great mod.
There is nothing more deadly than a US Marine and his rifle.
A close second is a US Marine and his K-BAR.
2/5 Fox Co.  (BlackHearts)
FAST Co. 5th Plt. (FIDO)

Rumbaar

@victoryrock you shouldn't be getting an error.  If so just run it through the parser and you should be able to find the spot you need to replace with the mod code.

@SgtMic You can edit the class value to match whatever you're using for your current custom template.  The first <td colspan="3" class="windowbg' values should control that.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

victoryrock

Sorry, what's a parser?

Quote from: Rumbaar on March 13, 2009, 12:55:37 AM
@victoryrock you shouldn't be getting an error.  If so just run it through the parser and you should be able to find the spot you need to replace with the mod code.

Advertisement: