News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Random Post or Thread

Started by geezmo, May 03, 2006, 12:50:09 AM

Previous topic - Next topic

geezmo

How about a mod for random posts or threads? I want to have a certain section in the forum that automatically shows a random post (or thread)...

L.G.S

FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


geezmo

Anyone?

QuoteHow about a mod for random posts or threads? I want to have a certain section in the forum that automatically shows a random post (or thread)...

geezmo

I really like this. Any takers? Random post in the forum... :D

geezmo


Metal_13

#5
    
Display random post
http://www.tinyportal.net/index.php?topic=8111.0

$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');





Random post displayer with banner option from http://www.tinyportal.net/index.php?topic=8155.0
$ff_boardname = 'Advertisments and Banners'; // The forum name.
$ff_maxlength = 1024; // Limit the length of the post.
$ff_bannersystem = 0; // make this so it cuts out all text aside from the first link found. 
$ff_limitimagewidth = 150; // 0 = no limit.

$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 );

$ff_news = ssi_boardNews($ff_boardID, 1, $ff_randomtopic, $ff_maxlength,  'return' );

foreach ($ff_news as $ff_new)
{
$ff_new_subject = $ff_new['subject'];
$ff_new_body = $ff_new['body'];
$ff_new_href = $ff_new['href'];
$ff_new_link = $ff_new['link'];
$ff_new_replies = $ff_new['replies'];
$ff_new_new_comment = $ff_new['new_comment'];
$ff_new_new_poster = $ff_new['poster']['link'];

$ff_startstring = strpos ( $ff_new_body, '<a href' );
$ff_endstring = (strpos ( $ff_new_body, '</a>' ) + 4) - $ff_startstring;


if ($ff_startstring != -1 && $ff_bannersystem == 1)
{
$ff_new_body = substr ( $ff_new_body, $ff_startstring , $ff_endstring );

}

$ff_startstring = strpos ( $ff_new_body, '<img src' );

if ($ff_startstring != -1 && $ff_limitimagewidth > 0)
{
  $ff_x = 0;
 
  $ff_y = $ff_startstring;
 
  while ($ff_y != FALSE && $ff_x < 100)
  {
    $ff_x = $ff_x + 1;
    $ff_new_body = substr_replace($ff_new_body, '<img width=' . $ff_limitimagewidth . ' src', $ff_startstring, 8);
    $ff_startstring = strpos ( $ff_new_body, '<img src' );
    $ff_y = $ff_startstring;
  }

}

echo '<div class="tborder" style="margin-bottom: 0px;"><div class="titlebg" style="padding: 4px; font-weight: bold;"><a href="javascript: void(0);" onclick="toggle(11)"><img id="blockcollapse11" style="margin: 0;" align="right" src="http://www.sldrama.com/Themes/default/images/collapse.gif" border="0" alt="" ></a>';

echo $ff_new_subject;

echo '</div><div class="windowbg" style="padding: 4px; " id="block11"><div align="center">';

echo $ff_new_body;

echo '</div></div></div>';
}

Gryzor

Almost twelve years later...

Was looking for such functionality. Anyboday has any idea whether the mod above still works or not?

@rjen

TinyPortal is still very much alive: the code mentioned would need to be added into a TP block...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Advertisement: