Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: aw06 on June 20, 2009, 03:54:59 PM

Title: adding show new icon ...
Post by: aw06 on June 20, 2009, 03:54:59 PM
Im using the advanced recent post mod, and i have it duplicated to show at the top of my index page ... what i want to do is add a clickable show new icon (https://www.simplemachines.org/community/Themes/smsite/images/english-utf8/new.gif) behind the topic name, similar to when your viewing messages on the message index page ....

The idea is i want it to work just the same and be only visible if a user is logged in... Here is the block of code i am using

// This is the "Recent Posts" bar.
   if (!empty($settings['number_recent_posts']))
   {
      echo '
        <table cellpadding="4" cellspacing="1" border="0" width="100%">
            <tr>
               <td class="titlebg" colspan="2">', $txt[214], '</td>
            </tr>
            <tr>
               <td class="windowbg" width="20" valign="middle" align="center">
                  <a href="', $scripturl, '?action=recent"><img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" /></a>
               </td>
               <td class="windowbg2">';

      // Only show one post.
      if ($settings['number_recent_posts'] == 1)
      {
         // latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
         echo '
                  <b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
                  <div class="smalltext">
                        ', $txt[234], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt[235], ' (', $context['latest_post']['time'], ')<br />
                  </div>';
      }
       // Show lots of posts.
         elseif (!empty($context['latest_posts']))
         {
             echo '
             <table cellpadding="0" cellspacing="1" width="100%" border="0">
           <tr>
               <td class="catbg2" style="text-align:center;" colspan="2">', $txt[70] ,'</td>
               <td class="catbg2" style="text-align:center;">', $txt[110] ,'</td>
               <td class="catbg2" style="text-align:center;">', $txt[301] ,'</td>
               <td class="catbg2" style="text-align:center;">', $txt[20] ,'</td>
               <td class="catbg2" style="text-align:center;">', $txt[29] ,'</td>
               <td class="catbg2" style="text-align:right;">', $txt[317] ,'</td>
             </tr>';
             /* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
$cnt = 0;
foreach ($context['latest_posts'] as $post){
         $cnt++;
         $class = ($cnt % 2) ? 'windowbg' : 'windowbg2';
         
        echo '
<tr>
                <td class="', $class, '"" style="text-align:center;"><img src="', $post['icon'] , '" alt="" /></td>
<td class="', $class, '"" title="', $post['preview'] ,'">', $post['link'], '</td>
                <td class="', $class, '"" style="text-align:center;">', $post['replies'], '</td>
<td class="', $class, '"" style="text-align:center;">', $post['views'], '</td>
                <td class="', $class, '"" style="text-align:center;">',$post['board']['link'], '</td>
                <td class="', $class, '"" style="text-align:center;">',$post['poster']['link'], '</td>
<td class="', $class, '"" style="text-align:right;" nowrap="nowrap">', $post['time'], '</td>
</tr>';
       }
echo '
</table>';
      }
      echo '
               </td>
            </tr>
        </table>';


Can somebody please add the edits for me, as i have been trying with no luck  :-[

My Site (http://www.classifieds.shopinja.com)
Title: Re: adding show new icon ...
Post by: aw06 on June 22, 2009, 12:32:23 AM
BUMP
Title: Re: adding show new icon ...
Post by: mashby on June 22, 2009, 06:39:59 PM
First two lines are:
// This is the "Recent Posts" bar.
   if (!empty($settings['number_recent_posts']))


Make that be:
// This is the "Recent Posts" bar.
   if (!empty($settings['number_recent_posts']) && $context['user']['is_logged'])


Then at the end (unless it's already there), look for:
        </table>';

Change that to:
        </table>';
}


What I mean by "already there" is the end of the if container {}.
Title: Re: adding show new icon ...
Post by: aw06 on June 23, 2009, 01:17:41 AM
Thanks, but perhaps you misunderstod me ... your edit hides the recent list from guest , what i want to do is display the show new icon (https://www.simplemachines.org/community/Themes/smsite/images/english-utf8/new.gif) behind the topic name,
Title: Re: adding show new icon ...
Post by: [SiNaN] on June 24, 2009, 12:11:46 PM
Sources/Recent.php

Code (Find) Select
'raw_timestamp' => $row['posterTime'],

Code (Replace) Select
'raw_timestamp' => $row['posterTime'],
'new' => !empty($row['isRead']),
'new_from' => !empty($row['new_from']) ? $row['new_from'] : 0,


Themes/default/BoardIndex.template.php

Code (Find) Select
$post['link'], '</td>

Code (Replace) Select
$post['link'], $post['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '</td>

For further support related to this mod, please use its own support topic.
Title: Re: adding show new icon ...
Post by: aw06 on June 24, 2009, 11:32:54 PM
 :-[ still not quite working ... the new icon is displayed, but when click it goes to the first post on the page, and when you go back to the index page and refresh the new icon is still shown on the link you just clicked...

I posted for support in the mod support topic, but no responce
Title: Re: adding show new icon ...
Post by: [SiNaN] on July 02, 2009, 10:06:11 AM
Well, I have tried it before suggesting to you. Can you attach your Recent.php and BoardIndex.template.php files here and provide a test account to check it?