[ABD] Topic Hover Preview 0.3.1

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
raptor5001
Registered User
Posts: 36
Joined: Mon Mar 19, 2007 5:09 pm

[ABD] Topic Hover Preview 0.3.1

Post by raptor5001 »

MOD Title: Topic Hover Preview
MOD Description: Hovering over topic links will show text from the first post of that topic.
MOD Version: 0.3.1
phpBB3 Version: RC4 (compatibility with RC5 has not been tested)

MOD Format:
Image

MOD Download: http://www.filepub.com/public/10515/Top ... review.zip

This is just like vB's feature, but improved, and the number of characters shown can be changed easily. It strips out the raw bbcode in the format like [b:0ab34], therefore leaving normal brackets untouched.

0.1.1: Smileys now parse, attachment code is removed, and newlines are converted to spaces.

0.1.2: Two more edits, but a MAJOR increase in speed. Only one query now, instead of one per topic (this should've been done originally ;)).

0.1.3: Announcements now show their post text. Shadow topics were tested and work already.

0.2.0 Added in Xabi's JavaScript proposal of using Swazz.org's boxover code and made minor tweaks for its usage.

0.2.1 Fixed long URL and long text in general problem. Also added in johnesku's last post alternative in the contrib/ directory.

0.2.2 Very minor char counting bug fixed. Now works for topic lists returned from topic searches! (search.php)

0.3.0 Updated for RC4 and now using a modified version of tas2580's JavaScript from the AJAX Userinfo mod.

0.3.1 Some bug-proofing and subsilver2 install instructions added.

Demo Screenshot:
Image

This MOD has been abandoned: http://www.phpbb.com/community/viewtopi ... 2#p3178272
Last edited by raptor5001 on Sat Sep 01, 2007 2:20 am, edited 17 times in total.

HokusPokus
Registered User
Posts: 1
Joined: Wed Jul 04, 2007 8:16 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by HokusPokus »

Great tnx alot :P

edit: nothing important but in installation description it says viewforum_body.tpl when it should be viewforum_body.html 8-)

working great also!
Last edited by HokusPokus on Wed Jul 04, 2007 8:29 am, edited 1 time in total.

agevaled
Registered User
Posts: 22
Joined: Sun Feb 18, 2007 11:16 pm

Re: [RC1] Topic Hover Preview 0.1.0

Post by agevaled »

Grate mod!!

I ll try tnks!!!

Xabi
Registered User
Posts: 460
Joined: Wed May 23, 2007 9:04 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by Xabi »

Greeeeeeeeeeeaaaaat!


Xabi
Registered User
Posts: 460
Joined: Wed May 23, 2007 9:04 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by Xabi »

It does not parse smilies :-(

User avatar
sherwinaval
Registered User
Posts: 61
Joined: Sun Jun 17, 2007 6:16 pm

Re: [RC1] Topic Hover Preview 0.1.0

Post by sherwinaval »

Xabi wrote:It does not parse smilies :-(
just as i thought... but this is a good mod.. thanks

Xabi
Registered User
Posts: 460
Joined: Wed May 23, 2007 9:04 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by Xabi »

I'll publish a better method of showing the preview, based on a HTML layer and not on "title". We need to parse BBCodes and smileys to get this really done, anyway.

Xabi
Registered User
Posts: 460
Joined: Wed May 23, 2007 9:04 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by Xabi »

Ok, let's go...

Open prosilver/themes/content.css and add this to the end of the file:

Code: Select all

.topictitlebox {
	background:#ffffff;
	color:#000000;
	border:1px solid #98aab1;
}
Open prosilver/templates/viewforum_body.html and add this to the very beginning:

Code: Select all

<!-- The javascript presents here comes from MyCalendar 2.2.6 from MojavLinux -->
<script language="Javascript" type="text/javascript">
<!--
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="topictitlebox"><table width="300" cellspacing="0" cellpadding="0" border="0"><tr><td><table width="100%"><tr><td>' + string + '</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 (javascript can get out of alignment)
	if (document.body.firstChild != originalFirstChild)
	{
		document.body.removeChild(document.body.firstChild);
	}
}
//-->
</script>
Find the {topicrow.TOPIC_TITLE} line and modify it in this way, adding onmouseover and onmouseout tags (viewforum_body.html):

Code: Select all

<a href="{topicrow.U_VIEW_TOPIC}" onmouseover="createTitle(this, '{topicrow.FIRST_POST_RESULT}', event.pageX, event.pageY);" onmouseout="destroyTitle();" class="topictitle">{topicrow.TOPIC_TITLE}</a>

Xabi
Registered User
Posts: 460
Joined: Wed May 23, 2007 9:04 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by Xabi »

Glitches and bugs:

- This mod itself does not parse BBCodes and smilies
- In my "hovering solution", hover titles like "No new posts" appear besides the FIRST_POST_RESULT anyway.
- The white box is in the wrong position with IE6
- In some topics, there is no FIRST_POST_RESULT showed (¡¿?!)

Could anyone help us to clean this code and to parse BBCode and smilies?

Darkwander
Registered User
Posts: 108
Joined: Mon Aug 23, 2004 5:15 pm

Re: [RC1] Topic Hover Preview 0.1.0

Post by Darkwander »

I can't seem to get this mod working, has anyone had any luck with it and if so do you have the instructions, the ones i used must be wrong somewhere, i tryed it a few times and same error.

Xabi
Registered User
Posts: 460
Joined: Wed May 23, 2007 9:04 am

Re: [RC1] Topic Hover Preview 0.1.0

Post by Xabi »

What error?

Darkwander
Registered User
Posts: 108
Joined: Mon Aug 23, 2004 5:15 pm

Re: [RC1] Topic Hover Preview 0.1.0

Post by Darkwander »

Simply when i hover over a topic it will load another page and it is all white.


Below is the list of coding i did;
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : '';
//---------Topic Hover Preview MOD start-------------------------------------------------------
$sql1 = $db->sql_build_query('SELECT', array(
'SELECT' => 'p.post_time, p.post_text',

'FROM' => array(
POSTS_TABLE => 'p',
),

'WHERE' => "p.post_time = {$row['topic_time']}"
));

$result1 = $db->sql_query($sql1);
$row1 = $db->sql_fetchrow($result1);
$db->sql_freeresult($result1);

$first_post = $row1['post_text'];
$first_post = preg_replace('/\[. :. \]/iU','',$first_post);
$char_limit = '775';
if (strlen($first_post) > $char_limit)
{
$first_post = substr($first_post, 0, $char_limit) . '...';
}
$first_post = str_replace(array('"', '\\\''), array('&quote;', '\\\''), $first_post);
//---------Topic Hover Preview MOD end---------------------------------------------------------

// Send vars to template
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
//---------Topic Hover Preview MOD start-------------------------------------------------------
'FIRST_POST_RESULT' => $first_post,
//---------Topic Hover Preview MOD end---------------------------------------------------------
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
<dt style="<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS -->background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;<!-- ENDIF -->" title="{topicrow.TOPIC_FOLDER_IMG_ALT}"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" title="{topicrow.FIRST_POST_RESULT}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
Last edited by Darkwander on Wed Jul 04, 2007 4:15 pm, edited 1 time in total.

raptor5001
Registered User
Posts: 36
Joined: Mon Mar 19, 2007 5:09 pm

Re: [RC1] Topic Hover Preview 0.1.0

Post by raptor5001 »

Xabi wrote:It does not parse smilies :-(
Ah, something I missed ;) I'll be sure to take a look and try to release an update later on today...

Very nice on the javascript solution, Xabi. IMO, bbcode should just be stripped out as it is too variable on what it displays. Or maybe just parse some bbcode, such as ... And do you have more information on the 'no FIRST_POST_RESULT is shown' problem? It's just not pulling any post data for some topics?

I am thinking of maybe instead of just stripping the bbcode out and having it's contents displayed, to just show the opening block of bbcode and strip out the content and closing block. So [img] tags now are just stripped and the url is displayed, but in a future version to just have [img] where ever the image is... this could go for

Code: Select all

 blocks etc and also for custom bbcode. Of course, bbcode like [b] [size] and etc will just need to keep with the old method.

User avatar
IPB_Refugee
Registered User
Posts: 1290
Joined: Fri Jul 07, 2006 2:25 pm
Location: Austria
Name: Wolfgang Weber

Re: [RC1] Topic Hover Preview 0.1.0

Post by IPB_Refugee »

Hi,

maybe it is a little help for you to look at a phpBB2 MOD which is able to parse smilies and BBCodes:

Code: Select all

############################################################## 

## MOD Title: display first message as hover title

## MOD Author: emrag < emrah987@hotmail.com > (Emrah Türkmen)  www.canver.net  (TURKEY)

## MOD Description: with this hack when you hover the mouse on topic link you

##		    will see first message as hover title like vBulletin Boards ;)

##

## MOD Version: 1.1.0

## 

## Installation Level: Easy

## Installation Time : ~5 minutes 

## Files to Edit: viewforum.php

##		  templates/subsilver/viewforum_body.tpl

##

## Included Files: n/a

############################################################## 

##

## Author Note: 

##

##	- The javascript you will add to viewforum_body.tpl comes from Mojavlinux's MyCalendar 2.2.6 

##	( http://www.mojavelinux.com/ )

##

##############################################################

##

## MOD History: 25.09.2004 - 1.0.0

##		- First release

##

##		07.10.2004 - 1.0.1

##		- Fixed a bug - thanx to Clock

##

##		25.11.2004 - 1.0.2

##		- added a character limit for hover title - you can change this value ;)

##		(before if message is too long hover title won't be display. Now fixed) 

##		

##		- EasyMod compitable

##

##		01.03.2005 - 1.1.0

##		- compitable with bbcodes

##		- now hover title show smilies :)

##		- compitable with MODE "HIDE" - author: Philiweb 

##		- now using a javascript code for hover title - author: MojavLinux

##		- fixed a bug about single and double quotes - ", '

##		- i think this version is compitable with EasyMod but i didn't test it :(

##

##############################################################

##

## Before Adding This Hack To Your Forum, You Should Back Up All Files Related To This Hack  

##

############################################################## 

# 

#-----[ 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', "<\\2>", $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('"', '\\\''), $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 javascript presents here comes from MyCalendar 2.2.6 from MojavLinux -->

<script language="Javascript" type="text/javascript">

<!--

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 (javascript can get out of alignment)

	if (document.body.firstChild != originalFirstChild)

	{

		document.body.removeChild(document.body.firstChild);

	}

}

//-->

</script>



#

#----[ FIND ]------------------------------------------ 

#



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



#

#----[ AFTER, ADD ]------------------------------------------ 

# 



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



#

#-----[ SAVE ALL FILES/CLOSE ]------------------------------------------ 

#

# EoM
Regards
Wolfgang

Locked

Return to “[3.0.x] Abandoned MODs”