Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Dylert - marraskuu 19, 2013, 05:23:36 IP

Otsikko: new.gif in SSI recent topics
Kirjoitti: Dylert - marraskuu 19, 2013, 05:23:36 IP
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>';

Otsikko: Re: new.gif in SSI recent topics
Kirjoitti: Kays - marraskuu 19, 2013, 07:27:04 IP
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)

Otsikko: Re: new.gif in SSI recent topics
Kirjoitti: Dylert - marraskuu 20, 2013, 04:26:17 AP
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>';
Otsikko: Re: new.gif in SSI recent topics
Kirjoitti: Dylert - marraskuu 20, 2013, 05:14:22 IP
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'])
Otsikko: Re: new.gif in SSI recent topics
Kirjoitti: Kays - marraskuu 20, 2013, 07:36:07 IP
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.