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

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 05:23:21 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 310
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 286
  • Total: 286

"recent topics" in SMF style

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

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

Zetan

#480
I've read through this a while back and I'm using one of the codes from somewhere in this thread. I'm happy with the layout of it, it's tidy. There are a few issues with it that I've been meaning to ask for help with.


  • Topic title. This should take you to the "First" post in the topic, not the "Newest / latest / most recent" (whichever way you look at it).
  • 'NEW' icon. This should take you to the "Newest" post in the topic.
  • I have aligned the New icon right. I have tried to make it Absmiddle as well, so that it is in line with the Topic Title, with no success, it aligns right, but under the title. Perhaps there is a better location for it.
  • Last Post icon works correctly.
  • After viewing content selected from the "recent topics", Mine is on the Home Page.. it should cancel the New Topic / Post icons listed in the board index, it doesn't. I think this may be the way the SSI is working.
Here is the code


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

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & 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="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></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>';


I'm no code expert and I have spent time with it, sometimes it's just easier to ask  :buck2:


Thanks

Ken.

Very good points Zetan, those changes would be nice to have. :up:

I'm using the version that lets you pick the board(s) you want displayed, so hopefully if someone is able to fix the code it will work for that version as well. :)
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

alhaudhie

Quote from: Zetan on March 13, 2009, 04:44:00 AM
I've read through this a while back and I'm using one of the codes from somewhere in this thread. I'm happy with the layout of it, it's tidy. There are a few issues with it that I've been meaning to ask for help with.


  • Topic title. This should take you to the "First" post in the topic, not the "Newest / latest / most recent" (whichever way you look at it).
  • 'NEW' icon. This should take you to the "Newest" post in the topic.
  • I have aligned the New icon right. I have tried to make it Absmiddle as well, so that it is in line with the Topic Title, with no success, it aligns right, but under the title. Perhaps there is a better location for it.
  • Last Post icon works correctly.
  • After viewing content selected from the "recent topics", Mine is on the Home Page.. it should cancel the New Topic / Post icons listed in the board index, it doesn't. I think this may be the way the SSI is working.
Here is the code


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

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & 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="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></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>';


I'm no code expert and I have spent time with it, sometimes it's just easier to ask  :buck2:


Thanks

with this code.. how can i add msg preview on mouse over...

JPDeni

I hadn't seen Zetan's post. Let's see if I can work through his questions.

1. In order to get the topic title to take you to the first post, the link will have to be built instead of just using what SSI.php gives.

Change

echo '<tr><td class="windowbg" valign="middle">', $topic['link'];


to


echo '<tr><td class="windowbg" valign="middle"><a href="' . $scripturl . '?topic=' . $topic['topic']' . $topic['subject'] . '</a>';


2. I'm not sure what the "new" icon does at the moment. If it doesn't act the way you want, you might try changing

      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


to


      echo '<a href="', $topic['href'] . '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


3. I don't know how to align the graphic differently.

4. Good. :)

5. I don't know how to change that problem.

--------------------------------------------------------------

Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)

alhaudhie

#484
Quote from: JPDeni on March 29, 2009, 12:58:13 AM
Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)

Yes... hope one day anybody can make it....

maybe like this


alhaudhie

How can i make alternate background for the first and the other topic?
global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & 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="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></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>';

IchBin

Do you mean to alternate background colors every other topic row?

alhaudhie


JPDeni

Change


foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'];


to


$bg=0;
foreach ($what as $topic)
  {
    echo '<tr>';
    if ($bg == 0) {
      echo '<td class="windowbg" valign="middle">';
      $bg = 1;
    }
    else {
      echo '<td class="windowbg2" valign="middle">';
      $bg = 0;
    }
    echo $topic['link'];

alhaudhie