TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 19, 2024, 11:51:05 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 128
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 59
  • Total: 59

Random post displayer with banner option

Started by Foolish Frost, September 06, 2006, 09:26:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Foolish Frost

Like my last offering, this one allow you to diplay images in a sidebar and limit the size of images displayed in it.  Just tinker with it and see what things you can do with it.

The subject is the Block title, and the body is the block body as well.


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