24 saat popüler konular

Başlatan kapt, 02 Eyl 2021 15:06

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

*

  1. 37

  2. 10

  3. 3

Resimdekiler gibi Son İletiler bölümünün üstüne son 24 saatin popüler konularını nasıl yapabilirim?




*

  1. 1,176

  2. 116

  3. 387
Hazırda daha önce kodumuz varmış.

Alıntı yapılan: snrj - 15 Kas 2017 01:00function son1($timestamp_now){
global $context, $settings, $options, $txt, $scripturl, $modSettings, $smcFunc, $user_info;


$timestamp =$timestamp_now;


//smf.konusal.com En cok goruntulenenler top 10
$topic_ids = array();
$topic_view_result = $smcFunc['db_query']('', '
SELECT m.subject, t.num_views, t.id_board, t.id_topic, b.name, m.poster_time, m.icon
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : '') . ')
WHERE m.poster_time > '.$timestamp.' AND {query_see_board}' . (!empty($topic_ids) ? '
AND t.id_topic IN ({array_int:topic_list})' : ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '')) . '
ORDER BY t.num_views DESC
LIMIT 5',
array(
'topic_list' => $topic_ids,
'recycle_board' => $modSettings['recycle_board'],
'is_approved' => 1,
)
);
$context['top_topics_views'] = array();
$max_num_views = 1;
while ($row_topic_views = $smcFunc['db_fetch_assoc']($topic_view_result))
{
censorText($row_topic_views['subject']);
$context['top_topics_views'][] = array(
'id' => $row_topic_views['id_topic'],
'board' => array(
'id' => $row_topic_views['id_board'],
'name' => $row_topic_views['name'],
'href' => $scripturl . '?board=' . $row_topic_views['id_board'] . '.0',
'link' => '<a class="knslorta" href="' . $scripturl . '?board=' . $row_topic_views['id_board'] . '.0">' . $row_topic_views['name'] . '</a>'
),
'subject' => $row_topic_views['subject'],
'num_views' => $row_topic_views['num_views'],
'href' => $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row_topic_views['id_topic'] . '.0">' . $row_topic_views['subject'] . '</a>',
'time' => timeformat($row_topic_views['poster_time']),
'timestamp' => forum_time(true, $row_topic_views['poster_time']),
);

if ($max_num_views < $row_topic_views['num_views'])
$max_num_views = $row_topic_views['num_views'];
}
$smcFunc['db_free_result']($topic_view_result);

foreach ($context['top_topics_views'] as $i => $topic)
{
$context['top_topics_views'][$i]['post_percent'] = round(($topic['num_views'] * 100) / $max_num_views);
$context['top_topics_views'][$i]['num_views'] = comma_format($context['top_topics_views'][$i]['num_views']);
}


echo '
<table class="table_list">
<tbody class="header">
<tr>
<td colspan="4">
<div class="cat_bar">
<div class="catbg"></div>
</div>
</td>
</tr>
</tbody>
<tbody>
<tr class="cat_bar_alt">
<td></td>
<td>Bölüm adı</td>
<td>Mesajlar&Konular</td>
<td>Son Mesaj</td>
</tr>
</tbody>';

foreach ($context['top_topics_views'] as $topic){
echo '
<tr class="windowbg">
<td class="">', $topic['link'], '</td>
<td class="">', $topic['board']['link'], '</td>
<td class="">', $topic['time'], '</td>
<td class="">', snrjTime($topic['timestamp']), '</td>
</tr>';

}
echo '</tbody>
</table>';

}
function snrjTime($UnixTimeStamp)
{
global $txt;
$Seconds = time() - $UnixTimeStamp;
if ($Seconds < 2592000) {
if ($Seconds >= 86400) {
return round($Seconds / 86400, 0) . '&nbsp;gün önce';
} else if ($Seconds >= 3600) {
return round($Seconds / 3600, 0) . '&nbsp; saat önce';
} else if ($Seconds >= 60) {
return round($Seconds / 60, 0) . '&nbsp;dakika önce';
} else if ($Seconds < 0) {
return 'çok taze';
} else {
return ($Seconds + 1) . '&nbsp; saniye';
}
} else {
return date("d-m-Y", $UnixTimeStamp);
}
}

global $context, $settings, $options, $txt, $scripturl, $modSettings, $smcFunc, $user_info;

$timestamp_now = time()-3600;
$zaman1 = son1($timestamp_now);

$timestamp_now = time()-14400;
$zaman2 = son1($timestamp_now);

$timestamp_now = time()-86400;
$zaman3 = son1($timestamp_now);
Bunu kullanarak boardindex.template info_center kısmında ekleme yapabilirsin.


MENU ×