
Re: New Blocks: Highest Rated Topics/ Most Read Topics
It creates a block in php that it executes this query, and will show 5 more seen:
<?php
$except_forums = build_exclusion_forums_list();
$sql = "SELECT t.* FROM " . TOPICS_TABLE . " AS t NOT IN (" . $except_forums . ") ORDER BY t.topic_views DESC LIMIT 0, 5";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not query most view topics information', '', __LINE__, __FILE__, $sql);
}
$number_topics = $db->sql_numrows($result);
$topic_row = array();
while ($row = $db->sql_fetchrow($result))
{
$topic_row[] = $row;
}
for ($i = 0; $i < $number_topics; $i++)
{
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
if (!empty($orig_word))
{
$recent_topic_row[$i]['topic_title'] = (!empty($recent_topic_row[$i]['topic_title'])) ? preg_replace($orig_word, $replacement_word, $recent_topic_row[$i]['topic_title']) : '';
}
$topic_title = htmlspecialchars_clean($recent_topic_row[$i]['topic_title']);
$template->assign_block_vars('most_view_topic', array(
'U_TITLE' => append_sid(VIEWTOPIC_MG . '?' . POST_FORUM_URL . '=' . $recent_topic_row[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $recent_topic_row[$i]['topic_id'] . '&' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#p' . $recent_topic_row[$i]['post_id'],
'L_TITLE' => $topic_title,
)
);
}
?>
The .tpl:
<table class="empty-table" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left">
<ul>
<!-- BEGIN most_view_topic -->
<li><a href="{most_view_topics.U_TITLE}" title="{most_view_topics.L_TITLE}">{most_view_topics.L_TITLE}</a>
<!-- END most_view_topic -->
</ul>
</td>
</tr>
</table>
it is a thing thrown on the moment, I do not know if it works, but trying a little, you would have to succeed to us, same thing for the others. Enough that orders for the other fields that you want
Sorry for my bad English