Hello! I have a SSI code for recent topic. How can I implement the icon "new.gif" to the code?
Should I add this in some way? ', $post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>', '
$topics = ssi_recentTopics(10, null, null, 'array');
echo '<table border="0" width="100%">
<tr>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Topic</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>new.gif here</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Board</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>By</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Read/posts</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Date</b></th>
</tr>';
foreach ($topics as $this_topic)
echo '<tr><td>', $this_topic['link'], '</td>
<td>', $this_topic['board']['link'], '</td>
<td>', $this_topic['poster']['link'], '</td>
<td>', $this_topic['views'], '/', $this_topic['replies'], '</td>
<td>', $this_topic['time'], '</td></tr>';
echo '
</table>';
Hi, basically change the $post to $this_topic and add it after the link so it's something like this:
echo '<tr><td>', $this_topic['link'], ($this_topic['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $this_topic['topic'] . '.msg' . $this_topic['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>'), '</td>
That is assuming you want it to appear after the link to the topic. O:)
(not tested)
Thanks a lot, Kays! Now the icon shows behind every topic if it's read or not. It should be shown only on unread posts.
The code I'm using now:
$topics = ssi_recentTopics(10, null, null, 'array');
echo '<table border="0" width="100%">
<tr>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Topic</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>new.gif here</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Board</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>By</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Read/posts</b></th>
<td bgcolor="#0078A7"><font color="#FFFFFF"><b>Date</b></th>
</tr>';
foreach ($topics as $this_topic)
echo '<tr><td>', $this_topic['link'], ($this_topic['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $this_topic['topic'] . '.msg' . $this_topic['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>'), '</td>
<td>', $this_topic['board']['link'], '</td>
<td>', $this_topic['poster']['link'], '</td>
<td>', $this_topic['views'], '/', $this_topic['replies'], '</td>
<td>', $this_topic['time'], '</td></tr>';
echo '
</table>';
The new.gif icon is showing up even if a member is not logged in.
Should this be added somewhere???
if (!$topic['new'] && $context['user']['is_logged'])
Hmm, the conditional in the original code you posted is the reverse of how it should be. ::)
Either try:
echo '<tr><td>', $this_topic['link'], (!$this_topic['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $this_topic['topic'] . '.msg' . $this_topic['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>'), '</td>
Or
echo '<tr><td>', $this_topic['link'], ($this_topic['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $this_topic['topic'] . '.msg' . $this_topic['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>'), '</td>
To test it you should post using a different account to your admin account. Unless you are testing this on a busy forum.