TinyPortal

Development => Block Codes => Topic started by: Greybrow on September 06, 2006, 06:08:09 PM

Title: Compact recent topics view
Post by: Greybrow on September 06, 2006, 06:08:09 PM
Just put this inside new php block, and use no matter the server and theme:
// Compact recent topics view
// Based on TinyPortal default block by BLOC
// Author: Greybrow
// Version: 2007-02-05 14:30
// Features:
// compact, uses smf icons for read/unread post,
// shows long topic, author, posting date on hover

// number of displayed topics
$last_topics_count='20';

// leave out the recycle board, if any
if(isset($modSettings['recycle_board']))
$bb=array($modSettings['recycle_board']);
else
$bb=array();

// get topics from SSI
$what=ssi_recentTopics($num_recent = $last_topics_count, $bb, $output_method = 'array');

// Output the topics
echo '<div style="width: 100%; overflow: hidden;">';
foreach($what as $w)
{
echo '<div style="white-space: nowrap;" class="smalltext">';
echo $w['new'] ? '<img src="' . $settings['images_url'] . '/new_none.gif" alt="+" border="0" style="vertical-align: middle;" />' : '<img src="' . $settings['images_url'] . '/new_some.gif" alt="-" border="0" style="vertical-align: middle;" />';
echo '<a href="'.$w['href'].'" title="'.$w['subject'];
echo "\n";
echo $w['poster']['name'];
echo "\n";
echo $w['time'];
echo '">';
echo strlen(un_htmlspecialchars($w['short_subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($w['short_subject']), 0, 22) . '...') : $w['short_subject'];
echo '</a></div>';
}
echo '</div>';

edit: 2006-01-30, removed unused variable, which was showing up as error in reports.
edit: 2006-02-05 4am, if the block makes strange gaps between columns ...cut
edit: 2006-02-05 2pm, I've changed the code, so you don't have to play with it by yourself, and I've fixed new-post icon vertical position
If you wish to use ie not friendly code:
change line:

echo strlen(un_htmlspecialchars($w['short_subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($w['short_subject']), 0, 22) . '...') : $w['short_subject'];

to:
echo $w['short_subject'];
Title: Re: Compact recent topics view
Post by: IchBin on September 06, 2006, 06:30:29 PM
Would be great if you could share a demo link or a screenshot for those that might want to try it. Thanks for sharing!
Title: Re: Compact recent topics view
Post by: Greybrow on September 06, 2006, 06:41:47 PM
Screenshots added.
Sorry, but in Polish only :)
Title: Re: Compact recent topics view
Post by: IchBin on September 06, 2006, 07:28:31 PM
Very cool! Thanks!
Title: Re: Compact recent topics view
Post by: Greybrow on January 30, 2007, 10:11:01 PM
A bit of update. Some errors fixed.
Title: Re: Compact recent topics view
Post by: Tanix on February 01, 2007, 01:41:42 AM
Neat, thank you very much.
Title: Re: Compact recent topics view
Post by: knat on February 01, 2007, 11:11:51 AM
very cool.. thanks for this  ;)
Title: Re: Compact recent topics view
Post by: houston on February 02, 2007, 05:50:32 PM
Great Mod, I like the design but it creates quite a large gap between my right side blocks column and my center blocks.
Title: Re: Compact recent topics view
Post by: Greybrow on February 02, 2007, 09:28:53 PM
I suppose you use IE. There is some strange problem with this browser not supporting "overflow: hidden;" in styles.
Try this. Instead of:
echo '">'.$w['short_subject'].'</a></div>';
put
echo strlen(un_htmlspecialchars($w['short_subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($w['short_subject']), 0, 22) . '...') : $w['short_subject'];

It will trim longer subjects to 25 letters.
Title: Re: Compact recent topics view
Post by: knat on February 03, 2007, 10:34:14 AM
i had same problem and try to use your fix for it but that makes the block go totaly nuts pushing the other blocks off the screen  :o

any other way to fix the problem with IE7 ?
Title: Re: Compact recent topics view
Post by: houston on February 03, 2007, 03:41:49 PM
Quote from: knat on February 03, 2007, 10:34:14 AM
i had same problem and try to use your fix for it but that makes the block go totaly nuts pushing the other blocks off the screen  :o

any other way to fix the problem with IE7 ?

Yup Me to.

Cheers
Title: Re: Compact recent topics view
Post by: Greybrow on February 05, 2007, 02:28:45 AM
I'm sorry, I didn't check this one :(
I forgot to add two lines of the code:
echo '">';
echo strlen(un_htmlspecialchars($w['short_subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($w['short_subject']), 0, 22) . '...') : $w['short_subject'];
echo '</a></div>';

It should work now.
Title: Re: Compact recent topics view
Post by: brianjw on February 05, 2007, 02:40:25 AM
Since there is no demo....
Is this like the one that you can use with TP in the recent posts? ???


Brianjw
Title: Re: Compact recent topics view
Post by: knat on February 05, 2007, 08:25:39 AM
Thanks, its working fine with the new code  ;)
Title: Re: Compact recent topics view
Post by: mietje on February 05, 2007, 01:57:18 PM
Working fine Greybrow, thank you.
Title: Re: Compact recent topics view
Post by: Greybrow on February 05, 2007, 01:59:26 PM
A bit of update again and screenshot added :)
Glad to hear, you like it :)
Title: Re: Compact recent topics view
Post by: mietje on February 05, 2007, 02:02:43 PM
Oh, do i need to replace code again then?
Title: Re: Compact recent topics view
Post by: Greybrow on February 05, 2007, 02:31:05 PM
If you like the vertical positon of the images, then no :)
Title: Re: Compact recent topics view
Post by: mietje on February 05, 2007, 02:32:32 PM
Okidoki  :)  Thx again.
Title: Re: Compact recent topics view
Post by: babjusi on May 15, 2007, 11:59:59 PM
thanx, it worked in my site
Title: Re: Compact recent topics view
Post by: k_4_kelly on June 03, 2007, 03:10:12 AM
I like this very much,
but all the chinese words from my forum are not able display correctly.
how do it fix the utf-8 problem?

thanks
Title: Re: Compact recent topics view
Post by: G6Cad on June 03, 2007, 10:04:09 AM
QuoteI like this very much,
but all the chinese words from my forum are not able display correctly.
how do it fix the utf-8 problem?

thanks

That is something you need to get help from Simplemachines.org
Forums posts and recent topics and the language settings for the same is their department of support  :)
Title: Re: Compact recent topics view
Post by: k_4_kelly on June 03, 2007, 11:31:30 AM
if i use the build-in recent topic from tiny portal
it works fine...

just the compact recent topics couldnt work properly... :'(

any ideas? ???