TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 347
  • Total: 348
  • @rjen

"recent topics" in SMF style

Started by Lesmond, August 17, 2005, 12:01:38 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

katoona

Again, thanks for your help. It works perfectly.

katoona

I know that this is a not a support board, but I am trying to write a code to add numbers before each post. This should be fairly easy, but I am completely stuck.

I thought this would be something that others also want to know how to do. I have a attached a manipulated picture of what I am trying to accomplish.


jacortina

These are simply to enumerate the lines?

What code are you using?

Basically, you'll set a counter variable to zero before you loop through the entries and increment it.

katoona

#273
Quoteglobal $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Selges</td></tr> ';
       $what=ssi_recentTopics_Include(60,array(1,2,3,4,5,6,7,8,9,10,11),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg2" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/ny.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/ny_ikke.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '</a>
            </td>

                                         <td class="annonser" height="22" valign="middle">
                                                ', $topic['link'],'

               </td>                                       
                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

I am using the above code to show recent posts in a center block, and now I am using the left field to show "new" indicator, but I am planning to move the "new" indicator somewhere else and replace it with numeric.

jacortina

Well, this adds a column to the far left and puts the number there (note the 'colspan' paramter in the 5th line; that should equal the total number of columns).

global $scripturl, $txt, $settings, $context;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="4" class="catbg">Selges</td></tr> ';
       $what=ssi_recentTopics_Include(60,array(1,2,3,4,5,6,7,8,9,10,11),'return');

$counter = 0;

        foreach ($what as $topic)
        {

$counter += 1;
                echo '
                                <tr> <td class="windowbg2" valign="middle" align="center" width="4%">', $counter, '</td>';

                echo '
                                <td ' , ' class="windowbg2" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/ny.gif" alt="', $txt[302], '" border="0" />';

else
echo '<img src="', $settings['images_url'], '/ny_ikke.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

echo '</a>
</td>

                                         <td class="annonser" height="22" valign="middle">
                                                ', $topic['link'],'

               </td>                                       
                                        <td class="windowbg2" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

katoona

Wow, that was fast. Thank you so much.  ;D ;D ;D

siyah11


texasflats

Whew, I got it working. Thank you!!  :)

I don't want to be a pain, but would it be real complicated to add the author of the topic and maybe a brief summary of the post?

The code I'm using is:
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Texas Fishing Reports</td></tr> ';
       $what=ssi_recentTopics_Include(3,array(5),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/on.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/on2.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '
            </td>

                                         <td class="windowbg2" height="22" valign="middle">
                                                ', $topic['link'],'

               </td>                                       
                                        <td class="windowbg" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';


It is 3 columns. I'd like to add the summary to the center column and the author to the right column if possible.

You can see it at http://texasflats.net/

jacortina

Without extensive re-work, you can only work with what's returned from the ssi function called. That gives last poster name (not the original topic starter) and it gives up to the first 128 characters of the message.

Try this:
global $scripturl, $txt;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="catbg">Texas Fishing Reports</td></tr> ';
       $what=ssi_recentTopics_Include(3,array(5),'return');


        foreach ($what as $topic)
        {
                echo '
                                <tr> <td ' , ' class="windowbg" valign="middle" align="center" width="4%"> <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['new_from'], '#new">';

            // Is this topic new? (assuming they are logged in!)
            if (!$topic['new'] && $context['user']['is_logged'])
               echo '<img src="', $settings['images_url'], '/', $context['user']['language'], '/on.gif" alt="', $txt[302], '" border="0" />';

            else
               echo '<img src="', $settings['images_url'], '/on2.gif" alt="', $txt[334], '" title="', $txt[334], '" />';

            echo '
            </td>

                                         <td class="windowbg2" valign="middle">
                                                ', $topic['link'],'<br />

                                                <span class="smalltext">
                                                        ', $topic['body'], '
                                                </span>
               </td>                                       
                                        <td class="windowbg" valign="middle" width="20%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                       echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '<br />', $topic['poster']['link'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';

texasflats

Thanks J.A.Cortina. I gave that a try, it works as you said with the exception of the 128 chars wouldn't show up, and the topic titles link to the last reply which doesn't work for what I'm wanting.

If it's a big deal I'll just keep what I have, but I do appreciate your response and EFFORT.

Thanks!

This website is proudly hosted on Crocweb Cloud Website Hosting.