Need help modding 'display first message as hover title'-mod

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Need help modding 'display first message as hover title'-mod
NoFantasy
CZ Newbie
NoFantasy has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Apr 07, 2005
0.00 posts per day
Posts: 2
Points: 300
   
Similar to the mod at this site, this mod is supposed to show first lines of the first post when hovering over the title, before entering the thread itself.
I found the original at [ Register or login to view links on this board. ] but it needs of course some modding.
I would appreciate any help and/or suggestions if this mod is already available for BBtoNuke anywhere. I use Nuke 7.5, Patched, BBtoNuke 2.17 myself.

OPEN
viewforum.php

FIND
include($phpbb_root_path . 'common.'.$phpEx);

AFTER, ADD
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);

FIND
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

AFTER, ADD
//
// display first message as title by emrag ;)
//
      //
      // character limit for hover title
      //
      $chr_limit = '1000';

      $sql = "SELECT p.*,  pt.post_text, pt.post_id, pt.bbcode_uid
         FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt
         WHERE p.topic_id = $topic_id
            AND pt.post_id = p.post_id
         ORDER BY p.post_time
         LIMIT 1";
      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
      }

      $row = $db->sql_fetchrow($result);
      $first_post = $row['post_text'];
      $first_post_bbcode_uid = $row['bbcode_uid'];

   //
   // if message is longer than character limit break message
   // and add "..." at the last of message
   //
   if (strlen($first_post) > $chr_limit)
   {
      $first_post = substr($first_post, 0, $chr_limit);
      $first_post .= '...';
   }

   //
   // If the board has HTML off but the post has HTML
   // on then we process it, else leave it alone
   //
   if ( !$board_config['allow_html'] )
   {
      if ( $row['enable_html'] )
      {
         $first_message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $first_post);
      }
   }

   //
   // Parse message for BBCode if required
   //
   if ( $board_config['allow_bbcode'] )
   {
      if ( $first_post_bbcode_uid != '' )
      {
         $first_post = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($first_post, $first_post_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $first_post);
      }
   }

   //
   // Parse smilies
   //
   if ( $board_config['allow_smilies'] )
   {
      if ( $row['enable_smilies'] )
      {
         $first_post = smilies_pass($first_post);
      }
   }

   //
   // replace \n with <br />
   //
   $first_post = preg_replace("/[\n\r]{1,2}/", '<br />', $first_post);

   //
   // escape from double and/or single quotes
   //
   $first_post = str_replace(array('"', '\''), array('&quot;', '\\\''), $first_post);

   //
   // if message have [hide] [/hide] tags
   // there will be an error message instead of normal message
   //
   if ( preg_match("/\[hide\]/i", $first_post) && preg_match("/\[\/hide\]/i", $first_post))
   {
      $first_post = '<b>Protected message:</b><br>If you are a <b>*registered user*</b> :<br>you must post a reply to this topic to see the message';
   }

//
// display first message as title by emrag
//


FIND
'TOPIC_FOLDER_IMG' => $folder_image,
'TOPIC_AUTHOR' => $topic_author,

BEFORE, ADD
'FIRST_POST' => $first_post,


OPEN
templates/subsilver/viewforum_body.tpl
FIND
at the top of the page
<form method="post" action="{S_POST_DAYS_ACTION}">
  <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">

BEFORE, ADD
at the top of the page
<!-- The javas-cript presents here comes from MyCalendar 2.2.6 from MojavLinux -->
<s-cript language="Javas-cript" type="text/javas-cript">
<!--
var agt = navigator.userAgent.toLowerCase();
var originalFirstChild;

function createTitle(which, string, x, y)
{
   // record the original first child (protection when deleting)
   if (typeof(originalFirstChild) == 'undefined')
   {
      originalFirstChild = document.body.firstChild;
   }

   x = document.all ? (event.clientX + document.body.scrollLeft) : x;
   y = document.all ? (event.clientY + document.body.scrollTop) : y;
   element = document.createElement('div');
   element.style.position = 'absolute';
   element.style.zIndex = 1000;
   element.style.visibility = 'hidden';
   excessWidth = 0;
   if (document.all)
   {
      excessWidth = 50;
   }
   excessHeight = 20;
   element.innerHTML = '<div class="bodyline"><table width="300" cellspacing="0" cellpadding="0" border="0"><tr><td><table width="100%"><tr><td><span class="gen">' + string + '</span></td></tr></table></td></tr></table></div>';
   renderedElement = document.body.insertBefore(element, document.body.firstChild);
   renderedWidth = renderedElement.offsetWidth;
   renderedHeight = renderedElement.offsetHeight;

   // fix overflowing off the right side of the screen
   overFlowX = x + renderedWidth + excessWidth - document.body.offsetWidth;
   x = overFlowX > 0 ? x - overFlowX : x;

   // fix overflowing off the bottom of the screen
   overFlowY = y + renderedHeight + excessHeight - window.innerHeight - window.pageYOffset;
   y = overFlowY > 0 ? y - overFlowY : y;

   renderedElement.style.top = (y + 15) + 'px';
   renderedElement.style.left = (x + 15) + 'px';

   // windows versions of mozilla are like too fast here...we have to slow it down
   if (agt.indexOf('gecko') != -1 && agt.indexOf('win') != -1)
   {
      setTimeout("renderedElement.style.visibility = 'visible'", 1);
   }
   else
   {
      renderedElement.style.visibility = 'visible';
   }
}

function destroyTitle()
{
   // make sure we don't delete the actual page contents (javas-cript can get out of alignment)
   if (document.body.firstChild != originalFirstChild)
   {
      document.body.removeChild(document.body.firstChild);
   }
}
//-->
</s-cript>

FIND
<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle"

AFTER, ADD
onmouseover="createTitle(this, '{topicrow.FIRST_POST}', event.pageX, event.pageY);" onmouseout="destroyTitle();"


The javascript itself seems to be working (without any content of course), but i'm having trouble getting the rest to work.


Back to top Reply with quote
#2   re: Need help modding 'display first message as hover title'
Dauthus
CZ Addict
 Codezwiz Site Donator
Dauthus has been a member for over 20 year's 20 Year Member
usa.gif illinois.gif
Age: 60
Gender: Male
Website:
Status: Offline
Joined: Mar 17, 2004
0.06 posts per day
Posts: 426
Points: 15,917
   
See if this is the same thing. It has already been ported. Mouse Hover Topic Preview
[ Register or login to view links on this board. ]




_________________
[ Register or login to view links on this board.]
Vivere disce, cogita mori
Back to top Reply with quote
#3   re: Need help modding 'display first message as hover title'
NoFantasy
CZ Newbie
NoFantasy has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Apr 07, 2005
0.00 posts per day
Posts: 2
Points: 300
   
Thanks!
It seems to be much of the same basics, but without the javascript used to show content of the message. I have tested a similar mod, and it had some issues with FireFox.

I will take a closer look into this anyway, to se if i can crossbreed the scripts and make the use of the javascriptcode. I'm no programmer, so if you have time, and feel like it, please go ahead and give it a try.



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum