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: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 370
  • Total: 370

Display random post in a block

Started by Foolish Frost, September 05, 2006, 05:47:22 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Foolish Frost

Add this code to any block to allow it to display one random topic from the board.  Reply posts are comments.
This allows blocks that display things like quotes or tips of the day.

Just change the name of $ff_boardname to the same as the forum you want to have it display from, and $ff_maxlength limits the length of the post.

$ff_boardname = 'Tips and Tricks';
$ff_maxlength = 1024;

$ff_boards = ssi_topBoards( 100, 'return' );

foreach ($ff_boards as $ff_board)
{
if ($ff_board['name'] == $ff_boardname)
{
$ff_numtopics = $ff_board['num_topics'];
$ff_boardID = $ff_board['id'];
}

}

$ff_randomtopic = rand( 0, $ff_numtopics - 1 );

ssi_boardNews($ff_boardID, 1, $ff_randomtopic, $ff_maxlength, 'echo');

Max


3nd3r

Sorry for posting in this old thread. If anyone is considering better I open a new post, I'll do it.

My question is about a little modification on this block code to show one random post from any random forum.

I'm wondering how to do it, but I'm not a code expert... Maybe with a forum array?

Thanks in advance.

3nd3r

Sorry. I've found the solution here:
http://www.tinyportal.net/index.php?topic=23006.msg187161#msg187161

Please admins, delete these two posts if you consider it neccessary

IchBin

In the future, if you have any question about where you should post, you should read the posting guidelines. Thanks.

3nd3r

Sure, I'll do it.

My mistake was that I've made a search about "random post" and the solution appeared when I searched about "random topic"

My mistake. Please accept my apologies.

IchBin

Not a huge deal 3nd3r. Apologies accepted. :)

insanemustang

Mine posts the same quote on every refresh.

It's the most recent post on the board I set to display a random quote from.

This website is proudly hosted on Crocweb Cloud Website Hosting.