// select the required parent board ID's
$board_parent_ids = array(1,3);
ehPortal_selectParentBoards($board_parent_ids, true, 'echo');
function ehPortal_selectParentBoards($board_ids, $boardImage, $output_method = 'echo')
{
global $context, $txt, $scripturl, $user_info, $modSettings, $settings, $smcFunc;
$context['html_headers'] .= '
<script>
$(document).ready(function() {
$(".customAaronBlockImg").hover(
function() {
$(this).css({"cursor" : "pointer", "filter" : "invert(1)"});
}, function() {
$(this).css({"cursor" : "normal", "filter" : "invert(0)"});
}
);
$(".customAaronBlockLink").hover(
function() {
$(this).css({"cursor" : "pointer", "mix-blend-mode" : "difference"});
}, function() {
$(this).css({"cursor" : "normal", "mix-blend-mode" : "normal"});
}
);
});
</script>';
$request = $smcFunc['db_query']('', '
SELECT
b.id_cat, b.name, b.num_topics, b.num_posts, b.id_board, b.child_level, b.id_parent, b.board_order, cat.cat_order,
cat.name AS cat_name
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS cat ON (cat.id_cat = b.id_cat)
WHERE {query_wanna_see_board} AND (b.id_parent IN ({array_int:include_parent_boards}) OR b.id_board IN ({array_int:include_parent_boards}))' . (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? '
AND b.id_board != {int:recycle_board}' : '') . ' AND b.child_level <= {int:child_lvl}
ORDER BY cat.cat_order ASC, b.board_order ASC',
array(
'include_parent_boards' => $board_ids,
'recycle_board' => !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : null,
'child_lvl' => 1,
)
);
list($parents, $boards, $count) = array(array(), array(), 0);
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$boards[] = array(
'id_cat' => $row['id_cat'],
'id_parent' => $row['id_parent'],
'cat_name' => $row['cat_name'],
'id' => $row['id_board'],
'child_lvl' => $row['child_level'],
'num_posts' => $row['num_posts'],
'num_topics' => $row['num_topics'],
'name' => $row['name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => !empty($boardImage) ? '<div style="display: inline-flex;vertical-align: middle;width: 1.5rem;max-width: 1.5rem;" class="centertext"><img onclick="location.href = \'' . $scripturl . '?board=' . $row['id_board'] . '.0\';" style="vertical-align: middle;max-width: 1rem;max-height: 1rem;" class="customAaronBlockImg centertext" title="' . $row['name'] . '" src="' . $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png" alt="->" /></div><div title="' . $row['name'] . '" onclick="location.href = \'' . $scripturl . '?board=' . $row['id_board'] . '.0\';" class="customAaronBlockLink" style="display: inline;padding-left: 0.5rem;vertical-align: middle;">' . $row['name'] . '</div>' : ('<div title="' . $row['name'] . '" onclick="location.href = \'' . $scripturl . '?board=' . $row['id_board'] . '.0\';" class="customAaronBlockLink" style="display: inline;padding-left: 0.05rem;vertical-align: middle;">' . $row['name'] . '</div>'),
'cat_href' => $scripturl . '?action=unread;c=' . $row['id_cat'],
'cat_link' => '<a href="' . $scripturl . '?action=unread;c=' . $row['id_cat'] . '" title="' . $row['cat_name'] . '">' . $row['cat_name'] . '</a>',
'parent_link' => '<div title="' . $row['name'] . '" onclick="location.href = \'' . $scripturl . '?board=' . $row['id_board'] . '.0\';" class="customAaronBlockLink" style="display: inline;padding-left: 0.05rem;vertical-align: middle;">' . $row['name'] . '</div>',
'image_path' => $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png',
'image' => '<div style="display: inline-flex;vertical-align: middle;width: 1.5rem;max-width: 1.5rem;"><img style="vertical-align: middle;max-width: 1rem;max-height: 1rem;" title="' . $row['name'] . '" src="' . $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png" alt="->" /></div>',
);
}
$smcFunc['db_free_result']($request);
if ($output_method != 'echo' || empty($boards))
return $boards;
echo '
<div style="display: flex;position: relative;">';
foreach ($boards as $sBoard) {
if (empty($sBoard['child_lvl']) && !in_array($sBoard['id'], $parents)) {
$parents[] = $sBoard['id'];
if (count($parents) > $count) {
echo '
</div>
</div>
<div style="width: inherit;min-height: 1.5rem !important;">
<div><span></span></div>
</div>';
}
$count++;
echo '
<div class="tborder">
<div class="cat_bar">
<h3 class="catbg">', $sBoard['parent_link'], '</h3>
</div>
<div class="windowbg">';
}
elseif (!empty($sBoard['child_lvl']))
echo '
<div style="padding-bottom: 0.33rem;">
<div style="display: inline;">', $sBoard['link'], '</div>
</div>';
else
echo '
</div>
</div>';
}
echo '
</div>';
}
ORDER BY b.board_order',
$board_category_ids = array(1,2);
$parent_board_ids = array(1,2);
// select the required board category ID's
$board_category_ids = array(1,2);
ehPortal_selectBoards($board_category_ids, true, 'echo');
function ehPortal_selectBoards($cat_ids, $boardImage, $output_method = 'echo')
{
global $context, $txt, $scripturl, $user_info, $modSettings, $settings, $smcFunc;
$context['html_headers'] .= '
<script>
$( document ).ready(function() {
$(".customAaronBlockImg").hover(
function() {
$(this).css({"cursor" : "pointer", "filter" : "invert(1)"});
}, function() {
$(this).css({"cursor" : "normal", "filter" : "invert(0)"});
}
);
$(".customAaronBlockCatId").hover(
function() {
$(this).css({"cursor" : "pointer", "mix-blend-mode" : "difference"});
}, function() {
$(this).css({"cursor" : "normal", "mix-blend-mode" : "normal"});
}
);
});
</script>';
$request = $smcFunc['db_query']('', '
SELECT
b.id_cat, b.name, b.num_topics, b.num_posts, b.id_board,
cat.name AS cat_name
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS cat ON (cat.id_cat = b.id_cat)
WHERE {query_wanna_see_board} AND b.id_cat IN ({array_int:include_cats})' . (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? '
AND b.id_board != {int:recycle_board}' : '') . '
ORDER BY b.id_cat ASC, b.id_board ASC',
array(
'include_cats' => $cat_ids,
'recycle_board' => !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : null,
)
);
list($cats, $boards) = array(array(), array());
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$boards[] = array(
'id_cat' => $row['id_cat'],
'cat_name' => $row['cat_name'],
'id' => $row['id_board'],
'num_posts' => $row['num_posts'],
'num_topics' => $row['num_topics'],
'name' => $row['name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => !empty($boardImage) ? '<div style="display: inline-flex;vertical-align: middle;width: 1.5rem;max-width: 1.5rem;" class="centertext"><img onclick="location.href = \'' . $scripturl . '?board=' . $row['id_board'] . '.0\';" style="vertical-align: middle;max-width: 1rem;max-height: 1rem;" class="customAaronBlockImg centertext" title="' . $row['name'] . '" src="' . $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png" alt="->" /></div><div style="display: inline;padding-left: 0.5rem;vertical-align: middle;"><a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '">' . $row['name'] . '</a></div>' : ('<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '">' . $row['name'] . '</a>'),
'cat_href' => $scripturl . '?action=unread;c=' . $row['id_cat'],
'cat_link' => '<a href="' . $scripturl . '?action=unread;c=' . $row['id_cat'] . '" title="' . $row['cat_name'] . '">' . $row['cat_name'] . '</a>',
'image_path' => $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png',
'image' => '<div style="display: inline-flex;vertical-align: middle;width: 1.5rem;max-width: 1.5rem;"><img style="vertical-align: middle;max-width: 1rem;max-height: 1rem;" title="' . $row['name'] . '" src="' . $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png" alt="->" /></div>',
);
}
$smcFunc['db_free_result']($request);
if ($output_method != 'echo' || empty($boards))
return $boards;
echo '
<div style="display: table;position: relative;" class="ssi_table">';
foreach ($boards as $sBoard) {
if (!in_array($sBoard['id_cat'], $cats)) {
$cats[] = $sBoard['id_cat'];
if (count($cats) > 1) {
echo '
<div style="display: flex;width: inherit;min-height: 1.5rem !important;">
<div><span></span></div>
</div>';
}
echo '
<div style="display: table-row;padding-bottom: 0.15rem;">
<div class="customAaronBlockCatId" style="display: table-cell;text-align: left;text-decoration: underline;">', $sBoard['cat_link'], '</div>
<div style="display: table-cell;text-align: left;padding-left: 2rem;text-decoration: underline;">', $txt['board_topics'], '</div>
<div style="display: table-cell;text-align: left;padding-left: 2rem;text-decoration: underline;">', $txt['posts'], '</div>
</div>';
}
echo '
<div style="display: table-row;padding-bottom: 0.33rem;">
<div style="display: table-cell;">', $sBoard['link'], '</div>
<div style="display: table-cell;text-align: right;padding-left: 2rem;">', comma_format($sBoard['num_topics']), '</div>
<div style="display: table-cell;text-align: right;padding-left: 2rem;">', comma_format($sBoard['num_posts']), '</div>
</div>';
}
echo '
</div>';
}
// select the required board category ID's
$board_category_ids = array(1,2);
ehPortal_selectBoards($board_category_ids, true, 'echo');
function ehPortal_selectBoards($cat_ids, $boardImage, $output_method = 'echo')
{
global $txt, $scripturl, $user_info, $modSettings, $settings, $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT
b.id_cat, b.name, b.num_topics, b.num_posts, b.id_board,
cat.name AS cat_name
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS cat ON (cat.id_cat = b.id_cat)
WHERE {query_wanna_see_board} AND b.id_cat IN ({array_int:include_cats})' . (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? '
AND b.id_board != {int:recycle_board}' : '') . '
ORDER BY b.id_cat ASC, b.id_board ASC',
array(
'include_cats' => $cat_ids,
'recycle_board' => !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : null,
)
);
list($cats, $boards) = array(array(), array());
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$boards[] = array(
'id_cat' => $row['id_cat'],
'cat_name' => $row['cat_name'],
'id' => $row['id_board'],
'num_posts' => $row['num_posts'],
'num_topics' => $row['num_topics'],
'name' => $row['name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => !empty($boardImage) ? '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '"><div class="child_icons" style="background-image: url(\'' . $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png\');background-size: cover;"></div></a><div style="display: inline;padding-left: 1rem;"><a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '">' . $row['name'] . '</a></div>' : ('<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '">' . $row['name'] . '</a>'),
'cat_href' => $scripturl . '?action=unread;c=' . $row['id_cat'],
'cat_link' => '<a href="' . $scripturl . '?action=unread;c=' . $row['id_cat'] . '" title="' . $row['cat_name'] . '">' . $row['cat_name'] . '</a>'
);
}
$smcFunc['db_free_result']($request);
if ($output_method != 'echo' || empty($boards))
return $boards;
echo '
<div style="display: table;position: relative;" class="ssi_table">';
foreach ($boards as $sBoard) {
if (!in_array($sBoard['id_cat'], $cats)) {
$cats[] = $sBoard['id_cat'];
if (count($cats) > 1) {
echo '
<div style="display: flex;width: inherit;min-height: 1.5rem !important;">
<div><span></span></div>
</div>';
}
echo '
<div style="display: table-row;">
<div style="display: table-cell;text-align: left;text-decoration: underline;cursor: pointer;">', $sBoard['cat_link'], '</div>
<div style="display: table-cell;text-align: left;padding-left: 2rem;">', $txt['board_topics'], '</div>
<div style="display: table-cell;text-align: left;padding-left: 2rem;">', $txt['posts'], '</div>
</div>';
}
echo '
<div style="display: table-row;">
<div style="display: table-cell;">', $sBoard['link'], '</div>
<div style="display: table-cell;text-align: right;padding-left: 2rem;">', comma_format($sBoard['num_topics']), '</div>
<div style="display: table-cell;text-align: right;padding-left: 2rem;">', comma_format($sBoard['num_posts']), '</div>
</div>';
}
echo '
</div>';
}
// select the required board category ID's
$board_category_ids = array(1,2);
ehPortal_selectBoards($board_category_ids, true, 'echo');
function ehPortal_selectBoards($cat_ids, $boardImage, $output_method = 'echo')
{
global $txt, $scripturl, $user_info, $modSettings, $settings, $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT
b.id_cat, b.name, b.num_topics, b.num_posts, b.id_board,
cat.name AS cat_name
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS cat ON (cat.id_cat = b.id_cat)
WHERE {query_wanna_see_board} AND b.id_cat IN ({array_int:include_cats})' . (!empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? '
AND b.id_board != {int:recycle_board}' : '') . '
ORDER BY b.id_cat ASC, b.id_board ASC',
array(
'include_cats' => $cat_ids,
'recycle_board' => !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : null,
)
);
list($cats, $boards) = array(array(), array());
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$image = !empty($boardImage) ? '<div class="child_icons" style="display: inline;background-image: url(' . $settings['default_theme_url'] . '/images/' . $row['id_board'] . '.png);"></div>' : $row['name'];
$boards[] = array(
'id_cat' => $row['id_cat'],
'cat_name' => $row['cat_name'],
'id' => $row['id_board'],
'num_posts' => $row['num_posts'],
'num_topics' => $row['num_topics'],
'name' => $row['name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '">' . $image . '</a>',
'cat_href' => $scripturl . '?action=unread;c=' . $row['id_cat'],
'cat_link' => '<a href="' . $scripturl . '?action=unread;c=' . $row['id_cat'] . '" title="' . $row['cat_name'] . '">' . $row['cat_name'] . '</a>'
);
}
$smcFunc['db_free_result']($request);
if ($output_method != 'echo' || empty($boards))
return $boards;
echo '
<div style="display: table;position: relative;" class="ssi_table">';
foreach ($boards as $sBoard) {
if (!in_array($sBoard['id_cat'], $cats)) {
$cats[] = $sBoard['id_cat'];
if (count($cats) > 1) {
echo '
<div style="display: flex;width: inherit;min-height: 1.5rem !important;">
<div><span></span></div>
</div>';
}
echo '
<div style="display: table-row;">
<div style="display: table-cell;text-align: left;text-decoration: underline;cursor: pointer;">', $sBoard['cat_link'], '</div>
<div style="display: table-cell;text-align: left;padding-left: 2rem;">', $txt['board_topics'], '</div>
<div style="display: table-cell;text-align: left;padding-left: 2rem;">', $txt['posts'], '</div>
</div>';
}
echo '
<div style="display: table-row;">
<div style="display: table-cell;">', $sBoard['link'], '</div>
<div style="display: table-cell;text-align: right;padding-left: 2rem;">', comma_format($sBoard['num_topics']), '</div>
<div style="display: table-cell;text-align: right;padding-left: 2rem;">', comma_format($sBoard['num_posts']), '</div>
</div>';
}
echo '
</div>';
}
Quote from: Chen Zhen on June 25, 2023, 04:54:39 PMJust so I understand correctly and to be clear. You are referring to boatd categories and their child boards?
You want to only specify the board categories and have it list their child boards? If I am correct do you want all child boards for each category or just 4 max as your first post implies?
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '"><div class="child_icons" style="background-image: url(/images/' . $row['id_board'] . '.png);"></div></a> <span><a href="' . $scripturl . '?board=' . $row['id_board'] . '.0" title="' . $row['name'] . '">' . $row['name'] . '</a></span>',
// select the required board ID's
$include_boards = array(1);
echo '
<div id="board_', $board['id'], '_children" class="children">
', implode(' ', $children), '
</div>';
}
// select the required board ID's
$include_boards = array(1,2,3,4);