Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Mouseover Preview blurb

Quote Reply
Mouseover Preview blurb
Hi,
I'm working on some software at the moment that has nothing to do with a forum but has some type of javascript code that lets you see the beginning of the product description when you mouseover a link to the product.
I was thinking that this would be good to think about for at least two reasons :
a) you get the nifty preview appearing and it helps people decide quickly whether or not to go further
b) by ricochet (quote for Paul) you can potentially reduce the amount of server calls since the user will in some cases not click on the link because he will have seen that the discussion is not what he thought it was.

To take this further it would even be interesting to have this function on the NEW messages for up to five previews for example, both private and posted. One notch further would be having a hyperlink in the mouseover to the message.

you could imagine something like this when there is a mouseover :
1. Message from Ian /Re: Your plug-in is great /Body: Thanks for the message, check the new update
2. Message from Paul /Re: Admin validation of users /Body: Check this out
etc.

This may well increase the code that G Forum spurns out and hence increasing overall bandwidth used though in certain cases I suppose it would need to have an active and inactive option through the admin panel.

John
Significant Media
Quote Reply
Re: [Jag] Mouseover Preview blurb In reply to
This should already be possible to do with the current templates. Wherever you want it to be, figure out the Javascript to make the window appear, and have it contain <%post_subject%>, <%post_message%>, <%post_username%>, etc.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Hi, I think as you say that the function in javascript is not the hardest. I'll start looking into it. I need to figure out how to link to the messages depending on whether they are private or not.

John
Significant Media
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
I want to post the 'latest' message in a thread in the forum view page. I'm able to print the FIRST message using the <%post_message%> but I want the last one in the thread. How do I do this?

Thanks,
Quote Reply
Re: [jaltuve] Mouseover Preview blurb In reply to
You could do this with a global. Create a global called "load_last_reply":

Code:
sub {
my $post_id = shift;
my $PostUser = $DB->table('Post', 'User');
$PostUser->select_options("ORDER BY post_time DESC", "LIMIT 1");
my $last = $PostUser->select(left_join => { post_root_id => $post_id })->fetchrow_hashref;

GForum::Post::normalize($last);

for (keys %$last) {
$last->{"last_reply_$_"} = delete $last->{$_};
}

return $last;
}

Then, in your template, do something like this:

Code:
<%if post_replies%>
<%load_last_reply($post_id)%>
<%last_reply_post_message%>
<%else%>
<%post_message%>
<%endif%>

As soon as you put the '<%load_last_reply($post_id)%>' tag in your template you'll get all posts tags for the last reply of the thread - prefixed with "last_reply_" (i.e. <%last_reply_post_subject%>, <%last_reply_post_message%>, etc.). Note that this will only work when the post_id you pass in is of a root post with replies - otherwise the various last_reply_* tags won't be set.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com

Last edited by:

Jagerman: Jan 27, 2003, 10:58 AM
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
No errors, but it is not getting the last message, but the second one. guess you had to place a count.
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Hi Jason, I doubled checked everything. For some reason the last message is not appearing. What could be wrong?
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
I already figured out what the problem was. I want the latest, most recent post to be shown. not the replys to the original post. that was the problem.
Quote Reply
Re: [jaltuve] Mouseover Preview blurb In reply to
Oops, my mistake - I fixed the post above. Just change this:

$PostUser->select_options("ORDER BY post_latest_reply", "LIMIT 1");

to:

$PostUser->select_options("ORDER BY post_time DESC", "LIMIT 1");

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Excelent... this makes a PERFECT modification to the forums... I appreciate your help. however, due to the nature of 'previews' some very long posts are clogging my view.. any way to trim the preview for the last post limiting it to a certain number of characters?
Quote Reply
Re: [jaltuve] Mouseover Preview blurb In reply to
You might want to strip out all markup tags before, so that [quote]'s won't show up on your main forum list (which would be particularly ugly).

So, before the call to GForum::Post::normalize, add this:

Code:
substr($last->{post_message}, 0, 100) = ''; # Change 100 to the number of characters you want
$last->{post_message} =~ s/[[^\[]+]//;
$last->{post_message} =~ s/[[^\[]*$//;

You might experiment a bit with the length, to see how well it works, but that should get you going.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com

Last edited by:

Jagerman: Jan 26, 2003, 8:41 PM
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Hmm... any idea why the substring function is not working?? I'm unable to truncate or replace.
Quote Reply
Re: [jaltuve] Mouseover Preview blurb In reply to
Oops, my mistake again. Add '= '';', as I edited in above.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Hello jagermann

A nice function

Can i modify this to show the subject from the last posted Thead in the category_list.html?

thanks höfti
linktobuy Web Directory
Ratgeber Recht

Last edited by:

hoefti: Jan 27, 2003, 6:22 AM
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Oops, I made another mistake in the above global. The part in red should be removed:

my $last = $PostUser->select(left_join => post_message => { post_root_id => $post_id })->fetchrow_hashref;

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [hoefti] Mouseover Preview blurb In reply to
Hi hoefti,

There is a way to get a post without using a global; just add this to your template where you want to get the latest post information:

Code:
<%GForum::Post::View::get($forum_last_id)%>

Now the normal variables (i.e. <%post_message%>, <%post_subject%>, etc.) are available.

However, this only applies to the last post, not the last thread. For the last thread, try a global like this:

Code:
sub {
my $last_id = shift;
my $root = $DB->table("Post")->select(post_root_id => { post_id => $last_id })->fetchrow;
require GForum::Post::View;
return GForum::Post::View::get($root || $last_id);
}

Then from the forum loop, add: <%global_name($forum_last_id)%>, and you'll have the variables available.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Hello jagermann

This works fine
<%GForum::Post::View::get($forum_last_id)%>

many thanks

The Global makes me an error
I call the Globan last_post_subject

and put it under

Code:
<b><a href="gforum.cgi?forum=<%forum_id%>;<%hidden_query%>"><%forum_name%></a></b><br>
<% else%>
<%forum_name%><br>
<% endif%>

then my forum says
Error: Variable 'last_post_subject' is not a code reference

Thats not so good
linktobuy Web Directory
Ratgeber Recht
Quote Reply
Re: [hoefti] Mouseover Preview blurb In reply to
Check to make sure there aren't any extra spaces or lines before the 'sub {' in the global - 'sub {' must be the exact content at the beginning of the global's value.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
Hello jagermann

I have überprüft check the global
write it in the Textfield oder copy and paste
but the forum says
Error: Variable 'last_post_subject' is not a code reference

Its not the first global for me i save to the forum, but the first who dont work

Perhabs you can spen an little time to check your global

thanks

greeting hoefti
linktobuy Web Directory
Ratgeber Recht
Quote Reply
Re: [hoefti] Mouseover Preview blurb In reply to
Jason's code is fine. Did you check your global as Jason suggested?

The reason for this error tends to be when you don't have one space only between sub and {

Double check that is the case with your cut and paste.

Also make sure you made no syntax errors when typing/pasting and finally check your error log JIC

Last edited by:

Paul: Jan 27, 2003, 1:12 PM
Quote Reply
Re: [hoefti] Mouseover Preview blurb In reply to
Hi hoefti - perhaps there is a problem with another variable of the same name? Perhaps try changing the name of the global and see if that fixes the problem. Also make sure you didn't put a type in the global name or call to the global in the template.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Mouseover Preview blurb In reply to
I will try to be as specific as possible, as to how i'm trying to do substitution on a given string to make it x characters long.

First. I created a global called truncar like this (this is based on what I learned in this thread:

[code]
sub {

my $post_id = shift;

my $PostUser = $DB->table('Post', 'User');
my $first = $PostUser->select(left_join => { post_root_id => $post_id })->fetchrow_hashref;

substr($first->{post_message}, 0, 5) = '';
$first->{post_message} =~ s/[[^\[]+]//;
$first->{post_message} =~ s/[[^\[]*$//;

GForum::Post::normalize($first);

for (keys %$first) {
$first->{"first_$_"} = delete $first->{$_};
}

return $first;
}
[/code]

then from within a template I call the global and give it $post_id as an argument like this:

[code]
<%truncar($post_id)%>
[/code]

and finally I print the string I intend to manipulate (I want to just do a substitution) like this:

[code]
<%first_post_message%>
[/code]

I'm supposed to get the FIRST post of the thread, but it always gives me the second post and it is not doing the substitution from left to right but from right to left... please help
Quote Reply
Re: [jaltuve] Mouseover Preview blurb In reply to
Fixed... it was

[code]
select(post_message => { post_id => $post_id })->fetchrow_hashref;
[/code]

simple