News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Default Theme Rendition (1.x)

Started by Biology Forums, August 08, 2011, 07:12:06 PM

Previous topic - Next topic

NHWD

I liked the blog and the trending topics. Those are the major mods I noticed.

Biology Forums

Not sure how good you are with codes, but here's the code I used to generate the trends. The function pulls up the most popular topics in the past 24 hours, 48 hours, and 72 hours.

function trending($limit = 1, $exclude_boards = null, $day = 1)
{
global $db_prefix, $modSettings, $user_info, $context;

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$time = time();

if($day == 1)
{
$time2 = $time - 86400;
$timing = 24;
}

elseif($day == 2)
{
$time2 = $time - (86400*2);
$timing = 48;
}
elseif($day == 3)
{
$time2 = $time - (86400*3);
$timing = 72;
}
else
{
$time2 = $time - 86400;
$timing = 24;
}
$request = db_query("
SELECT COUNT(mes.id_topic) as t, mes.id_topic, mes2.subject,
b.id_board, b.name
FROM {$db_prefix}messages AS mes
LEFT JOIN {$db_prefix}boards as b ON (mes.id_board = b.id_board)
LEFT JOIN {$db_prefix}topics as top ON (mes.id_topic = top.id_topic)
LEFT JOIN {$db_prefix}messages AS mes2 ON (mes2.id_msg = top.ID_FIRST_MSG)
WHERE mes.posterTime <= $time
AND mes.posterTime >= $time2" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
AND $user_info[query_see_board]
GROUP BY id_topic
ORDER BY t DESC, id_topic DESC
LIMIT $limit", __FILE__, __LINE__);

$context['PopTopics'] = array();

while ($row = mysql_fetch_assoc($request))
{
$context['PopTopics'][] = array(
'coll' => $row['t'],
'id_topic' => $row['id_topic'],
'subject' => $row['subject'],
'board_id' => $row['id_board'],
'board_name' => $row['name'],
);
}
mysql_free_result($request);

foreach ($context['PopTopics'] as $what)
{
echo'<div class="round5px tbordertp" style="margin-bottom: 1ex;"><div class="round5px windowbgx""><table width="100%" cellpadding="4" cellspacing="0"><tr><td><span class="logreg"><a class="largetext" href="http://biology-forums.com/index.php?topic=',$what['id_topic'], '#top">', $what['subject'], '</a></span> <span class="smalltext">in <a href="http://biology-forums.com/index.php?board=', $what['board_id'], '">', $what['board_name'], '</a></span><br/><span class="midtext"><b>', $what['coll'], '</b> ',$what['coll'] != 1 ? 'posts' : 'post',' made in the past ',$timing,' hours</span></td></tr></table>
</div></div>';
}
}


Here's an example of it being used, like an SSI function.

trending(10, array(29, 44, 17, 38, 53, 68), 1);

- Show 10 posts.
- Show posts found primarily in board 29, 44, 17, 38, 53, and 68.
- Show 24 hours, 1 day.

Recall that my forum is using 1.x, therefore, you will need someone to adjust it according to your version.

The blog, on the other hand, originates from an abandoned mod that was popular years ago. I ended up customizing its code to fit my forum.

Biology Forums

Default 1.x Version 2.0 is now in development.

- Font-awesome in full effect
- Image icons reduced by 90%
- Cleaner layout
- Gradients created entirely with CSS.
- More to come...

Advertisement: