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?

November 30, 2022, 05:13:16 PM

Login with username, password and session length
Members
  • Total Members: 3853
  • Latest: tty456
Stats
  • Total Posts: 193625
  • Total Topics: 21107
  • Online today: 70
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 0
Guests: 30
Total: 30

Author Topic: Show "last post time" to Freddy's snippet  (Read 6134 times)

0 Members and 1 Guest are viewing this topic.

Offline agent47

  • Full Member
  • ***
  • Posts: 103
Show "last post time" to Freddy's snippet
« on: March 12, 2011, 05:51:51 AM »
So this is a mod that was created by Freddy. I would like to know how I can show the last post time to this code. The area where the "last post time" should be displayed has to be right before the "last poster"

Code: [Select]
// *************
// The Functions
// *************


// Grabs recent topics...
function mot_NewTopics()
{
global $scripturl, $settings, $context, $txt;
   
$what = ssi_recentTopics('15',NULL,'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></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" border="0" /></a>';

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="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo '
</td>
</tr>
</table>
</div>';
}

Thanks in advance
« Last Edit: April 10, 2011, 05:01:02 AM by Freddy »

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Show "last post time" to Freddy's snippet
« Reply #1 on: March 14, 2011, 08:16:34 AM »
$what['time] should have the time of the post. You should be able to put that in the HTML where ever you need it.

Offline agent47

  • Full Member
  • ***
  • Posts: 103
Re: Show "last post time" to Freddy's snippet
« Reply #2 on: March 14, 2011, 10:10:10 AM »
That simple ha? Man! I really need to learn coding but hey I'm catching up as I've gone from scratch to running a successful forum :)

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Show "last post time" to Freddy's snippet
« Reply #3 on: March 14, 2011, 11:40:33 AM »
Well all you have to do is to look at the function in SSI.php. Scroll down until you see what is in the array that it is creating.

You can see what is available when the function is called.
Code: [Select]
// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>',
// Retained for compatibility - is technically incorrect!
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" />',
);

Offline agent47

  • Full Member
  • ***
  • Posts: 103
Re: Show "last post time" to Freddy's snippet
« Reply #4 on: April 09, 2011, 04:08:10 PM »
Sorry for the trouble Ich but as you know I'm a utter noob at this and support forums are all I depend on anyways so here is my code ->
Code: [Select]
function mot_NewTopics1()
{
global $scripturl, $settings, $context, $txt;

$what = ssi_recentTopics('15', array(2,30,4,3,5,39,40,42,43,45,41,6,34,33,35,25,32,36,17,8,11,10,9,12,15,14,13,20,37,31,29,38,16,19,27,24),'array');

echo '
<div class="tabsmenucontent" style="padding: 5px">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr class="catbg3">
<td valign="middle"></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" border="0" /></a>';

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="Last Post" title="Last Post" border="0" style="float: right;" /></a>';
}

echo '
</td>
</tr>
</table>
</div>';
}

I placed the $what['time] function like this:
Code: [Select]
<td class="windowbg2" valign="middle">', $what['time] '</td>
It didn't seem to work. Could you be generous enough to tell me how and where it should be placed amongst my code, sir.
I'd appreciate it greatly.

My site URL: http://www.superheroalliance.net

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Show "last post time" to Freddy's snippet
« Reply #5 on: April 09, 2011, 04:10:14 PM »
I realize I made a mistake in the code I posted which you seemed to copy lol, but do you see the difference between this?
$what['time]

And this?
$what['time']

Offline agent47

  • Full Member
  • ***
  • Posts: 103
Re: Show "last post time" to Freddy's snippet
« Reply #6 on: April 10, 2011, 04:35:39 AM »
I realize I made a mistake in the code I posted which you seemed to copy lol
Coz I'm stupid like that.
Anyways this is my line:
Code: [Select]
<td class="windowbg2" valign="middle">', $what['time'], '</td>Still not displaying time? :/

Offline Freddy

  • Moderator
  • *
  • Posts: 1617
    • AiDreams
Re: Show "last post time" to Freddy's snippet
« Reply #7 on: April 10, 2011, 04:41:44 AM »
Try :

Code: [Select]
<td class="windowbg2" valign="middle">', $topic['time'], '</td>

Offline agent47

  • Full Member
  • ***
  • Posts: 103
Re: Show "last post time" to Freddy's snippet
« Reply #8 on: April 10, 2011, 04:57:37 AM »
Wooooooooohoooooooooooooooo!!!! FREDDY!!!!! You the man!!
Also thanks Ichi..... You guys rule.....
Please mark topic as solved

Offline Freddy

  • Moderator
  • *
  • Posts: 1617
    • AiDreams
Re: Show "last post time" to Freddy's snippet
« Reply #9 on: April 10, 2011, 05:00:52 AM »
Haha, welcome  :)