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

Recent

Welcome to TinyPortal. Please login or sign up.

May 19, 2024, 12:06:44 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 70
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 68
  • Total: 68

"recent topics" in SMF style

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchBin

That's good stuff! Post away astpaul. :)

astpaul

Quote from: IchBinâââ,¬Å¾Ã,¢ on April 03, 2006, 02:39:04 PM
That's good stuff! Post away astpaul. :)
Ok

It is a little tricky as i had to modify SSI.php in order to obtain the desired result.

So the actual block code is :
// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', array('1','2','3','4','5','6','7','8','9','10','12','13','14','16','17','15'), 'array', 500);

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
//echo '<tr class="catbg3"><td valign="middle">Subject</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle">', $topic['link'],'<br><font color="#666666" size="1">', $topic['preview'],'</font>';
    // 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['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
//      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
//      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      echo '<td class="windowbg2" valign="middle">';
      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>';


For the SSI modification, here is the file. Watch for lines beginning by //MODIF ASP
I had to create a new variable in ssi_recentTopics which states the number of characters one wants to display; modify the correspoding SQL order and variables.

And voila!

Hope it helps

elpvn

Thank, that's so fine in some case  :)

technodragon73

Ok...how can i fix this?  I keep getting a error from this in the log stating newtime is an undefined index...also db.

What do i need to change in order to stop the errors?

jpark

I'm having some trouble with the array function [example - array('3','36')]  I want to list recent topics from a specific board but I am finding that it doesn't just call from the board that i indicated but others as well.  I modified bloc's code to have two columns both 42% of the screen that each call 5 recent topics from separate boards with the board titles indicated.. but i'm having that problem that i stated above.  Does anyone know how to fix this?

global $scripturl;

echo '
<table border="0" width="100%" cellspacing="1" cellpadding="2">
<tr>
<td width="42%">
<table width="100%">News</br><div class="hr"><hr /></div>
                               ';
       $what=ssi_recentTopics('5', array('9') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td width="70%" valign="top">
<img src="', $settings['images_url'], '/icons/arrow.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: left;" / >   

                                                ', $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['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>             
                                        <td width="30%" align="center" valign="top">';
                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>
</td>

<td width="42%">
<table width="100%">General Discussion</br><div class="hr"><hr /></div>
                               ';
       $what=ssi_recentTopics('5', array('1') , 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td width="70%" valign="top">
<img src="', $settings['images_url'], '/icons/arrow.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: left;" / >   

                                                ', $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['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';

                echo '
                                        </td>             
                                        <td width="30%" align="center" valign="top">';
                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>
</td>
</tr></table>';

astpaul

you put in the array the boards that you DO NOT want to be displayed!!! :)

jpark

ahh i see.. thanks, i will try that out

jpark

one more question.. how do i define the max length of a topic title so it fits on one line in the above code (42% of the screen)

astpaul

Quote from: jpark on April 15, 2006, 09:11:35 PM
one more question.. how do i define the max length of a topic title so it fits on one line in the above code (42% of the screen)
You can't the way you want it.
The only thing you can do is to limit your title to a specific number of characters like this:
substr($topic['topic'],0,34)
In this case, we took the 1st 34 characters.

technodragon73

Quote from: technodragon73 on April 12, 2006, 05:43:02 PM
Ok...how can i fix this?  I keep getting a error from this in the log stating newtime is an undefined index...also db.

What do i need to change in order to stop the errors?

Anyone?