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

Recent

Welcome to TinyPortal. Please login or sign up.

May 19, 2024, 03:32:14 PM

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: 1
  • Guests: 49
  • Total: 50
  • tino

[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 1 Guest are viewing this topic.

Freddy

For the length of the body refer back to my original posting here :

http://www.tinyportal.net/index.php?topic=30884.msg246639#msg246639

You need to change the SSI.php file.

As for the bbc code - when I tried here with bold, it just strips out the tags, and when I use the url code, it just shows the text part, so I'm not sure why that is happening for you.

Can you give me an example of something that shows this behaviour ?  You can post it in a code block....

prometheus fire

#31
visit http://leafboxtea.com

The scrolling box on the right has this block code in it. I was able to adjust the SSI.php to increase the character limit.  I'll leave that block up until you respond before I switch it out again with my non-tooltip block.  But in it you can see how it fails to parse the bbc.  The URL shows up with it ignoring the text. It's pretty sloppy looking. Could this be because the character limit is too short causing it not to read the entire code and tags?

I'd love to get this tooltip feature functioning right since it'll certainly drive traffic further into my website

Freddy

Mornin'.   Thanks for the link - I see what you mean from the first link in that list.

I've had a proper look at the SSI.php function and I think you are right - the database query is only gathering the first 384 characters, so this looks like it is causing the end of the bbc tags to be cut off.

I think I will try extracting the database query from SSI.php and adjusting it so it works the way we want.  This code can just go in a block, or that function you were using.  And then forget about using SSI.php too.

If it is done that way, I think this will also mean we can forget about that 128 character adjustment in SSI.php too - as it would then be using just the limit set by the mod.

I can't do this right away though, as I am just about to go out.  I will be back later tonight when I will take a better look at it.

Freddy

#33
OK, please don't post any more here about the scrolling box version, this thread is departing too much from the original subject.

So...here is the new thread for Prometheus' request for a scrolling recent topics block with hover over tips : http://www.tinyportal.net/index.php?topic=31639

Also this applies to everything so far;

I have found the problem with the bbc code also occurs when the ToolTips are used normally in a board - I mean 'out-of-the-box'...

So the best way to remedy that is for people ask the original mod maker to work on that bug.  The problem is that the mod only grabs a set length of characters from the database - so this means it can chop url's in half.   I think what they need to do is grab the whole of the post body from the database and then work out a way to do it within the NiceTooltip() function so that urls don't get chopped up.

Update : I think I have improved on what we have done so far - I stripped down the SSI.php code and put it in the actual block instead.  I also made it use the NiceToolTips settings to limit the characters.  So no more messing around with SSI.php - now it is all done in one handy block.

The code can be found here : http://www.tinyportal.net/index.php?topic=31642

alhaudhie

nice work..

with a new code you wrote

// *********************************************************************
// A PHP block by Freddy888 and MrCare
// Used alongside the NiceToolTips mod, will show
// recent posts 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 : 3 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;   

   
// 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,
      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
   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();

while ($row = mysql_fetch_assoc($request))
{
   // Build the array.
   $posts[] = 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']),
   );
}

mysql_free_result($request);
   
   
// Now for the output...

echo '
   <table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">
      <tr class="catbg3">
         <td align="center">Subject</td>
         <td align="center">Board</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 valign="middle">
            <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" align="right", valign="absmiddle" /></a>';
   
   echo '
         </td>
         <td valign="middle" >', $topic['board']['link'], '</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 want to add :
1- msg icon
2- num replies
3- num views

hope u can help.

tq soo much  O0

Freddy

Here's what I came up with ....

Screenshot attached...


// *********************************************************************
// A PHP block by Freddy888 and MrCare
// !!Modified to show icon, number of views and replies.!!
// 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 : 10 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,
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();

while ($row = mysql_fetch_assoc($request))
{
// Build the array.
$posts[] = 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'],
);
}

mysql_free_result($request);


// Now for the output...

echo '
<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">
<tr class="catbg3">
<td align="center" colspan="2">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 valign="middle">
' , $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" align="right", 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>';

alhaudhie

very very nice work... tq

:smitten:

how about topic status? like normal topic,  hot topic icon ... etc?

IchBin

Good love Mrcare. Four pages of you requesting feature after feature. How about you think about this long and hard and make up your mind at what you actually want? lol This would be a lot easier for Freddie if he didn't have to keep coming back for every little thing I'm sure.

alhaudhie

Quote from: IchBinâ„¢ on January 11, 2010, 02:15:36 AM
Good love Mrcare. Four pages of you requesting feature after feature. How about you think about this long and hard and make up your mind at what you actually want? lol This would be a lot easier for Freddie if he didn't have to keep coming back for every little thing I'm sure.

tq..
i think to put topic the colum to show
Topic you have posted in
Normal Topic
Hot Topic (More than 10 replies)
Very Hot Topic (More than 15 replies)
Locked Topic
Sticky Topic
Poll

tq.. if its easier way to Freddie to make it im very glad.. if he cant/or have a problem to make it, im very glad now.. because what i want, is getting now.. tq for all...


Freddy

#39
Yes I am afraid IchBin is right, I do get a bit fed up if people keep changing their mind and keep adding more and more things.  I'm not here to answer to people's every whim after all...

But anyway, Mrcare you have been polite and clear about what you want and I am happy to help you.  Just one question though - is this finally what you want ? lol