Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

December 05, 2022, 08:23:06 AM

Login with username, password and session length
Members
  • Total Members: 3853
  • Latest: tty456
Stats
  • Total Posts: 193627
  • Total Topics: 21108
  • Online today: 83
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 0
Guests: 66
Total: 66

Author Topic: [Block] Recent TOPICS scrolling with hover over previews  (Read 7808 times)

0 Members and 1 Guest are viewing this topic.

Offline Freddy

  • Moderator
  • *
  • Posts: 1617
    • AiDreams
[Block] Recent TOPICS scrolling with hover over previews
« on: January 03, 2010, 09:54:42 AM »
Name of Snippet: Recent TOPICS 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 topics 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.
« Last Edit: January 03, 2010, 09:59:46 AM by freddy888 »

Offline Freddy

  • Moderator
  • *
  • Posts: 1617
    • AiDreams
Re: [Block] Recent TOPICS scrolling with hover over previews
« Reply #1 on: January 03, 2010, 09:55:46 AM »
Code: [Select]
// *********************************************************************
// A PHP block by Prometheus Fire and Freddy888
// Used alongside the NiceToolTips mod, will show
// scrolling recent topics with tool tip previews.

// @SMF Mods : http://custom.simplemachines.org/mods/index.php?mod=2115
// @Tiny Portal : http://www.tinyportal.net/index.php?topic=31643

// This version : 3 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();

   
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 in distinct topics.  Newer ones will have higher IDs.
// This is stripped down from SSI.php

$request = db_query("
SELECT
ms.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}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_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>
';
« Last Edit: May 23, 2010, 06:00:03 AM by freddy888 »