Customizing SMF > Modifications and Packages

Childboards as Dropdown

(1/51) > >>

Labradoodle-360:
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.

heinandar:
á‚ŠThis is the original code of BoardIndexTemplate.php of DilberMC. I can't figure out.


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

--- End code ---

Rumbaar:
For DilberMC

Find:

--- Code: --- // 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>';
}
--- End code ---

Replace:

--- Code: --- // 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>';
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version