Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 12, 2022, 06:44:23 PM

Login with username, password and session length
Members
  • Total Members: 3842
  • Latest: Kokoro
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 50
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 45
Total: 45

Author Topic: "recent topics" in SMF style  (Read 266182 times)

0 Members and 2 Guests are viewing this topic.

Offline Zetan

  • Friends
  • *
  • Posts: 3471
Re: "recent topics" in SMF style
« Reply #480 on: March 12, 2009, 10:44:00 PM »
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' title='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

Code: [Select]
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
« Last Edit: March 12, 2009, 10:55:50 PM by Zetan »

Offline Ken.

  • Support Team
  • *
  • Posts: 4362
    • Our FamilyForum
Re: "recent topics" in SMF style
« Reply #481 on: March 13, 2009, 06:52:35 AM »
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

  • Guest
Re: "recent topics" in SMF style
« Reply #482 on: March 28, 2009, 06:34:38 PM »
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' title='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

Code: [Select]
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

  • Guest
Re: "recent topics" in SMF style
« Reply #483 on: March 28, 2009, 06:58:13 PM »
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
Code: [Select]
echo '<tr><td class="windowbg" valign="middle">', $topic['link'];

to

Code: [Select]
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
Code: [Select]
      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

Code: [Select]
      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

  • Guest
Re: "recent topics" in SMF style
« Reply #484 on: March 29, 2009, 12:28:33 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

« Last Edit: March 29, 2009, 12:33:44 AM by Mrcare »

alhaudhie

  • Guest
Re: "recent topics" in SMF style
« Reply #485 on: March 30, 2009, 03:37:01 PM »
How can i make alternate background for the first and the other topic?
Code: [Select]
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>';

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: "recent topics" in SMF style
« Reply #486 on: March 30, 2009, 03:42:56 PM »
Do you mean to alternate background colors every other topic row?

alhaudhie

  • Guest
Re: "recent topics" in SMF style
« Reply #487 on: March 30, 2009, 03:49:36 PM »
yes... that is what i mean...

JPDeni

  • Guest
Re: "recent topics" in SMF style
« Reply #488 on: March 30, 2009, 05:52:28 PM »
Change

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

to

Code: [Select]
$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

  • Guest
Re: "recent topics" in SMF style
« Reply #489 on: March 30, 2009, 11:48:04 PM »
tq...nice code. solved.