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

Recent

Welcome to TinyPortal. Please login or sign up.

May 02, 2024, 11:18:12 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,178
  • Total Topics: 21,220
  • Online today: 127
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 88
  • Total: 89
  • @rjen

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 1 Guest are viewing this topic.

iowamf

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!)


bloc

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.

kip

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?

IchBin

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

kip

Okay, fair enough.  I'll have to look into this further.  Thanks!

dknoppix

#5
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

IchBin

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

iowamf

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

    }
}


iowamf

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