TinyPortal

Development => Block Codes => Topic started by: agent47 on October 13, 2012, 12:10:07 PM

Title: Block code for recent topics
Post by: agent47 on October 13, 2012, 12:10:07 PM
Link to my site: http://www.superheroalliance.net
SMF version: SMF 2.0.2
TP version: TP 1.0
Default Forum Language: English utf8
Theme name and version: DzinerStudio's laGusta

Guys, I'm looking for a simple block code that displays recent topics in the following manner:

[screen removed]
It's nice and clean just the way I like it.

Thanks in advance.

Kind regards,
agent47
Title: Re: Block code for recent topics
Post by: lurkalot on October 13, 2012, 05:01:10 PM
This one kind of does what you need.  I'm sure it could be tweaked if necessary.  Put it in a php block.  ;)

Code: [Select]
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

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

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
Title: Re: Block code for recent topics
Post by: agent47 on October 13, 2012, 06:12:17 PM
Hey lurkalot ol' pal, have I ever told you how awesome you are? Because if I haven't here's me saying it "You're too damn awesome bud!!!!"  O0
Thanks pal.
Title: Re: Block code for recent topics
Post by: lurkalot on October 14, 2012, 01:45:30 AM
Thanks agent47.   I can't take credit for this one, I grabbed the code from this thread http://www.tinyportal.net/index.php?topic=596.0 

Which I found in the old snippets boards, which you can find here.  http://www.tinyportal.net/index.php?topic=4983.0  These are for old versions of TP / SMF, but some still work. ;)
Title: Re: Block code for recent topics
Post by: MrCare on August 14, 2013, 12:08:36 AM
This one kind of does what you need.  I'm sure it could be tweaked if necessary.  Put it in a php block.  ;)

Code: [Select]
global $scripturl;

echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg">Recent topics</td></tr> ';
       $what=ssi_recentTopics('8', NULL, 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'];

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

                echo '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['poster']['link'], '
                                        </td>
                                        <td class="windowbg2" valign="middle" width="35%">';
                if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
                        echo '
                                        <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
                echo '
                                                <span class="smalltext">
                                                        ', $topic['time'], '
                                                </span>
                                        </td>
                                </tr>';
        }

        echo '
                        </table>';
how can we make it  like default board index display? like we have in forum?