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

Recent

Welcome to TinyPortal. Please login or sign up.

March 28, 2024, 08:51:17 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,104
  • Total Topics: 21,212
  • Online today: 212
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 209
  • Total: 210
  • illori

[Block] Recent POSTS scrolling with hover over previews.

Started by freddy888, January 02, 2010, 08:33:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Freddy

Name of Snippet: Recent POSTS scrolling with hover over previews
SMF/TP versions tested: SMF 1.1.11; TinyPortal v1.0 beta 4
Block Type: PHP
Author: Prometheus Fire, Freddy888 and digger at SMF
Link to Discussion: Click here....
Requirements : The block uses the NiceToolTips MOD at SMF in combination with the block code below.  So you will have to install that module too.

Note : sometimes bbc code may not be handled correctly - this is something for the NiceToolTips maker to work on - so try requesting that they work on that.

Description: Will scroll recent posts upwards in a marquee and show previews when a user hovers over them.

This code excludes the recycle boards, omits private boards that a user cannot see and uses the NiceToolTips settings to limit the number of characters shown.


Freddy

#1
// *********************************************************************
// A PHP block by Prometheus Fire and Freddy888
// Used alongside the NiceToolTips mod, will show
// scrolling recent posts with tool tip previews.

// @SMF Mods : http://custom.simplemachines.org/mods/index.php?mod=2115
// @Tiny Portal : http://www.tinyportal.net/index.php?topic=31632
// SMF/TP versions tested: SMF 1.1.11; TinyPortal v1.0 beta 4
// This version : 2 Jan 2010
// *********************************************************************

// Cofiguration, set the number of posts to show:

$num_recent = 8;

// Config end.


global $settings, $modSettings, $db_prefix, $user_info;

// First get all the NiceToolTip javascript in place if it's needed.
// The javascript is not needed when we are in a board as the NiceToolTip module
// will already have loaded it.  We just need to add it if we are elsewhere...

// So add the code if we are not in a board
// OR When viewing a topic the board is also set,
// so we need to add the javascript then too...

if (!isset($_GET['board']) || isset($_GET['topic']))
echo '
<style type="text/css">
.nice_tooltip_fgclass {
background-color: ' . $modSettings['NiceTooltips_FGCOLOR'] . ';
opacity: ' . $modSettings['NiceTooltips_OPACITY'] / 100 . ';
}
.nice_tooltip_bgclass {
background-color: ' . $modSettings['NiceTooltips_BGCOLOR'] . ';
opacity: ' . $modSettings['NiceTooltips_OPACITY'] / 100 . ';
}
</style>

<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . (!empty($modSettings['NiceTooltips_scripturl']) ? '/' . $modSettings['NiceTooltips_scripturl'] : '') . '/overlib_mini.js"></script>

<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . (!empty($modSettings['NiceTooltips_scripturl']) ? '/' . $modSettings['NiceTooltips_scripturl'] : '') . '/overlib_adaptive_width.js"></script>
';

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


$ex_aeva = empty($modSettings['aeva_enable']) ? 0 : 1;
$modSettings['aeva_enable'] = 0;
   
if ($exclude === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude = array($modSettings['recycle_board']);
else
$exclude = empty($exclude) ? array() : $exclude;


// Find all the posts.  Newer ones will have higher IDs.
// This is stripped down from SSI.php

$request = db_query("
SELECT
m.subject, m.ID_TOPIC, m.ID_MSG,
LEFT(m.body, ". (!empty($modSettings['NiceTooltips_lenght']) ? $modSettings['NiceTooltips_lenght'] : 384) .") AS body
FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($num_recent, 5)) . "
AND b.ID_BOARD = m.ID_BOARD" . (empty($exclude) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude) . ")") . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
   
$posts = array();

while ($row = mysql_fetch_assoc($request))
{
// Build the array.
$posts[] = array(
'subject' => $row['subject'],
'preview' => $row['body'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
);
}
mysql_free_result($request);

$modSettings['aeva_enable'] = $ex_aeva;

   
// Output the topics

echo '
<marquee  behavior="scroll" direction="up" height="150px" scrolldelay="1" scrollamount=" 1" onmouseover="this.stop()" onmouseout="this.start()">';

echo '
<ul class="tp_recentblock">';

foreach($posts as $w)
{
// Generate the pop up...
$popup = NiceTooltip($w['preview'], $w['subject']);

echo '
<li style="overflow: auto;"><a href="' , $w['href'] , '"' , $popup , '>' , $w['subject'] , '</a></li>';
}

echo '
</ul>
</marquee>
';