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

Recent

Welcome to TinyPortal. Please login or sign up.

April 14, 2024, 11:30:58 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,156
  • Total Topics: 21,219
  • Online today: 63
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online

[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.

alhaudhie

Edit by freddy888 : I've turned this thread over to discussion, instead the latest code for this block can be found here, in a easy to find place : The Code...

Feel free to talk more about what we can do with this code in this thread.

Original request....


Quote from: Mrcare on March 29, 2009, 07:28:33 AM
Quote from: JPDeni on March 29, 2009, 12:58:13 AM
Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)

Yes... hope one day anybody can make it....

maybe like this


i have find simila of this in

http://custom.simplemachines.org/mods/index.php?mod=2115

but what must i do? anybody can help to show new preview like that mod in frontpage with this code
global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<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 ($what as $topic)
{
   echo '<tr class="windowbg' , $bg ? '2' : '' , '">';
   $bg = !$bg;
    echo '<td valign="middle">', $topic['link'];

    // 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"/>[/url]';
   echo '</td>
      <td valign="middle" >', $topic['board']['link'], '</td>';
   echo '</td>
      <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;" />[/url]';
    echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>'

Freddy

There are errors in your code, but I will take a look at this.

Freddy

#2
I went over your code and corrected it.  You need to install the mod you mentioned for this to work.  This should do the trick, assuming you have that mod installed you can use this in a PHP block or article :


global $scripturl, $settings, $modSettings;

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

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="3" class="bordercolor">';
echo '
<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 ($what as $topic)
{
$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>
     <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>';


Because you are using SSI, there is a limit to what is shown in the message body.  With the default SSI settings it is limited to 128 characters.

You can change this by going to SSI.php and finding (around line 372)

if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';


Change both 128 to whatever you want...

Hope that get's you on track.  :)

Screenshot attached...I din't change my colours, that's why it doesn't match, but it works.

IchBin

Freddy, I think once the user has acknowledged it works for him you should split the topic and put your code into a different topic. This topic is 52 pages long... Any significant changes I think should be in a new topic. Hope thats cool.

NCSurfer

Freddy, Ichbin the code that you came up with along with the Nice Tooltips MOD worked great.

Thanks

Freddy

Ichbin, no problem with that, I'll just wait till Mrcare responds.

NCSurfer, Great, I am glad it worked and you're welcome :)

alhaudhie

finally i got it... thank you soo much.. nice helper...

Freddy

#7
Glad you got it sorted  :)

If you want to change the number of posts shown then change this line to what you want :

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

So just change 10 to however many you need.

NCSurfer

I do have one more question in regards to this statement Freddy...

QuoteYou can change this by going to SSI.php and finding (around line 372)

Code:

if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';


Change both 128 to whatever you want...

I can't find the location of this file in the default theme or my theme. Could you please tell me where it is?

Thanks

IchBin

SSI.php is in the top level of your forum. The root directory.