TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 15, 2024, 04:03:02 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,188
  • Total Topics: 21,220
  • Online today: 130
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 77
  • Total: 77

Few blocks from TP causing my site to eat resources.

Started by Ricky., December 14, 2007, 07:26:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jacortina

But, if the 10th 'newest' topic is a week old, a month old or a year old, it's still the 10th newest topic. Just means nobody has started many topics in all that time.

Of course, it's only the 10 newest topics that a user can SEE and excludes the recycle bin.

bloc

Yes, it is.

I don't know what the member here wants, but I would probably want to show just the newest..and a month old topic isn't "new" anymore. ;)

Ricky.

Quote from: J.A.Cortina on December 20, 2007, 04:44:25 PM
"Newest Topics" might be more appropriate:

global $scripturl, $settings, $db_prefix, $user_info, $modSettings;

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 4px 0 0;" />';

$list_count = 5;

$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname
FROM ({$db_prefix}messages AS ms, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE   t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY t.ID_FIRST_MSG DESC LIMIT " . $list_count, __FILE__, __LINE__);

echo '
<table border="0">';

while ($row = mysql_fetch_assoc($request))
echo ' <tr>
<td valign="middle">', $bullet, '<a href="',  $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen"><b>', $row['firstSubject'], '</b></a></td>
</tr>';

echo '
</table border>';

This is what I need, thanx. Did little workaround and it worked.

Bloc, timelimit is good idea and can be used to show topics started in a particular span. Here member (that is me) just wanted Newest / Latest topic created irrespective of replies or time and that is what I got :)

Cheers!