News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

adding show new icon ...

Started by aw06, June 20, 2009, 03:54:59 PM

Previous topic - Next topic

aw06

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 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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

mashby

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 {}.
Always be a little kinder than necessary.
- James M. Barrie

aw06

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 behind the topic name,
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

aw06

 :-[ 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
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

[SiNaN]

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?
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: