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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,915
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

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

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

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

trvlnman

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.

Techdomain

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

trench

Thats for all Recent topics though. How do we get it working for one particular board?

iowamf

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:


  • exclude all boards (except the one board you want) by adding more "middle" parameters using the existing ssi_recentTopics function - the 1st parameter is the number of posts and the last parameter is the output type ... the middle paramaters are the boards to "exclude".
  • create your own ssi_recentTopics function to do nearly the opposite with the paramters so instead of excluding certain boards - it includes them (much simpler to maintain).

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.

Techdomain

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

iowamf

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


trvlnman

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.


akulion

Thanks this is perfect for the "In the News" 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

Puchu

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...

G6Cad

What kind of block have you added the code in to ?
It needs a PhP block to work

This website is proudly hosted on Crocweb Cloud Website Hosting.