TinyPortal

Development => Block Codes => Topic started by: iowamf on November 04, 2005, 09:47:16 AM

Title: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on November 04, 2005, 09:47:16 AM
I have created a php block similar to the "Recent Posts" block, but it will be highly customized to only pull "Recent Topics" (not comments to ancient posts) and it will only include new Topics from specific boards.  It's a work in progress, but here is the PHP block snippet so far:

$result=ssi_recentTopics(10,array(1,3,4),'return');
echo'<center>';
echo '<list>';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
}
echo '</list>';
echo'</center>';
echo '<span class="smalltext">SmallText</span>';


and the result is attached below.

Yes, I'm a rookie PHP hacker ... the only reason I threw in the "smalltext" example was to see what the text looks like.

What I'd like to do ... is to make the text and the little icons (list bullets) look like the text and icons in the "Content" box right above it (barely visible - but you can see the "About Us" and the "Links" in the snapshot).

Notes:

   if I don't "center" the list - the "bullets" show up too far to the left (outside of the box).

   to those who are new to ssi_recent_topics() - the 10 param is the # of topics to grab and the array is the boards to *EXCLUDE* (I'm hacking up my own ssi_recent_topics() to do the reverse so I don't have to change this block everytime the boards change - doh!)

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: bloc on November 04, 2005, 11:40:46 AM
try <ul> instead of <list> and attach a padding or margin to it..like <ul style="padding-left: 2px;"> or <ul style="margin-left: 2px;">

One of those will control the automatic indentation that any <ul> or <ol> tag creates.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: kip on January 09, 2006, 03:55:53 AM
Could someone point me to a way to offer this to users letting them choose which boards they would like to see recent topics from?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on January 09, 2006, 04:15:21 AM
It can't be done without changine some code. And I think it's a little out of scope especially if you want them to be able to pick the forums they want to see recent topics from. That sounds like a whole other mod to me. Unfortunately, I'm not a PHP guru or I'd try it myself. :)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: kip on January 09, 2006, 04:22:15 AM
Okay, fair enough.  I'll have to look into this further.  Thanks!
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: dknoppix on February 07, 2006, 10:33:38 PM
Where do we put the code?

Make a phpbox?

EDIT: Got it, but how do I make the bullets a little to the left? http://dknoppix.com/forums

Thanks
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on February 08, 2006, 07:38:25 PM
$result=ssi_recentTopics(10,array(1,3,4),'return');
echo'<div align="left">';
echo '<list>';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
}
echo '</list>';
echo'</div>';
echo '<span class="smalltext">SmallText</span>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on February 08, 2006, 08:33:31 PM
TportalBlocks.template.php - note, this was for v.0.75 of TinyPortal.

Example of how to add the bullet (and remove the time stamp - the fact that it is a "recent" topic and is in post "order" is enough info for me).

Quote// TPortal recent topics block
function TPortal_recentbox()
{
    global $context, $settings, $options, $txt , $modSettings;

//hack - added bullet:
    $bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

    // is it a number?
    if(!is_numeric($context['TPortal']['recentboxnum']))
                     $context['TPortal']['recentboxnum']='10';

    // leave out the recycle baord, if any
    if(isset($modSettings['recycle_board']))
      $bb=array($modSettings['recycle_board']);
    else
      $bb=array();
    $what=ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'], $bb, $output_method = 'array');

    // Output the topics
    foreach($what as $w){

// hacks to add bullet and strip out time begin
   echo "$bullet";
// changed time to short_subject:
            echo '<span class="smalltext"><a href="'.$w['href'].'"> '.$w['short_subject'];
            if(!$w['new'])
               echo ' <img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" />';

//commented this out:
//           echo '
'.$w['short_subject'].'</a></span><hr style="background-color: #c0c0c0;margin: 0px; " />';
// hack to replace above:
echo '</a></span><br style="background-color: #c0c0c0;margin: 0px; " />';
// - end hacks to strip out time

    }
}
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: dknoppix on February 08, 2006, 11:09:13 PM
thanks
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on February 09, 2006, 09:00:37 AM
Below is the "user block" phpbox snippet.

Note, the ssi_recentTopics() was copied and a new function was created ssi_recentTopics_REVERSE to do the opposite (instead of returning information from all boards that were excluded - it only returns information from boards that are requested (ie, in this case the boards in section "9").

global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_REVERSE(10,array(9),'return');
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '<br>';
}
echo '</span>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: kai920 on February 14, 2006, 06:28:51 AM
Thanks for this thread iowamf.

I'm trying to display recent posts only from board id "2"... but this code does not seem to work: (note I do not have board id "3")

$result=ssi_recentTopics(10,array(7,4,5,8,1,6,10,9),'return');
echo'<center>';
echo '<list>';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
}
echo '</list>';
echo'</center>';
echo '<span class="smalltext">SmallText</span>';


Any ideas on what may be wrong?  All that is displayed in the box is "SmallText".
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on February 14, 2006, 08:13:22 AM
it looks ok - do other ssi_ calls work?

i'd open up your ssi_ call to not exclude so many boards - make sure you get something  :-\

throw in a print_r for debug to get a bunch of info to look at (see below).

$result=ssi_recentTopics(10,array(59,2),'return');
foreach($result as $my){
echo '<span class="smalltext">'.$my['link'].'<br>';
}
echo "<hr>";
echo "<pre>";
print_r ($result);
echo "</pre>";
echo '<hr>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: criminalmind on February 26, 2006, 10:30:10 AM
Has anybody posted the "ssi_recentTopics_reverse" function or similar?
Or is there another way to display (in a block) the last X posts from (not excluding) a specified range of boards?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on February 26, 2006, 04:42:01 PM
Quote from: criminalmind on February 26, 2006, 10:30:10 AM
Has anybody posted the "ssi_recentTopics_reverse" function or similar?
Or is there another way to display (in a block) the last X posts from (not excluding) a specified range of boards?

Edit SSI.php, copy the entire function ssi_recentTopics and create a new one - but call it ssi_recentTopicsINC (or whatever you want).

Follow what is in  this thread  (http://www.simplemachines.org/community/index.php?topic=51987.msg366755#msg366755) over at simplemachines where an awesome guru provided some nuggets of wisdom.

NOTE - this worked fine on SMF 1.1 RC1 (has not been tested on SMF 1.1 RC2 yet).
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: criminalmind on February 26, 2006, 06:15:24 PM
Quote from: iowamf on February 26, 2006, 04:42:01 PM

Follow what is in  this thread  (http://www.simplemachines.org/community/index.php?topic=51987.msg366755#msg366755) over at simplemachines where an awesome guru provided some nuggets of wisdom.


This thread doesnt work. Please provide the code (if u still have it) without refering to any links!
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on February 26, 2006, 06:45:27 PM
If you want the last 10 topics from any board just take out the array part.

$result=ssi_recentTopics(10, 'return');
echo'<center>';
echo '<ul>';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
}
echo '</ul>';
echo'</center>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on February 26, 2006, 07:26:34 PM
I wanted to link as the credit is due to a support guru - not me ... plus, the code is more SMF related than TP related (another reason why I linked back to it - and posted there in the 1st place).

Quote from: criminalmind on February 26, 2006, 06:15:24 PM
Quote from: iowamf on February 26, 2006, 04:42:01 PM

Follow what is in  this thread  (http://www.simplemachines.org/community/index.php?topic=51987.msg366755#msg366755) over at simplemachines where an awesome guru provided some nuggets of wisdom.

This thread doesnt work. Please provide the code (if u still have it) without refering to any links!

yo' criminalmind, watch your bangs (!) - it makes your post sound like a demand/shout  :coolsmiley:

for the link and search impaired, the repost from:
  http://www.simplemachines.org/community/index.php?topic=51987
is below:

note - I edited Oldiesmann post to add the INC to the end of the new function call in the 1st replace ... I hope it's not taboo to copy and paste from the SMF boards to this board?  If so - please delete this post.

Quote from: Oldiesmann on October 13, 2005, 01:25:18 AM
SSI.php

Find
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')

Replace
function ssi_recentTopicsINC($num_recent = 8, $include_boards = null, $output_method = 'echo')

Find
if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;


Replace
$include_boards = empty($include_boards) ? array() : $include_boards;

Find
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "


Replace
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
" . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != '$modSettings[recycle_board]'" : '') . "


Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rodman on March 14, 2006, 05:41:44 AM
Is there a way to get the "new" image displayed?

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on March 14, 2006, 09:13:35 AM
Quote from: rodman on March 14, 2006, 05:41:44 AM
Is there a way to get the "new" image displayed?

it is there.

see post#9 code box (it is somewhat hidden by the scroll bars) after the "is this topic new?" comment.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rodman on March 14, 2006, 04:02:42 PM
AWSOME!!!

This has helped me out so much!! TY iowamf and everyone else who helped!!

Is there a way to increase the font by just a tad ....   ;)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: trvlnman on June 21, 2006, 04:03:28 AM
Thanks everyone for this...I have it implemented and it works great.

However, I'd like to keep the timestamp in the list.  I used the post in Reply #9.  Is there anyone that can help me out?

I appreciate any help that you can give me.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Techdomain on July 17, 2006, 10:54:15 PM
This is the code to put the bullets in the box, left aligned, and also add the "new" graphic for new posts:


$result=ssi_recentTopics(10,array(15),'return');
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: trench on July 19, 2006, 02:13:48 AM
Thats for all Recent topics though. How do we get it working for one particular board?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on July 19, 2006, 02:51:50 AM
Quote from: trench on July 19, 2006, 02:13:48 AM
Thats for all Recent topics though. How do we get it working for one particular board?
I ran into that exact same concern myself - in order to get it working for one particular board you have to do one of the following:


See the posts that reference ssi_recentTopics_reverse - it is discussed in this thread ... note the change of parameter from "exclude_boards" to "include_boards".

The problem with using the default ssi_recentTopics to display only one board is that you have to go back and hack the parameters in the call everytime you add a board.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Techdomain on July 19, 2006, 03:26:31 AM
yep - that is what I found. this is my code for this page here:
http://www.techdomain.com.au/index.php?page=20


echo "<p style='margin-bottom: 0in;' align='middle'><u><font size='5'><strong><span lang='en-AU'>Recent";
echo " Discussion</span></strong></font></u></p>"; 
        echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
';
       $what=ssi_recentTopics('50', array('15','72') , '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['newtime'], '#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="17%">
                                                ', $topic['poster']['link'], '
                                        </td>
<td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['board']['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 '
                                        <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>';

echo "<p style='margin-bottom: 0in;' align='middle'><u><font size='5'><strong><span lang='en-AU'>Recent";
echo " News</span></strong></font></u></p>"; 

        echo '
                        <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
';
       $what=ssi_recentTopics('50', array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','50','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94') , '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['newtime'], '#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="17%">
                                                ', $topic['poster']['link'], '
                                        </td>
<td class="windowbg2" valign="middle" width="20%">
                                                ', $topic['board']['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 '
                                        <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: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on July 19, 2006, 05:24:47 AM
looks good - but the problem (as you already know) is that you'll have to update the excluded board(s) in your ssi call array('15','72') every time you add a board to your forum ... oh well, it is what it is.

Quote from: Techdomain on July 19, 2006, 03:26:31 AM
yep - that is what I found. this is my code for this page here:
http://www.techdomain.com.au/index.php?page=20


       $what=ssi_recentTopics('50', array('15','72') , 'array');

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: trvlnman on July 19, 2006, 06:02:45 PM
I did get the "included" boards to work just fine creating a ssi_recentTopics_INC function.  That way you only have to put the one board you want included into the list.  No further updating necessary.  Just follow the directions in Reply #16.

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: akulion on August 19, 2006, 04:41:39 AM
Thanks this is perfect for the "In the News" (http://path-to-peace.net) board I have on my forum (browse down until u see a guy with a newspaper reading EXTRA) - its reserved for latest news from around the globe

2 things id like to ask are:

- Make the link text size bigger
- Make them appear in a tabular layout

====

By the way im using the recenttopicsINC method out of all of the above
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 20, 2006, 09:08:44 PM
Quote from: iowamf on February 09, 2006, 09:00:37 AM
Below is the "user block" phpbox snippet.

Note, the ssi_recentTopics() was copied and a new function was created ssi_recentTopics_REVERSE to do the opposite (instead of returning information from all boards that were excluded - it only returns information from boards that are requested (ie, in this case the boards in section "9").

global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_REVERSE(10,array(9),'return');
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '<br>';
}
echo '</span>';


On my site it just shows the title... or nothing at all...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: G6Cad on October 20, 2006, 09:14:37 PM
What kind of block have you added the code in to ?
It needs a PhP block to work
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 20, 2006, 09:16:25 PM
Do you have the ssi_recentTopics_REVERSE function?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 20, 2006, 09:26:30 PM
I dont know, we probably dont, but I also tried it without the _REVERSE, and it did the same thing...

And yes Im putting it into a php block...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 20, 2006, 09:37:39 PM
okay I tried some of the other codes, I got something to show up, don't like the view of them...

But the problem is now I must type in an estimated, 50 boards or so to exclude them...  and then add a few more here and there...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 20, 2006, 10:26:20 PM
QuoteBut the problem is now I must type in an estimated, 50 boards or so to exclude them.
That's the point of the REVERSE function. Follow the instructions in the other topic to create that function and you will be able to show only the boards that you want, instead of showing everything except the ones you don't want.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 21, 2006, 03:39:16 AM
Quote from: JPDeni on October 20, 2006, 10:26:20 PM
QuoteBut the problem is now I must type in an estimated, 50 boards or so to exclude them.
That's the point of the REVERSE function. Follow the instructions in the other topic to create that function and you will be able to show only the boards that you want, instead of showing everything except the ones you don't want.

You mean in this thread a few pages back???

If thats it I must edit a file... but I need to get the person who is hosting the site (individual not company) to get the ftp working again for the admins... or have him do it himself which will probably never happen lol

Is there a way to show just how the recent topics built in the tp is and array them???  Because most others are made different... and Ill do that instead so I dont have to bother anybody...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 21, 2006, 03:57:49 AM
Yes, that's the one. You can put functions into a php article or block.

I'll come back to this in a bit and give you the code you need to use.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: 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);

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

  $include_boards = empty($include_boards) ? array() : $include_boards;

  $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
  $icon_sources = array();
  foreach ($stable_icons as $icon)
    $icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
  $request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
                        AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
" . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != '$modSettings[recycle_board]'" : '') . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
  $posts = array();
  while ($row = mysql_fetch_assoc($request))
  {
    $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
    if ($func['strlen']($row['body']) > 128)
      $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
      censorText($row['subject']);
      censorText($row['body']);

      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
        $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$result[] = array(
                        'board' => array(
                                                'id' => $row['ID_BOARD'],
                                                'name' => $row['bName'],
                                                'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
                                                'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
                        'topic' => $row['ID_TOPIC'],
                        'poster' => array(
                                                'id' => $row['ID_MEMBER'],
                                                'name' => $row['posterName'],
                                                'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
                                                'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
       ),
                        'subject' => $row['subject'],
                        'short_subject' => shorten_subject($row['subject'], 25),
                        'preview' => $row['body'],
                        'time' => timeformat($row['posterTime']),
                        'timestamp' => forum_time(true, $row['posterTime']),
                        'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
                        'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
                        'new' => !empty($row['isRead']),
                        'new_from' => $row['new_from'],
                        'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}

mysql_free_result($request);

// Print out the results

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
  if (!$my['new'] && $context['user']['is_logged'])
  echo '
    <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
    <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
  echo '</span>';
  echo '<br>';
}
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 21, 2006, 05:12:11 AM
I put that in and it cuts off the tp on that side and only shows the title bar...  none of the blocks below where it would go shows...

EDIT:
unless that is what needs modified in the file... which I can't get to that file if that is the case :-/


$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'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


Thats the code I have to use if I type in all the boards to be excluded...  only problem with this I really don't like how it looks...  I want the date, time, title, and new to show...


basically default view in TP with all my baords I have listed exlcuded is what I want =P

EDIT 2:
I got the size smaller...  moved the span class... now would just like the timestamp... also noticed that the background is a different color than all the other blocks... dont understand that...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 21, 2006, 06:10:38 AM
I don't understand either what you did or what you got when you used the code I posted.

The code I gave you can go into a php block or a php article. It's all self-contained so you don't have to edit any files. I guess I didn't explain that you need to enter the board numbers that you want to use, separated by commas in the $include_boards variable. If you did that, can I see the result that you got? Either give me a URL where I can see it or take a screenshot and attach it to your post.

If you want to mess around with listing all the boards to exclude, you can, but it really would be easier to get the code to work so you can just list the boards to include.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 21, 2006, 03:37:57 PM
Here is a picture of what it does with your code in a php block...

With the other code its background changed colors and its attached as well...  the rest of the blocks are black possibly transparent...

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: 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.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on October 21, 2006, 04:15:01 PM
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).
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 22, 2006, 07:22:34 PM
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 ;)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 22, 2006, 07:28:42 PM
Change
  if($my['new'])
to
  if(!$my['new'])
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: pvcblue on October 22, 2006, 08:02:11 PM
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>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 22, 2006, 10:04:59 PM
Quote from: JPDeni on October 22, 2006, 07:28:42 PM
Change
  if($my['new'])
to
  if(!$my['new'])


Thank you!
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Puchu on October 22, 2006, 11:29:42 PM
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>';

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rrasco on October 26, 2006, 10:03:31 PM
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.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rrasco on October 26, 2006, 10:09:19 PM
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.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 26, 2006, 10:29:52 PM
What are your three functions?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rrasco on October 26, 2006, 10:32:05 PM
Quote from: rrasco on October 26, 2006, 10:03:31 PM
I modified SSI.php to have 3 additional functions, exact copies of ssi_recentTopics, only numbered ssi_recentTopics1, ssi_recentTopics2, and ssi_recentTopics3.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 26, 2006, 10:38:36 PM
I realize that. But what are they? If they are exact copies of each other, then, yes, you will get the exact same results. I was asking to see them to see if I could figure out why you were getting the results you are getting.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rrasco on October 26, 2006, 10:42:43 PM
This is the one I copied.  all of these have the same exact code except this:

function ssi_recentTopics($num_recent = 8, $exclude_boards = null,

was changed to:

function ssi_recentTopics1($num_recent = 8, $exclude_boards = null,

and so on up to 3.

// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 26, 2006, 10:47:43 PM
Okay. So how are you accessing the functions? Can you give me the code you're using?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rrasco on October 26, 2006, 10:49:57 PM
One per block i created.

echo '<span class="smalltext">';
$result=ssi_recentTopics1(5,array(1,29,30,53,41,43,62,63,45,46,47,48,26,52,38,39,40,42,44),'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>';


echo '<span class="smalltext">';
$result=ssi_recentTopics2(5,array(2,21,3,28,50,51,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,49,22,23,24,25,27,1,29,30,53,45,46,47,48,26,52),'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>';


echo '<span class="smalltext">';
$result=ssi_recentTopics3(5,array(2,21,3,28,50,51,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,49,22,23,24,25,27,1,29,30,53,26,52,41,43,62,63,38,39,40,42,44),'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>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 27, 2006, 12:54:47 AM
So that tells you that you didn't need to create the different functions, since you get the same result with whichever function you use. It doesn't make any sense that you would get the same result with all of them, though.

Wish I could figure it out.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: rrasco on October 27, 2006, 02:05:02 AM
i dont get it either.  but if i didnt create the new functions, then only the first block you create will contain content.  the others dont work at all.  so they have to be seperate to work.  by me defining which cats to exclude, it should show content based on that.  I did at one point have the first block show its content, then the other two showed the same wrong content.  this has got be baffled.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: smartmouse on January 16, 2007, 11:37:37 PM
Hello, i create a new ssi_recentTopics fuction in the SSi.php file and i created a new phpbox.
It works... but i get the same result of standard Recent Topics module: there are the same topics listed. Why??

I use $result=ssi_recentTopics_NEW(10,array(9),'return');

where 10 is the # of recent topics to show, and (9) is the section ID of the forum.

Why i obtain the same result of standard Recent Topics module?


Thank you and sorry for my english.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on January 16, 2007, 11:44:56 PM
What is the code in this new function? If it's just a copy of the original, then it WILL NOT work on an INCLUDE basis.

Just like rrasco's code above, just calling the array an include list doesn't help. The actually query has to be changed to reference the include list and use an 'IN' clause instead of a 'NOT IN' clause.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: smartmouse on January 17, 2007, 12:37:59 AM
Quote from: J.A.Cortina on January 16, 2007, 11:44:56 PM
What is the code in this new function? If it's just a copy of the original, then it WILL NOT work on an INCLUDE basis.

Just like rrasco's code above, just calling the array an include list doesn't help. The actually query has to be changed to reference the include list and use an 'IN' clause instead of a 'NOT IN' clause.

Yes, it is a copy of original.

Sorry due my bad english i do not understand what i have to do to make new module working...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on January 17, 2007, 01:36:51 AM
Your english is far better than my abilities in any language beside english, so no apologies are necessary.

Replace the ssi_recentTopics_NEW that you added to SSI.php with the code given below.

Then see what $result = ssi_recentTopics_Include(10,array(9),'return'); returns.

function ssi_recentTopics_Include($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: smartmouse on January 17, 2007, 11:16:08 AM
Thank you for the code.

In the phpbox i used this code:

Quote
global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_Include(10,array(62),'return');
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '
';
}
echo '</span>';

It works but... it shows the latest 5 topics instead of 10, and it show the wrong section!
As you can see in the code, i set section 62... but it shows section 63.

What's wrong?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on January 17, 2007, 02:57:53 PM
It's showing the latest 5 because that query is designed to only check a certain number of messages back from the latest. It only looks at the last (35 * number asked for) messages. In your case, that means it only looks in the last 350 messages for topics in the given board. Apparently, it only found 5.

You can eliminate this restriction by finding:
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG


And replacing it with:
WHERE t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG


As to it getting topics from the wrong board, I'd have to ask you to confirm that you have the correct board number.

If you directly enter:
http://<URL to your forum>/index.php?board=62.0

Do you or do you not go to the board where the topics are being pulled from?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: smartmouse on January 17, 2007, 10:37:17 PM
It worked!

Forget about the board ID, all works fine! It was the right section...

Thank you so much!
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on January 18, 2007, 01:58:06 AM
awesome - all the diversion and added complexity was scaring me.

this thread is mostly about "reversing" the functionality of a known/good/functioning SSI call - i hope it stays on topic.

Quote from: smartmouse on January 17, 2007, 10:37:17 PM
It worked!

Forget about the board ID, all works fine! It was the right section...

Thank you so much!

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: snoopy_inc on January 24, 2007, 05:43:52 AM
Maybe a post with the final code for the new ppl ;)

That would be appriciated.

thanks
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: smartmouse on January 24, 2007, 12:59:13 PM
Add this code in SSI.php file

Quotefunction ssi_recentTopics_NEW($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
   global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
   global $user_info, $modSettings, $func;

   $include_boards = empty($include_boards) ? array() : $include_boards;

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   // Find all the posts in distinct topics.  Newer ones will have higher IDs.
   $request = db_query("
      SELECT
         m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
      FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE t.ID_LAST_MSG = m.ID_MSG
         AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
         AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
         AND $user_info[query_see_board]
         AND ms.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_LAST_MSG DESC
      LIMIT $num_recent", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('
' => '')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      // Censor the subject.
      censorText($row['subject']);
      censorText($row['body']);

      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      // Build the array.
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
      );
   }
   mysql_free_result($request);

   // Just return it.
   if ($output_method != 'echo' || empty($posts))
      return $posts;

   echo '
      <table border="0" class="ssi_table">';
   foreach ($posts as $post)
      echo '
         <tr>
            <td align="right" valign="top" nowrap="nowrap">
               [', $post['board']['link'], ']
            </td>
            <td valign="top">
               <a href="', $post['href'], '">', $post['subject'], '</a>
               ', $txt[525], ' ', $post['poster']['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>
            <td align="right" nowrap="nowrap">
               ', $post['time'], '
            </td>
         </tr>';
   echo '
      </table>';
}

Then in administration panel create a new phpbox and paste this code:

Quoteglobal $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_NEW(10,array(9),'return');
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '
';
}
echo '</span>';

"9" is the board ID, change it to select the prefer board to be listed in the module.

I hope this can help, sorry for my english.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on January 24, 2007, 04:30:24 PM
Smartmouse, you MUST put code into a 'code box'. Putting it in quote box results in erroneous transposition of some of the tags. For instance, look through your post for:
</a>

New Function for SSI:
function ssi_recentTopics_Include($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


Block Code Example:
global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(9),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '
';
}
echo '</span>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: smartmouse on January 24, 2007, 11:27:54 PM
Sorry, i just tried to be helpful ;D
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on January 24, 2007, 11:37:57 PM
Right. And that's great.

It's just the nature of how the two different things, quotes and code, are treated by SMF.

It's a 'gotcha' that turns up here now and then, so you watch out for it, too.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: snoopy_inc on January 26, 2007, 03:40:13 PM
So if i copy his quoted code i wont have trouble?  It can disply multiple boards new posts right? not just a singular board?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on January 26, 2007, 03:48:57 PM
Use the code I posted in the 'code' boxes in message:
http://www.tinyportal.net/index.php?topic=1234.msg105411#msg105411

As noted, the first part should be added to the SSI.php file (defines a new SSI function).

Then you put the second part in a block. The one line to pay attention to there (and you'll want to change) is:

$result=ssi_recentTopics_Include(10,array(9),'return');

That '10' is the number of topics to return.

That 'array(9)' is the list of boards to get recent topics from. So, you can change it to, for intance, 'array(5,6,10,18)' to get from board numbers 5, 6, 10, and 18.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: snoopy_inc on January 26, 2007, 05:06:35 PM
excellent... thanks
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jakemelon on February 11, 2007, 03:50:56 PM
Hi,

I got this to work, looks good! How can you add more details about the recent posts such as:

1) *NEW* icon next to each new post (if posted today)
2) name of forum where the post was made
3) name of person who wrote post
4) if posted today display "Posted TODAY", if yesterday display YESTERDAY, if older then yesterday display "posted x days ago"


I know I am asking for alot! hehehe

thanks!

jake
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on February 11, 2007, 04:33:50 PM
Quote from: jakemelon on February 11, 2007, 03:50:56 PM
Hi,

I got this to work, looks good! How can you add more details about the recent posts such as:

1) *NEW* icon next to each new post (if posted today)
2) name of forum where the post was made
3) name of person who wrote post
4) if posted today display "Posted TODAY", if yesterday display YESTERDAY, if older then yesterday display "posted x days ago"


I know I am asking for alot! hehehe

thanks!

jake

You can only make use of the information passed back in the array. To check what that information is, look at the function that is added to SSI. You'll see the array is:
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',



1) Note that *NEW* icon denotes unread in SMF and not posted today. Also, that icon also should be a link to the first unread post in the topic. Given the usage up-thread (foreach($result as $my)), this should put out the new icon as a link to first unread in topic:
if ($my['new'] == 0)
echo '<a href="', $scripturl . '?topic=' . $my['topic'] . '.msg' . $my['new_from'] . ';topicseen#new'"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';


2) Board name would be in $my['board']['name']

3) Name of most recent poster would be in $my['poster']['name']

4) This would depend on your settings for the forum (for 'Today' and 'Yesterday') and 'X days ago' is not something that's set up anywhere (would just show date). and that would be in $my['time'].
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jakemelon on February 11, 2007, 05:02:53 PM
Hi,

Something is not working for me, missing ',' or ';'.

I looked at the original vs the new piece, dont see anything missing.

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/content/j/a/k/jakemelon/html/Sources/Load.php(1733) : eval()'d code(35) : eval()'d code on line 12

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on February 11, 2007, 05:09:23 PM
Well, I'd have to see the code after you made the addition.

Maybe the previous statement wasn't closed prior to the insert 'if'.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jakemelon on February 11, 2007, 05:22:58 PM
Okay I got the ' and ; figured out but the output is not correct. Here is what the box looks like:

Recent Topics
I am new test topic
Welcome!
Welcome to SMF!

It does not show name of poster for some reason even tho it is in the code below, it only show the topic header....I am really new to this (as you can see), I really appreciate your help and patience!


Quoteglobal $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(1,2),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
echo '
';
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '<a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], $my['poster']['name'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '
';
}
echo '</span>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on February 11, 2007, 05:41:57 PM
That's because you embedded it within the link (within the <a href which doesn't end until after the #new)

Also, what version of SMF are you running. I didn't think that 'from' construction you have there for the 'new' was used in the 1.1 series.

Try this:
global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(1,2),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo ' in ', $my['board']['link'];
echo ' by ', $my['poster']['link'];
echo ' posted ', $my['time'];
echo '<br />';

}
echo '</span>';


You can pull out/rearrange the other fields tacked on there (board name as link to board, poster name as link to profile, and time posted).
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jakemelon on February 11, 2007, 06:10:43 PM
Alright this works like a charm! I am using 1.1.1 but I think original snipped I copied from the forum must have been older. I was able to make some tweaks to this now and it is perfect!

thank you!
jake
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: iowamf on February 11, 2007, 09:55:47 PM
Can you post the tweaks you made ?

BTW, you are right the original was done for an older ver of SMF/TP. 

Quote from: jakemelon on February 11, 2007, 06:10:43 PM
Alright this works like a charm! I am using 1.1.1 but I think original snipped I copied from the forum must have been older. I was able to make some tweaks to this now and it is perfect!

thank you!
jake

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jakemelon on February 27, 2007, 02:55:56 PM
global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(12,array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo ' in ', $my['board']['link'];
echo ' by ', $my['poster']['link'];
echo ' posted ', $my['time'];
echo '<br />';

}
echo '</span>';


This seems to only display last 5 posts, any way to increase this to 10 posts? I thought the $result=ssi_recentTopics_Include(12,array   controlled how many posts should show up but that is not it.

Any thoughts?

jake
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jacortina on February 27, 2007, 03:09:42 PM
Quote from: jakemelon on February 27, 2007, 02:55:56 PM
This seems to only display last 5 posts, any way to increase this to 10 posts? I thought the $result=ssi_recentTopics_Include(12,array   controlled how many posts should show up but that is not it.

Any thoughts?

Yes. The number is actually a maximum. The query uses an algorithm that only looks at the last (35 * num_request) posts. So if you only have 5 topics in the boar(s) that you haven't excluded which have had posts added in the last 420 (35*12) posts, then that's all you'll get.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: tick on February 27, 2007, 09:24:43 PM
Quote from: jakemelon on February 27, 2007, 02:55:56 PM
global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(12,array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo ' in ', $my['board']['link'];
echo ' by ', $my['poster']['link'];
echo ' posted ', $my['time'];
echo '<br />';

}
echo '</span>';


This seems to only display last 5 posts, any way to increase this to 10 posts? I thought the $result=ssi_recentTopics_Include(12,array   controlled how many posts should show up but that is not it.

Any thoughts?

jake

Ok I am new so i have to ask this question.  Do I put this code in a php box on the front page to make this work?  And how do I make it show the last 30 post
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: tick on February 28, 2007, 02:14:25 AM
ok I did add this to the frontpage block and when I enabled it I got an error .  How do I make this work.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: jakemelon on February 28, 2007, 02:25:50 AM
Hi,

Make sure you change these numbers to correspond to your own forums. I have 48 different ones so I listed the ones I wanted to show in my box. If you pasted all of them and you don't have 48 of them then it will probably not work.

array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48),'return');

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: tick on February 28, 2007, 02:48:40 AM
so you put the number of boards.  Say i have 8 board i would put 1,2,3,4,5,6,7,8






edit  this is the error I get.      Parse error: syntax error, unexpected T_VARIABLE in /home2/ibewfrie/public_html/Sources/Load.php(1747) : eval()'d code(35) : eval()'d code on line 1
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block but from another fo
Post by: denis on April 10, 2007, 03:38:03 AM
Hi,

I have 6 instances of the SMF/TP duo working. I would like the 1st SMF/TP duo to be able to fetch recent post from the 2nd, 3rd, 4th, 5th and 6th instances. Is this possible? IF so what would be the best approach?

Thanks

Denis.


Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on April 10, 2007, 03:41:57 AM
Are they on the same server? I don't think you could if not, but I'm not sure.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: denis on April 10, 2007, 03:44:23 AM
Yes they are on the same server and under the same domain.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on April 10, 2007, 03:46:19 AM
You could try in a phpbox to:

include('path/to/other/SSI.php');
Your recentopics code here

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: denis on April 10, 2007, 02:39:48 PM
Ok I will try this.

Thanks

Denis
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: khoking on May 18, 2007, 05:15:36 AM
Instead of using bullet, can it have line (hr) to separate each thread?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: denis on July 14, 2007, 02:05:25 PM
Ok. I am 3 months late  ;) but I am finally ready to try this. Unfortunately I do not know how to do this so I have a few questions.


Thank's
Ps.: I will try to do this myself but I am sure I will be back for more questions
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: snoopy_inc on September 13, 2007, 07:13:42 PM
I have a question... maybe i should post this in a new thread but i thought i would give it a bash here first.

I want to have a recent board that scrolls like an rss feed... that way i can use the same space the it would take for 5 recents but have 30 in it scrolling.... allows for more activity and such.... also a feature that disables it per profile so if the people dont like it they can stop it.

Is there something like this? if not can one do it?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: falguni1 on January 03, 2008, 01:50:22 AM
this is the topic I was searching.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: lebisol on January 03, 2008, 04:26:46 PM
this is better: http://www.tinyportal.net/index.php?topic=19339.0
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: spurry on June 28, 2008, 08:29:24 PM
hi all i am using this code in a php block


global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(1,2),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo ' in ', $my['board']['link'];
echo ' by ', $my['poster']['link'];
echo ' posted ', $my['time'];
echo '<br />';

}
echo '</span>';


but i dont want it to show this  Forum Help And Chat by ## posted Today at 01:15:36

could some one help me edit it out please?

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: spurry on June 28, 2008, 08:32:05 PM
ok dont worry i am stupid :uglystupid2:


global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(32),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

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

}
echo '</span>';

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on June 28, 2008, 08:40:38 PM
hehe, good job!
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: spurry on June 28, 2008, 08:51:18 PM
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on June 28, 2008, 10:07:02 PM
Change this code:
echo '<li>'.$my['link'].'</li>';

To this:
echo '<li style="padding-bottom: 8px">'.$my['link'].'</li>';

Change the number 8 to what you need.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: spurry on June 28, 2008, 10:12:51 PM
global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(32),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<li style="padding-bottom: 8px">'.$my['link'].'</li>';

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

}
echo '</span>';


ok but now it hase a dot and a image at each line?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: efil on July 28, 2008, 08:59:18 AM
Thanks,
Efil.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 05, 2008, 01:01:56 AM
Quote from: JRW on July 17, 2006, 10:54:15 PM
This is the code to put the bullets in the box, left aligned, and also add the "new" graphic for new posts:


$result=ssi_recentTopics(10,array(15),'return');
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


THIS IS working great for me..

but how can i put character limit?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on September 05, 2008, 01:08:16 AM
http://us2.php.net/manual/en/function.substr.php

Think you can figure it out? :D
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 05, 2008, 12:49:26 PM
Quote from: IchBinâ,,¢ on September 05, 2008, 01:08:16 AM
http://us2.php.net/manual/en/function.substr.php

Think you can figure it out? :D

sorry, i only can read it..  hehe
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on September 05, 2008, 04:37:27 PM
echo '<Li>'.substr($my['link'], 1, 20).'</Li>';

Start with character 1 and end with character 20.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 05, 2008, 06:44:00 PM
I have try a several way to put
echo '<Li>'.substr($my['link'], 1, 20).'</Li>';

in

$result=ssi_recentTopics(10,array(15),'return');
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


but its still fail...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on September 05, 2008, 07:53:45 PM
Perhaps you could explain what "but its still fail..." means? I have no idea what you are seeing or not seeing. Please explain.

BTW, what is this?
echo'<right>';

Never seen an HTML tag for right.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 06, 2008, 02:46:38 AM
its show url of msg not the msg exactly...

like

a href="http://myforum.net/index.php?topic=4341.msg25209# but not the msg in that url.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on September 06, 2008, 03:14:59 AM
It only shows the link because that is all the code was made to show. If you want the message to show, you'll have to pick some code in this topic that does what you want.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 06, 2008, 07:41:37 AM
after searching few times..

i cant find it yet...

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Loky on September 09, 2008, 10:50:30 AM
Any idea how can I order the list of topics by start date not by the last reply?

Thanks in advance.

EDIT:
I found a solution for it:
http://www.tinyportal.net/index.php?topic=14887.msg207401#msg207401

Cheers.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Ibexy on December 03, 2008, 06:27:45 PM
I am using the following code on my front page to display topics from selected boards (thanks to this thread). Its working 100% The problem is that some topics show which I dont want. Is there a way I can also select which topics show up from these selected boards? Something like entering the topic ID or something? Below is the code:

       
       
global $scripturl;

echo '<div style="overflow: auto; height: 700px">';

echo '
                        <table border="0" width="97%" cellspacing="1" cellpadding="4" class="bordercolor">
                               <tr><td colspan="3" class="titlebg"></td></tr> ';


       $what=ssi_recentTopics('500', array(11,40,43,45,46,54,55,58,60,65,70,71), 'array');


        foreach ($what as $topic)
        {
                echo '
                                <tr>
                                        <td class="windowbg" valign="middle">
                                                ', $topic['link'],' - [', $topic['board']['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>';
echo '</div>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on December 03, 2008, 08:59:55 PM
You can't randomly select topics to show or not show. That would be a completely different script in which you would have to specify topics instead of calling a function for "recent topics".
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Ibexy on December 03, 2008, 09:02:36 PM
ah I see.
Please, is there any code snippet somewhere I can use for this?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on December 03, 2008, 09:08:28 PM
I don't think I've ever seen a snippet like that made.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: villano666 on March 05, 2009, 02:58:23 PM
Hi, I'm using this code and I want the new icon and de "by" to be next to the thread link not to be above
How can I do this?

$result=ssi_recentTopics(10,array(11,12),'return');
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';
echo ' by ', $my['poster']['link'];
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


Thanks in advance
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on April 06, 2009, 07:02:30 AM
Quote from: smartmouse on January 24, 2007, 12:59:13 PM
Add this code in SSI.php file

Quotefunction ssi_recentTopics_NEW($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
   global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
   global $user_info, $modSettings, $func;

   $include_boards = empty($include_boards) ? array() : $include_boards;

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   // Find all the posts in distinct topics.  Newer ones will have higher IDs.
   $request = db_query("
      SELECT
         m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
      FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE t.ID_LAST_MSG = m.ID_MSG
         AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
         AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
         AND $user_info[query_see_board]
         AND ms.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_LAST_MSG DESC
      LIMIT $num_recent", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('
' => '')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      // Censor the subject.
      censorText($row['subject']);
      censorText($row['body']);

      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      // Build the array.
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
      );
   }
   mysql_free_result($request);

   // Just return it.
   if ($output_method != 'echo' || empty($posts))
      return $posts;

   echo '
      <table border="0" class="ssi_table">';
   foreach ($posts as $post)
      echo '
         <tr>
            <td align="right" valign="top" nowrap="nowrap">
               [', $post['board']['link'], ']
            </td>
            <td valign="top">
               <a href="', $post['href'], '">', $post['subject'], '</a>
               ', $txt[525], ' ', $post['poster']['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>
            <td align="right" nowrap="nowrap">
               ', $post['time'], '
            </td>
         </tr>';
   echo '
      </table>';
}

Then in administration panel create a new phpbox and paste this code:

Quoteglobal $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_NEW(10,array(9),'return');
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '
';
}
echo '</span>';

"9" is the board ID, change it to select the prefer board to be listed in the module.

I hope this can help, sorry for my english.

why the topic text is smaller after one by topic?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on April 06, 2009, 03:19:30 PM
It's hard to tell, because I can't tell what the code actually is. The code was posted in quote tags instead of code tags, which could very well have changed what the code was originally supposed to be. For example, in the line


echo '
                                                <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new"><img src="',
$settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" />[/url]';


Notice the [/url] at the end. That's BBC and should not be anywhere in php. It would take a whole lot of study to try to figure out what the original poster intended before they used the wrong tags. I would see if I could find something that was posted correctly.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on April 08, 2009, 03:00:34 PM
tq... hope u can solve it...
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on April 08, 2009, 04:42:04 PM
I can't solve anything unless I can see the code as it's supposed to be. When I said

QuoteI would see if I could find something that was posted correctly.
I meant, "If I were you, I would see ..." IOW, this is something you need to do before I can help you.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on April 09, 2009, 03:27:43 AM
nope... the code is in latest post i send bofore...

the topic go correctly in FF but not in IE.
In IE the topic go smaller after one topic(small) and topic(smaller) and topic(smallest)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on April 09, 2009, 04:14:02 AM
Can I see the page where the problem is?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: villano666 on April 25, 2009, 05:05:07 AM
I'm using this code
$result=ssi_recentTopics(5, array('34'), return);
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';

}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


I can't make it to show specific boards, it always shows every board there is
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: IchBin on April 25, 2009, 05:07:19 AM
If you are only getting it from one board, you don't need to use array. Also, if you do use an array with the board id's, the board id does not need single quotes around it because its a number.

$results=ssi_recentTopics(5, 34, 'array');

Or

$results=ssi_recentTopics(5, array(4,12,34), 'array');
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: villano666 on April 25, 2009, 05:21:00 AM
Thanks

Now it's showing this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')
AND 1
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAS
File: /home/jk000489/public_html/foros/SSI.php
Line: 368

Note: It appears that your database may require an upgrade. Your forum's files are currently at version SMF 1.1.8, while your database is at version 1.1.2. The above error might possibly go away if you execute the latest version of upgrade.php.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: villano666 on April 29, 2009, 02:48:59 PM
Any help?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on April 29, 2009, 03:45:39 PM
Wait a second. The code you're using, with ssi_recentTopics only excludes boards. So, if you have


$result=ssi_recentTopics(5, array('34'), return);


it means "Show the five most recent topics from every board except board 34." The whole point of this topic is that the original poster wrote code that allows you to display just the topics from the board or boards you specify.

You'll need to reread the topic.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: villano666 on April 29, 2009, 03:52:27 PM
So, if I want to show only one forum I should include all the other ones in the code?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on April 29, 2009, 04:45:25 PM
Yes. That's the way the original function was written. In the SSI.php file (which is where the function is), that array is named $exclude_boards.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: villano666 on April 29, 2009, 04:52:08 PM
Thanks, I see how it works now :)
Another question, how can I do so that the "new" image appears next to the title and not below?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 29, 2009, 08:11:55 PM
echo '
<table cellspacing="1" cellpadding="1" border="1" align="" width="200" summary="">
   <tbody>
       <tr>
           <td> </td>
           <td> </td>
       </tr>
       <tr>
           <td> </td>
           <td> </td>
       </tr>
   </tbody>
</table></td>';


with this table above i want to put this code below in each/every table.. how can i make it? its because i want to put multiple results for every tables thats only change in $result=ssi_recentTopics_NEW(10,array(26),'return');
i want to put it in custom page to show all boards with the newest topic.


global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$result=ssi_recentTopics_NEW(10,array(26),'return');

echo'<table border="0" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">
<tr><td width="692px"><div class="titlebg" align="center">New Topic In First Board</td></tr><tr>
<td>';
echo '<left>';
foreach($result as $my){

echo'<span class="smalltext3"><img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" /><nbsp;>'.$my['link'];
 echo "<br>";

}
echo '</span>';
echo'</td><td>';

echo'</td></td></tr>

</table>';



Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on September 29, 2009, 08:34:11 PM
I'll write back what I think you want and you tell me if I'm right, okay? :)

You want to have a link with the name of the topic that has the most recent post for each board on your forum. (Or maybe you want the topics with the 10 most recent posts. I'm not sure.) You want the links to print out in two columns.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 30, 2009, 06:17:35 AM
The second is nearly right... i want to make to colums that show two different board for every colums.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on September 30, 2009, 02:43:47 PM
You can give this a try. You'll need to put the numbers of the boards into the $boards array.


global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

// List the numbers of the boards you want to be displayed in this array
$boards = array(26, 25, 24, 23);

$new_row = 1;
echo '<table border="0" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">';

foreach ($boards as $board) {
if ($new_row)
echo '<tr>';
echo '
<td>';
$result=ssi_recentTopics_NEW(10,array($board),'return');
foreach($result as $my){

echo '
<span class="smalltext3">
<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />
<nbsp;>' . $my['link'] . '
</span><br>';
}
echo'
<td>';
if (!$new_row)
echo '</tr>';
$new_row = !$new_row;
}

echo '</table>';


I haven't really tested this because I don't have that function installed.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 30, 2009, 04:41:50 PM
Yes.. very nice help. TQ

Soo hope i can to another one.

1- How can i put the manual board/category in the top of every new topics list?

2- also i want to alignment the text topic to not go below the second button when the topic create two row like attach. i want the second row of topic to go below the topic itself

3- i want to show for board with three colums and two rows.

TQ for help.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on September 30, 2009, 05:12:16 PM
QuoteHow can i put the manual board/category in the top of every new topics list?

Do you mean that you want the name of the board at the beginning of the list?

Quotealso i want to alignment the text topic to not go below the second button when the topic create two row like attach. i want the second row of topic to go below the topic itself

So you want the program to shorten the name of the topic? That's going to mean a lot more programming.

Quotei want to show for board with three colums and two rows.

I wish you would have said three columns to start with. It means that I have to redo much of the code. As for rows, that would depend on how many boards you list.

If there's anything else you want, you need to tell me now.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 30, 2009, 05:28:20 PM
Do you mean that you want the name of the board at the beginning of the list?

Yes.. I want to put the name of board in the begining of list.

So you want the program to shorten the name of the topic? That's going to mean a lot more programming.

Nice ... but is not really what i think.. ok.. what i want is like what i write down

(button)When the topic is soo long.. its become
automatically go to second row.

(button)When the topic is soo long.. its become
           automatically go to second row. (this what i mean)

last.. with code you wrote.. there is no problem with row. but with colums when i try to make 3 colums.
tq
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on September 30, 2009, 05:55:20 PM
I see. You want the second line to be indented.

This should do it. You'll need to enter the names of the boards.


global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

// Enter the names of the boards you want to display, along with their numbers
$board[26] = 'Name of board 26';
$board[25] = 'Name of board 25';
$board[24] = 'Name of board 24';

$new_row = 1;
echo '<table border="0" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">';

foreach ($board as $name => $key) {
if ($new_row == 1)
echo '<tr>';
echo '
<td style="display: block; margin-left: 2em; text-indent: -2em;">' . $key . '<br />';
$result=ssi_recentTopics_NEW(10,array($key),'return');
foreach($result as $my){

echo '
<span class="smalltext3">
<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />
<&nbsp;>' . $my['link'] . '</span>
<br>';
}
echo'
</td>';
if ($new_row == 3) {
echo '</tr>';
$new_row = 0;
}
++$new_row;
}

echo '</table>';


If the indenting isn't right, you'll want to change this line:


<td style="display: block; margin-left: 2em; text-indent: -2em;">' . $key . '<br />';


If the indenting is too much, change the 2 to 1. If it's not enough, change the 2 to 3 or 4 (or whatever works).
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on September 30, 2009, 06:15:29 PM
when i enable block that contain this new code... i cant log in / see frontage of my site.. but can in forum. tq
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on September 30, 2009, 07:35:25 PM
Then there's an error somewhere. Can I see the page?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on October 01, 2009, 03:12:24 PM
Quote from: JPDeni on September 30, 2009, 07:35:25 PM
Then there's an error somewhere. Can I see the page?

There is nothing... it make long time to loading... but when the web appear it reset the login to guest automatically... registered user cant see it.  also to  guest.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 01, 2009, 03:19:28 PM
I need to have the URL to the page. Even though nothing may appear on the page, I might be able to get something from the source code.

Otherwise, you'll just have to take the code out and forget it, because I don't know what's wrong with it.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: alhaudhie on October 01, 2009, 03:39:17 PM

im not already yet to full open.
but if i enable to guest.. there is Internet Explorer cannot display the webpage
 
  Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.

Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: JPDeni on October 01, 2009, 03:59:27 PM
Then I suggest that you remove the code. I don't see what the problem is and I can't test this code on my own site.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Renegd98 on October 11, 2009, 12:33:56 PM
any idea why when i use this code it puts [/url] on the end?

It outputs this:
mpinones wishes to join -=NoBS=-[/url]

Code I am using:

global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(35),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

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

}
echo '</span>';
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on October 11, 2009, 01:12:37 PM
This example post originates from a form or something ?

I can't see why it would do that with the code you posted, perhaps it is introduced earlier.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: K-teto on March 29, 2010, 10:05:23 PM
Hi guys.

I've been using this slightly modified version of the code:
global $context, $scripturl, $settings, $txt;

//define the two images for read/unread replies
$bullet = '<img src="'.$settings['images_url'].'/TPdivider5.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider4.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(4,array(34),'return');
// show the board name
echo '<span class="smalltext"><b><a href="http://www.bjdoll.net/index.php?board=34.0">Newsposters</a>:</b><br /></span>';
// and now, the latests posts
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';
echo '<br />';

}
echo '</span>';

With some tables, I've got a nice looking recent posts block, conveniently sorted for the forum users.

It outputs something like this:
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg.photobucket.com%2Falbums%2Fv697%2FK-teto%2Frecentblock.png&hash=31c1cbc8fc92ccd7cd937cbf99312aa2e9612f34)
You can see it working at http://www.bjdoll.net
The darker bullets are for the unread replies, and the lighter ones, for... well, for the read ones  ;D

But now, some people are asking for more info about the threads showing in the front page, so... here is the question.
Does anyone know how to add the number of posts of the threads and the name of the last poster?
Something like this:
Ã,·Thread name [number of posts](last poster's name)

Any help will be greatly appreciated, this code has been of great help for my site.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: K-teto on April 11, 2010, 10:06:03 PM
Anyone?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on April 11, 2010, 10:14:22 PM
Hi there, I knew there was something that I was going to do..

I can probably help you with this, but it's getting late here so it will have to wait till morning - it's gone 10pm here and it's been a busy day.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: K-teto on April 11, 2010, 10:20:09 PM
Don't worry!
I'm happy to hear from you, I've been trying to do it myself, but with no luck.
I'm glad to know that you are at least interested in this, thanks, thanks a lot.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on April 12, 2010, 02:45:39 PM
No problem :)

I am presuming that this is a work in progress as there is no mechanism to change the colour of the bullets.

Also this line makes an invisible link... so I am guessing you are working on that :

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';


Anyway, if you want to get the number of replies then you need to adjust your ssi_recentTopics_Include function in SSI.php

Find :

m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,

Replace with :

m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, t.numReplies,


Find :

'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',

Add AFTER :

'numReplies' => $row['numReplies'],

Then in your code that you provided you can do something like this :

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

//define the two images for read/unread replies
$bullet = '<img src="'.$settings['images_url'].'/TPdivider5.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider4.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(4,array(34),'return');
// show the board name
echo '<span class="smalltext"><b><a href="http://www.bjdoll.net/index.php?board=34.0">Newsposters</a>:</b><br /></span>';
// and now, the latests posts
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">' , $my['link'] , ' (' , $my['numReplies'] , ') ' , $my['poster']['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';
echo '<br />';

echo '</span>';

}


Notice the new line changes :

echo '<span class="smalltext">' , $my['link'] , ' (' , $my['numReplies'] , ') ' , $my['poster']['link'];

You can see I introduced the new $my['numReplies'] variable and that I also used the already available $my['poster']['link']  So you just need to figure out how you want to use them.

I also moved your </span> up into the foreach loop where it needs to be to make correct HTML.

Is that enough to get you going ?
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on April 12, 2010, 02:50:28 PM
Oh yes, by the way I noticed you need to update your SMF, there is a newer one out which fixed a security issue.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: K-teto on April 12, 2010, 03:16:58 PM
I'm at work right now, but I will try as soon as I arrive at home.
Thanks a lot, you are my hero right now!
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on April 12, 2010, 03:22:25 PM
LOL well it's nice to be a hero  ;D
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: K-teto on April 13, 2010, 04:46:42 AM
Thanks for all, it's working perfectly.

This is the code I'm using rigth now, if anyone needs it.
global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider5.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider4.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(3,array(38,12),'return');
echo '<span class="smalltext"><b><a href="http://www.bjdoll.net/index.php?board=11.0">Quedadas y eventos</a>:</b><br /></span>';
foreach($result as $my){
echo '<span class="smalltext">';
if (!$my['new'] && $context['user']['is_logged'])
echo "$bullet2" ,'<a href="', $my['firstpost'],'">', $my['subject'], '</a> (<a href="', $my['href'] , '" title="', $my['preview'],'">' , $my['numReplies'] , '</a>)';
else
echo "$bullet" ,'<a href="', $my['firstpost'],'">', $my['subject'], '</a> (<a href="', $my['href'] , '" title="', $my['preview'],'">' , $my['numReplies'] , '</a>)';
echo ' [Últ: ', $my['poster']['name'],']';
   echo '<br></span>';
}


This way, the thread name links to the first post, the number of replies, links to the latest one, and the number, also, gives a preview of the last post on mouseover.
The poster name is not a link, because, with all these links, people can be confused, and all I need is something to make people interested in that thread, like... the name of someone they know, for example  ;)

Thanks again, I didn't even know about the existance of that SSI.php file, I'm learning a lot about PHP and SMF forums here, so... thanks for everything people, and special thanks for you, freddy888!

Oh, and sorry for my extremely bad english  ;D
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on April 13, 2010, 01:29:41 PM
Your English is fine K-eto :)

I am glad it worked out and that you are enjoying it too  :)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Jags on September 17, 2010, 01:30:44 PM
Hi,

I too needed this code, I just used the code posted above by K-Teto, I'm getting the following error.

Fatal error: Call to undefined function ssi_recentTopics_Include() in /home/just4dos/public_html/Sources/Load.php(1806) : eval()'d code(48) : eval()'d code on line 5

SMF- 1.1.11
TinyPortal v1.0 beta 4 Ã,© Bloc

Do I need to modify the ssi.php file too for the ssi_recentTopics_Include() function to work? Please guide. :)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on September 17, 2010, 03:16:17 PM
You need to add the extra code into SSI.php, by which I mean the ssi_recentTopics_Include() function that is somewhere back in this thread.  Just read through the thread and it's there somewhere.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Jags on September 24, 2010, 11:33:20 AM
Hi Freddy,

Thanks a lot for your reply.. I modified the SSI.php file and it is working fine.. I just need a bit more help.

I want this block to look similar to the default block of recent topics as in Tinyportal.
As is given in the right hand side of this forum..
http://just4dosti.com/forum/

The recent block given on left of this site (http://www.tinyportal.co.uk) is also similar to what I need.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on September 24, 2010, 11:43:57 AM
No problem.

If you are happy with the content then can you post the code you are using and I will change the layout.

If you could also post the  ssi_recentTopics_Include() function too that would be helpful.

Remember to put each bit of code in code (# button in editor) tags.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Jags on September 24, 2010, 12:20:38 PM
Wow.. It was prompt....  :)

Here's the code I'm using....

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

//define the two images for read/unread replies
$bullet = '<img src="'.$settings['images_url'].'/TPdivider5.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider4.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(4,array(19, 8),'return');
// show the board name
echo '<span class="smalltext"><b><a href="http://www.just4dosti.com/index.php?board=19.0">Newsposters</a>:</b><br /></span>';
// and now, the latests posts
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">' , $my['link'] , ' (' , $my['numReplies'] , ') ' , $my['poster']['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="http://just4dosti.com/', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';
echo '<br />';

echo '</span>';

}


SSI_RecentTopics_Include function

function ssi_recentTopics_Include($num_recent = 8, $include_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$include_boards = empty($include_boards) ? array() : $include_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
                  AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
                  AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
                  " . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? "
                  AND b.ID_BOARD != '$modSettings[recycle_board]'" : '') . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['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>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on September 24, 2010, 01:23:46 PM
Thanks, that helps a lot  O0

Try this block code out, it should look exactly like the layout you are using on your site :

global $context, $scripturl;

// limit, boards, method
$result=ssi_recentTopics_Include(4,array(19, 8),'return');

// show the board name
echo '
<span class="smalltext">
<b><a href="http://www.just4dosti.com/index.php?board=19.0">Newsposters</a>:</b><br />
</span>';

// and now, the latests posts

echo '
<ul class="tp_recentblock">';

foreach($result as $my)
{
echo '
<li style="overflow: auto">';

if (strlen($my['subject']) > 25)
{
echo '
<a href="' , $my['href'] , '">' , substr($my['subject'], 0, 24) . '...</a>';
}
else
{
echo $my['link'];
}

echo ' by ' , $my['poster']['link'] , ' [' , $my['time'] , ']';

// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo ' <a href="http://just4dosti.com/', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';

echo '
</li>';
}

echo '
</ul>';



I am not sure about this line near the end :

// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo ' <a href="http://just4dosti.com/', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';


It doesn't really do anything, it makes a link, but not a link you can click.  I left it in, just in case it is something you are working on.
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Jags on September 27, 2010, 08:57:29 AM
Freddy,

I think I messed up something, I just copied the code and used inside a new PHP block, I'm getting the following error..

Parse error: syntax error, unexpected ',' in /home/just4dos/public_html/Sources/Load.php(1806) : eval()'d code(48) : eval()'d code on line 4

I tried to figure it out, but my limited knowledge of PHP didn't work.. :)

The screenshot you posted is exactly what I need.

Quote from: Freddy on September 24, 2010, 01:23:46 PM

I am not sure about this line near the end :

// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo ' <a href="http://just4dosti.com/', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';


It doesn't really do anything, it makes a link, but not a link you can click.  I left it in, just in case it is something you are working on.
I had just copied the code from a post in this thread, I myself is not sure what the above code does....  :uglystupid2:

Sorry for my bad English and a late reply, I couldn't come online this weekend.. :)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on September 27, 2010, 12:49:58 PM
No problem.  It wasn't you, it was me.  When I changed the categories back to using your ones I inadvertently added in an extra ) bracket.

I edited the code above to remove it so try again now.

Sorry about that   :idiot2:

About that extra line, well to me it looks like it might be meant to show the 'new' icon for when a post is unread, except the code is incomplete.  Do you want that feature or are you not fussed ?

Your English is fine, I thought it was your first language  8)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Jags on September 27, 2010, 03:21:56 PM
Thanku soooooooo much Freddy.... It worked like a charm. I don't need the 'new' feature as of now....

Thanks for all the help provided..  :)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Freddy on September 27, 2010, 03:32:51 PM
Welcome :)
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: The Wizard on November 17, 2010, 04:09:06 PM
Link to my site: http://www.tribeuniverse.com
SMF version: 2.0 RC4
TP version: 1.0 RC1
Default Forum Language: English
Theme name and version:CurveLife
Browser Name and Version: IE
Mods installed:Tiny Portal, Aeva Media
Related Error messages: None

Hello:

I have been reading thought this thread and I trully dont know where to start on this I have tryed a few of the codes, but I don't think they work with the  version I have.

What I would like to do is list all the topics in a parent board of my choice. I want the topics to be links. I don't care about who wrote the topic, when it was posted ect.. I just want the name of the topic and make it a link. I would like the topics in alphabectical order, but I'm not married to the idea. So if anybody can give me the code and the steps to pull this off it would be helpfull.
Thanks
Title: Re: custom "Recent Topics from Board X, Y, Z only" php block
Post by: Inge Jones on August 08, 2012, 08:28:19 PM
Where do I put the function ssi_recentTopics_Include ?   Presumably I need to add it to some php source file?

Ok found it...