TinyPortal

Development => Block Codes => Topic started by: Foolish Frost on September 05, 2006, 05:47:22 PM

Title: Display random post in a block
Post by: Foolish Frost on September 05, 2006, 05:47:22 PM
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');
Title: Re: Display random post in a block
Post by: Max on September 05, 2006, 06:00:05 PM

Nice script Foolish Frost  :up:
Title: Re: Display random post in a block
Post by: 3nd3r on April 24, 2008, 10:34:24 AM
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.
Title: Re: Display random post in a block
Post by: 3nd3r on April 24, 2008, 11:49:52 AM
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
Title: Re: Display random post in a block
Post by: IchBin on April 24, 2008, 04:15:20 PM
In the future, if you have any question about where you should post, you should read the posting guidelines. Thanks.
Title: Re: Display random post in a block
Post by: 3nd3r on April 24, 2008, 04:34:42 PM
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.
Title: Re: Display random post in a block
Post by: IchBin on April 24, 2008, 04:43:34 PM
Not a huge deal 3nd3r. Apologies accepted. :)
Title: Re: Display random post in a block
Post by: insanemustang on April 29, 2008, 07:39:08 PM
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.