Gossamer Forum
Home : Products : Gossamer Links : Discussions :

List the most recent/popular Gforum Discussions on homepage

Quote Reply
List the most recent/popular Gforum Discussions on homepage
Is there a way to put the most popular discussions from Gforum on the home page for LinksSql? It woulld need to be able to update them as the popularity changes???

</not a clue>

Last edited by:

pugdog: Mar 26, 2006, 9:53 PM
Quote Reply
Re: [Kilroy] Insert Gforum In reply to
How would you define the most popular? I would imagineit is possible, you should just need a MySQL query to find the most popular, and then format the HTML...could probably be done as a tag. The main problem would be you would either need to rebuild your directory every x minutes to keep it updated...or use page.cgi to make it all dynamic.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [A.J.] Insert Gforum In reply to
What I would have would be a query, either done dynamically, or using a cron job, to identify the most popular discussions, and diplay them on the front page. As an alternative, how would you display the latest or newest discussions???

</not a clue>
Quote Reply
Re: [Kilroy] Insert Gforum In reply to
You could do the latest with SSI:

<!--#include virtual="/cgi-bin/gforum.cgi?do=search_results&search_time=4h&t=links"-->

To pull up the posts in the last 4 hours. Then create a new template set called links, and copy over the search_results.html template from it and format it however you like.

Hope that helps,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Insert Gforum In reply to
Alex,



This worked great for me until I logged in and started viewing dynamic pages. Then the SSI stopped working and there are "holes" in my pages where the SSI is supposed to be parsed. Is there any way to do this so that it works no matter how pages are viewed?



Thank you.
Quote Reply
Re: [nt6] Insert Gforum In reply to
SSI only works with SERVER parsed pages, not cgi parsed pages (same problem as PHP).

You would need to make the ssi call a global, and return the value of the global.

This would work for DYNAMIC pages :) It would not work for static pages, as the pages would be built once, with old data.

You might be able to use the d= flag to decide whether to include the SSI or the global tag.

<%if d%>
<%last_4_hours_forum%>
<%else%>
<!-- SSI Tags -->
<%endif%>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Alex] Insert Gforum In reply to
Alex,

can you give an example to put

<!--#include virtual="/cgi-bin/gforum.cgi?do=search_results&search_time=4h&t=links"-->

in a global

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Sir Up] Insert Gforum In reply to
Is the global inside of Gossamer Forum or Links SQL?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Insert Gforum In reply to
The global should be defined at dbmansql, displaying a call of a linksql page like this:

http://www.domain.com/page.cgi?p=last5

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Alex] Insert Gforum In reply to
A need such global (just for recent post) in GLinks.

Is it possible?

Regards.

UnReal Network
Quote Reply
Re: [deadroot] Insert Gforum In reply to
I looked at the suggestions here, and I need something like this too.

The best idea, would be if GLinks could read the GForum tables, and yank the data out itself, and stuff it into a
<%loop%>able variable, or reversing the logic, if GForum could export an XML/RSS type feed that Glinks could parse and read. Alternatively, creating a subroutine that would pull the data directly from Gforum, with as little overhead as possible, is another.

Combining some ideas from about a dozen unrelated threads, you'd end up with something like:



<%grab_gforum_newest (10)%>
Code:
sub {
## this routine will connect to a GForum database, from inside a GLinks template/global
## it will grab the newest posts, 10 of them, and return the ID, Subject and Time of the post.
## You need to loop through the returned value, using standard GT::Template tags, style, etc.

my $limit = shift;
$limit = 10 if (ref $limit); ## the template parser has a nasty habit of passing in a hash_ref of all tags if no
## value is supplied to the routines. So, we need to check a scalar was passed in.
## a scalar returns "undef" when checked as a reference, so if a ref value exists, it's not a salar
use lib '/path/to/gforum/admin';
my $DB_GFORUM = GT::SQL->new('/path/to/gforum/admin/defs'); ## force a table object from ANOTHER database
## the GForum must be on the same server/account/etc to work this way
my $posts_table = $DB_GFORUM->table('Post'); ## now, create a table object to that new $DB object

$posts_table->select_options("ORDER BY post_latest_reply", "LIMIT $limit"); ## set the select options to order the results to pick off the newest

my $sth = $posts_table->select('post_id', 'post_subject', 'post_time' => { ## remember, => is just a snooty comma
## forum_id_fk => 123, ## limit to a forum, if you want
post_root_id => 0 } ## don't find replies
);

## now, to generalize this routine, so it can be used in other areas, not just this particular one,
## we want to return a <%loop%>able variable, so we can pick out the datafields and format as we need to.
## to locate a post in GForum, all we need is it's ID, and then call it with .../gforum.cgi?post=$id
## real simple, and similar to using jump.cgi?ID=$id
## FYI: remember, you might need to $subject = GT::CGI::html_escape($subject); in some cases/situations.

use GT::Date qw/date_get/ ; ## qw/:all/; ## need to do a date transform

my @output;
while (my $post = $sth->fetchrow_hashref) {

$post->{post_time} = date_get($post->{post_time});

# if you have an active forum, you might want to put the time. I *know* there is a better way,
# and it should be possible to show the date for posts not made today, and time for posts made
# today, but that is up to you. This is just an example of where, and how you could do it.
# my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime $post->{post_time};
# $post->{post_time} = "$hour:$min:$sec";

push @output, $post;
}

return ({'GForum_loop' => \@output}); ## return the dereferenced array, the actual data as a tag called <%GForum_loop%>
## which you'd use as <%loop GForum_loop%>...<%endloop%>
## contains the hash_keys post_id, post_subject and post_time

## sample template output line:
## <li><a href="http://url/to/gforum.cgi?post=<%post_id%>"><%escape_html post_subject%></a> at <%post_time%></li>
## if you are using the search engine templates, you can do something like:
## <li><a href="/forum/Post_P<%post_id%>"><%escape_html post_subject%></a> at <%post_time%></li>
## the templates parse out the stuff BEFORE the _P(*\d) and all it looks at is the number after the _P
}



Note: I have this working, several minor bug fixes, and quirks fixed, date transform support added, some extra example template code, etc.
This is working on my site, as noted.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Mar 31, 2006, 11:00 PM
Quote Reply
Re: [pugdog] Insert Gforum In reply to
Ok. Now for one dumb question.

Where do I put template code?

(something like this).

<li><a href="http://url/to/gforum.cgi?post=<%post_id%>"><%escape_html post_subject%></a> at <%post_time%></li>

Regards.

UnReal Network
Quote Reply
Re: [pugdog] Insert Gforum In reply to
Ok. I've figure it out! ;)

UnReal Network