global $context, $smcFunc, $scripturl, $settings, $txt, $modSettings;
// Number of promoted topics to show
$promoted_limit = 15;
// Check if there are promoted topics
if (!empty($context['TPortal']['frontpage_topics']))
{
$request = $smcFunc['db_query']('', '
SELECT t.id_topic, t.id_first_msg, m.subject, m.id_member, m.poster_name, m.poster_time
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
WHERE t.id_topic IN ({array_int:topics})
ORDER BY m.poster_time DESC
LIMIT {int:limit}',
array(
'topics' => array_map('intval', explode(',', $context['TPortal']['frontpage_topics'])),
'limit' => $promoted_limit,
)
);
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$topics[] = $row;
}
$smcFunc['db_free_result']($request);
echo '
<div style="display: flex; flex-wrap: wrap; gap: 1rem; width: 100%;">';
foreach ($topics as $topic)
{
$member_id = (int) $topic['id_member'];
$avatar_img = '';
if (!empty($member_id)) {
// Query avatar info directly
$request2 = $smcFunc['db_query']('', '
SELECT avatar, email_address
FROM {db_prefix}members
WHERE id_member = {int:id_member}
LIMIT 1',
array(
'id_member' => $member_id,
)
);
if ($request2) {
if ($row2 = $smcFunc['db_fetch_assoc']($request2)) {
$avatar_data = set_avatar_data(array(
'avatar' => $row2['avatar'],
'email' => $row2['email_address'],
));
if (!empty($avatar_data['image'])) {
$avatar_img = $avatar_data['image'];
}
}
$smcFunc['db_free_result']($request2);
}
}
// Fallback default avatar
if (empty($avatar_img)) {
$avatar_img = '<img src="' . $settings['images_url'] . '/default_avatar.png" alt="" style="width:50px;height:50px;border-radius:50%;">';
}
echo '
<div style="display: flex; align-items: center; border: 1px solid #ccc; border-radius: 8px; padding: 10px; width: 300px; box-sizing: border-box;">
<div style="flex-shrink: 0; margin-right: 10px;">
<a href="', $scripturl, '?action=profile;u=', $member_id, '">', $avatar_img, '</a>
</div>
<div style="flex-grow: 1;">
<div style="font-weight: bold; margin-bottom: 5px;">
<a href="', $scripturl, '?topic=', $topic['id_topic'], '.0">', $topic['subject'], '</a>
</div>
<div style="font-size: smaller; color: #666;">', $txt['by'], ' ', htmlspecialchars($topic['poster_name']), ' | ', timeformat($topic['poster_time']), '</div>
</div>
</div>';
}
echo '
</div>';
}
else
{
echo '<div class="smalltext">No promoted topics available.</div>';
}
Quote from: @rjen on December 17, 2018, 03:24:11 PMI agree this is not very intuitive, especially since the 'Promote to frontpage' button is showing even when the chosen frontpage layout will not show the topics.
I think we should only show the button if the button can actually be used. I can fix this in the next bugfix release...
Page created in 0.027 seconds with 17 queries.