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

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 05:10:07 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 108
  • Total: 109
  • lurkalot

[Discussion] Recent topics table with hover over previews.

Started by alhaudhie, September 14, 2009, 04:58:20 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Freddy

In other words the subject...

Try this :

$popup = NiceTooltip($topic['preview'], substr($topic['subject'], 0, 50) . '...');

alhaudhie

Quote from: freddy888 on March 16, 2010, 09:36:42 PM
In other words the subject...

Try this :

$popup = NiceTooltip($topic['preview'], substr($topic['subject'], 0, 50) . '...');

yes got it..
but .. hehe
what i mean the subject in the block itself.. original subject.not preview. tq

Freddy

You really need to explain things more fully my friend, as I told someone else today we are not mind readers...

Here you go, find this line :

<a href="' , $topic['href'] , '"' , $popup , '>' , $topic['subject'] , '</a>';

Change it to :

<a href="' , $topic['href'] , '"' , $popup , '>' , substr($topic['subject'], 0, 50) , '...</a>';

Just change the 50 until you get what you want.

alhaudhie

Quote from: freddy888 on March 17, 2010, 01:10:20 PM
You really need to explain things more fully my friend, as I told someone else today we are not mind readers...

Here you go, find this line :

<a href="' , $topic['href'] , '"' , $popup , '>' , $topic['subject'] , '</a>';

Change it to :

<a href="' , $topic['href'] , '"' , $popup , '>' , substr($topic['subject'], 0, 50) , '...</a>';

Just change the 50 until you get what you want.

sorry for all the trouble. but the existing short subject  also have [...] . So how to remove [...] from subjects who had an existing short subject?.

Again.. sorry my friend for the trouble...

Freddy

Okay, try changing that line to this instead :

<a href="' , $topic['href'] , '"' , $popup , '>' , strlen($topic['subject']) > 50 ? substr($topic['subject'], 0, 50) . '...' : $topic['subject'] , '</a>';

That should do it.  :D

If you want to shorten them you will need to change both 50s.

alhaudhie

Quote from: freddy888 on March 18, 2010, 10:33:15 AM
Okay, try changing that line to this instead :

<a href="' , $topic['href'] , '"' , $popup , '>' , strlen($topic['subject']) > 50 ? substr($topic['subject'], 0, 50) . '...' : $topic['subject'] , '</a>';

That should do it.  :D

If you want to shorten them you will need to change both 50s.
wonderful. thank you for help


alhaudhie

Quote from: freddy888 on January 11, 2010, 05:10:39 PM
OK here is what I came up with :

This will show the 'hot', 'very hot', 'locked' etc icons for each topic.


// *********************************************************************
// A PHP block by Freddy888 and MrCare
// !!Modified to show icon, number of views and replies.!!
// !!Modified to show topic class icons (hot, locked etc)!!
// Used alongside the NiceToolTips mod, will show
// recent topics in a table with tool tip previews.

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

// This version : 11 Jan 2010
// *********************************************************************

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

$num_recent = 8;

// Config end.


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

// 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;


// Icons...
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';


// Find all the posts in distinct topics.  Newer ones will have higher IDs.
// Stripped down from SSI.php ssi_recentTopics() function.

$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, t.numReplies, t.numViews, t.ID_POLL, t.isSticky, t.locked,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ",
LEFT(m.body, ". (!empty($modSettings['NiceTooltips_lenght']) ? $modSettings['NiceTooltips_lenght'] : 384) .") AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
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) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude) . ")") . "
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();
$topic_ids = array();

while ($row = mysql_fetch_assoc($request))
{
// Build the array.
$posts[$row['ID_TOPIC']] = array(
'board' => array(
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'viewsreplies' => $row['numViews'] . '/' . $row['numReplies'],
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
);

// Get the class of the post (normal, hot, very hot etc)...
determineTopicClass($posts[$row['ID_TOPIC']]);

// Add this topic to the list of topic ids, so we can check later if the
// user has posted in this topic.
$topic_ids[] = $row['ID_TOPIC'];
}

mysql_free_result($request);

// Check if user has posted in a topic - adapted from MessageIndex.php
if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER
GROUP BY ID_TOPIC
LIMIT " . count($topic_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
$posts[$row['ID_TOPIC']]['is_posted_in'] = true;
$posts[$row['ID_TOPIC']]['class'] = 'my_' . $posts[$row['ID_TOPIC']]['class'];
}
mysql_free_result($result);
}




// Now for the output...

echo '
<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">
<tr class="catbg3">
<td align="center" colspan="3">Subject</td>
<td align="center">Board</td>
<td align="center">Views/Replies</td>
<td align="center">Member</td>
<td align="center">Date & Time</td>
</tr>';

$bg=false;

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

echo '
<tr class="windowbg' , $bg ? '2' : '' , '">';

$bg = !$bg;
   
echo '
<td class="windowbg2" valign="middle" align="center" width="5%">
<img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />
</td>
<td class="windowbg2" valign="middle" align="center" width="5%">
' , $topic['icon'] , '
</td>
<td>
<a href="' , $topic['href'] , '"' , $popup , '>' , $topic['subject'] , '</a>';

    // Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" valign="absmiddle" /></a>';

echo '
</td>
<td valign="middle">' , $topic['board']['link'], '</td>';

echo '
<td valign="middle" align="center">' , $topic['viewsreplies'] , '</td>';

echo '
<td valign="middle" >', $topic['poster']['link'], '</td>
<td valign="middle" >';

if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '
<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';

echo '
<span class="smalltext">', $topic['time'], '</span>
</td>
</tr>';
}

echo '
</table>';


i tried to put it with smf rc3 and tp 1.0 beta 5 but it show nothing. tq

Freddy

Thanks MrCare, yes this won't work in SMF 2 because of the changes made in SMF 2.

Are you just reporting this or do you need help figuring it out ?

Blue Steel

Hi,

I've got my php recent topics block with tooltip preview working now;)

Running TP 1.0 Beta5, SMF2 RC2 and NiceTooltips 1.6

I've got this php code block set up as my recent topics center block


// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $context, $settings, $options, $scripturl, $txt, $modSettings, $sourcedir;

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

$what=ssi_recentTopics('40', NULL, 'array');

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

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

$what=ssi_recentTopics('10', NULL, 'array');
echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg2"><td valign="middle">Subject</td><td valign="middle">Board</td><td valign="middle">Poster</td><td valign="middle">Time</td></tr>';

foreach ($what as $topic)
  {
   // Generate the popup.
$popup = NiceTooltip($topic['preview'], $topic['subject']);

      echo '<tr><td class="windowbg2" valign="middle">';
      echo '<a href="', $topic['href'], '"', $popup , '>', $topic['subject'],' </a>', $topic['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $topic['topic'] . '.msg' . $topic['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" >', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" >';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';

don't forget to set number of characters to display to more than 0. lol under admin > modifications < misacelanous .. LOL