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

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.


Freddy

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.

K-teto

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.

Freddy

#153
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 ?

Freddy

Oh yes, by the way I noticed you need to update your SMF, there is a newer one out which fixed a security issue.

K-teto

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!

Freddy


K-teto

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

Freddy

Your English is fine K-eto :)

I am glad it worked out and that you are enjoying it too  :)

Jags

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

This website is proudly hosted on Crocweb Cloud Website Hosting.