HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media


Welcome to TinyPortal. Please login or sign up.

May 28, 2023, 12:29:19 AM

Login with username, password and session length
  • Total Members: 3,864
  • Latest: Joonoz
  • Total Posts: 194,353
  • Total Topics: 21,156
  • Online today: 142
  • Online ever: 3,540
  • (September 03, 2022, 01:38:54 AM)
Users Online
Users: 0
Guests: 88
Total: 88

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.


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:

echo '<list>';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
echo '</list>';
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).


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


try <ul> instead of <list> and attach a padding or margin to <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.


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?


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


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


Where do we put the code?

Make a phpbox?

EDIT: Got it, but how do I make the bullets a little to the left?



echo'<div align="left">';
echo '<list>';
foreach($result as $my){
echo '<li>'.$my['link'].'</li>';
echo '</list>';
echo '<span class="smalltext">SmallText</span>';


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?

    // leave out the recycle baord, if any
    $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'];
               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



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