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,915
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

custom "Recent Topics from Board X, Y, Z only" php block

Started by iowamf, November 04, 2005, 09:47:16 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JPDeni

If you've got it to work now, even though it's a pain, it's probably best to just leave it. It worked fine for me, but, as always, YMMV.:) My guess is that there's a syntax error somewhere.

The timestamp is in a variable called $my['time'] which you can put wherever you want it. As for the color, I'm not sure, but there could be something in your theme that changes the background for lists. That's the only thing I can think of that would cause it. You could test it by just making an html block with an unordered list to see if the color changes.

There's a lot of funky code in there. I'll try to fix it up a little bit.

$result=ssi_recentTopics(10,array(5,6,7,8,9,10,13,15,16,17,18,19,22,23,24,25,226,27,28,29,30,31,33,34,35,36,37,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,106,107,108,109),'array');
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
  echo '<Li>'.$my['link'];
  if($my['new'])
    echo ' <a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
  echo ' ',$my['time'],'</Li>';
}
echo '</UL>';

I've also added your timestamp in there.

jacortina

Quote from: JPDeni on October 21, 2006, 04:34:19 AM

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$num_recent = 10;
$include_boards = array(5,6,17);

...



Using this method (targetting specific boards), it's probably best to eliminate the 'WHERE' condition limiting the query to the last messages only:

t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "

You could easily end up with an empty result set (none of the last 350 posts in any of the boards to be included).

Puchu

Quote from: JPDeni on October 21, 2006, 04:00:46 PM
If you've got it to work now, even though it's a pain, it's probably best to just leave it. It worked fine for me, but, as always, YMMV.:) My guess is that there's a syntax error somewhere.

The timestamp is in a variable called $my['time'] which you can put wherever you want it. As for the color, I'm not sure, but there could be something in your theme that changes the background for lists. That's the only thing I can think of that would cause it. You could test it by just making an html block with an unordered list to see if the color changes.

There's a lot of funky code in there. I'll try to fix it up a little bit.

$result=ssi_recentTopics(10,array(5,6,7,8,9,10,13,15,16,17,18,19,22,23,24,25,226,27,28,29,30,31,33,34,35,36,37,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,106,107,108,109),'array');
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
  echo '<Li>'.$my['link'];
  if($my['new'])
    echo ' <a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
  echo ' ',$my['time'],'</Li>';
}
echo '</UL>';

I've also added your timestamp in there.

looks good... but the new image shows on what I have seen instead of what i havent seen...

EDIT:

I used the code I had posted earlier and added the timestamp, it looks good minus the background being different, but you said it had funky code...  so if you can get the new to work right then Ill switch it over to yours ;)

JPDeni


pvcblue

Problem - I am using this code - but it does not mark the topic nor post as read....
help!

       
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>';


Puchu

I did one more thing, saw that the timestamp was running on witht he title of the thread... so I added break...  couldnt get it done any other way besides giving its own line... so it works for me atleast =P

echo '<span class="smalltext">';
$result=ssi_recentTopics(10,array(5,6,7,9,10,13,15,16,17,18,19,22,23,24,25,226,27,28,29,30,31,33,34,35,36,37,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,105,106,107,108,109),'array');
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
  echo '<Li>'.$my['link'];
  if(!$my['new'])
    echo ' <a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';
echo ' <br />';
  echo ' ',$my['time'],'</Li>';
}
echo '</UL>';
echo '</span>';


rrasco

so is there a version of this that makes it look like the actual Recent Posts block?

and i tried over and over again to make that function include instead of exlude and it just will not work.  i have created 3 blocks, Recent Topics, Recent News, and Classifieds.  When I input the forums to exclude, only the first block i made shows content, the others are blank.  I modified SSI.php to have 3 additional functions, exact copies of ssi_recentTopics, only numbered ssi_recentTopics1, ssi_recentTopics2, and ssi_recentTopics3.  Now that I did this, all of the blocks show content, however it is the wrong content.  the first block i made has the correct content, but the other block are showing the same exact posts as the first one i made, and they are specifically excluded from those blocks.  got me all confused.

anyone used this on 1.1RC3?  im thinking that has to be my problem.

rrasco

ok, so i have come to the conclusion that you can only use one of these blocks at a time, or they will only show the content of one block.  if you create multiple functions as i did, then they will work but for some reason they will only show the content of the first one you create.


This website is proudly hosted on Crocweb Cloud Website Hosting.