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

Recent

Welcome to TinyPortal. Please login or sign up.

May 14, 2024, 11:50:56 PM

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: 176
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 104
  • Total: 104

"recent topics" in SMF style

Started by Lesmond, August 17, 2005, 12:01:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bloc

Technodragon73, try to find the ['newtime'] in the code, and exchange it with ['new_from'].

technodragon73

Quote from: Bloc on April 20, 2006, 12:07:52 PM
Technodragon73, try to find the ['newtime'] in the code, and exchange it with ['new_from'].

That fixed it...thank you!

akulion

Quote from: BlueSteel on March 29, 2006, 01:07:56 AM
ok here it is updated and re-organised and re-formatted

It should now only display the headings once


// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';





bluesteel THANK YOU SO MUCH I have been dying for this snippet of code for ages!

UR THE BOMB!

deniz

recenttopics shows about 30-40 last topics..

why ?
how can topics count increase. ?
i need according to time.. like last day, last week, last month etc. is it possible ?


bloc

Recent topics always count from the very latest post and backwards. To set a date/timespan would mean to have to adjust the routine somewhat.

Maybe something for an "archive" sort of mod/function for posts/topics?

Blue Steel

What you could do is change the number of msgs to be in the fetching array to a larger number and then scan for those msgs by date... and only pirint out those ones.. that makes for a way more complicate block of code .. but honestly you can do anything you want if you know how (which i don't .. I just tweak others code.. i'm not smart enough to write it out fully by myself)

akulion

#86
i was wondering is it possible to have a modification of this code so that it does the following?

1 - Only displays topics from a particular board
2 - ONLY displays new topics (from the selected board) IF they are new topics (dosent loop topics on replies)

I ask cos I am making a "in the news" board in which I and members will post the daily news from around the world and it would appear on the TP index.

Thanks

bloc

Both thinsg could be done in the actual mysql_call. It means a custom ssi_recentTopics function though.

akulion: for just one baord is easy, but the other item I am not exactly sure what you mean.."new topics" as in unread? or as in newer than a set timespan?

akulion

by new topics I mean: A topic which has been posted just recently in that board, but replying to that post does not bring it to top on the "recent post block"

So basically ONLY when the topic is initially posted it appears in the block - but afterwards no matter how many replies it gets it dosent appear there - but can only be overtaken by newer posts/threads made

bloc

I see. So just sorting on created dates then, not on last replied date. That would mean even a simpler sql call.