Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Scripts for last 10 posting

(Page 1 of 2)
> >
Quote Reply
Scripts for last 10 posting
Is there a script that we can call using SSI within any HTML page to show the last 10 posting
Quote Reply
Re: [bgkhoo] Scripts for last 10 posting In reply to
... no.

- wil
Quote Reply
Re: [bgkhoo] Scripts for last 10 posting In reply to
Code:
use strict;
use GForum qw/$DB/;

my @posts;
my $db = $DB->table('Post');

$db->select_options("ORDER BY post_time DESC", "LIMIT 10");

my $sth = $db->select('post_id', 'post_subject');

while (my ($tags) = $sth->fetchrow_hashref) {
push @posts, qq|<a href="gforum.cgi?post=| . $tags->{post_id} . qq|;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;">| . $tags->{post_subject} . qq|</a>|;
}

return join '<br>', @posts;

I'm not in the mood to test it but hope it puts you on the right track.

Last edited by:

PaulW: Dec 3, 2001, 8:18 AM
Quote Reply
Re: [PaulW] Scripts for last 10 posting In reply to
Thanks for the code. Will try it out.
Post deleted by PaulW In reply to

Last edited by:

PaulW: Dec 3, 2001, 10:38 AM
Quote Reply
Re: [bgkhoo] Scripts for last 10 posting In reply to
I've made it into a plugin so you can choose how many new posts to show and whether you want to number them eg...

1. Post1
2. Post2

I'm not sure how well it works so let me know. Thanks.

Last edited by:

PaulW: Dec 3, 2001, 11:20 AM
Post deleted by kjetilpa In reply to

Last edited by:

kjetilpa: Jul 31, 2002, 1:55 AM
Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
Paul,
I just tried this last 10 posting plugin with a version 1.1.7 of the forum and I get an internal server error. Does it only work with a previous version or am I doing something wrong ?

John
Significant Media
Quote Reply
Re: [Jag] Scripts for last 10 posting In reply to
Do you have access to an error log?
Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
Hi Paul,
This is the error I'm getting at the moment :

Can't call method "table" on an undefined value at /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi line 12.
[Mon Sep 2 12:09:42 2002] [error] [client 195.206.XX.XX] Premature end of script headers: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi

John
Significant Media
Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
Paul,
This was done to be used as an SSI and I suppose I can get it to work on the main index page but did you do one that can be directly inserted into the main index by pasting code like your other plugins ?

Thanks, John
Significant Media
Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
I have re-installed it and I get an error most probably a chmod error. I chmoded the cgi script to 755 it was on 666.

I copied this out of my error log :
Can't use an undefined value as an ARRAY reference at /usr/local/etc/httpd/cgi-bin/deleted_domain/admin/Plugins/GForum/Block_User.pm line 39.
[Mon Sep 2 13:37:48 2002] [error] [client 195.206.XX.XX] file permissions deny server execution: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi

As you can see the first one doesn't seem to be relative to the newposts.cgi but you may know what it is about ??

The when the chmod was changed I got this :

Can't call method "table" on an undefined value at /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi line 12.
[Mon Sep 2 14:01:13 2002] [error] [client 195.206.XX.XX] Premature end of script headers: /usr/local/etc/httpd/cgi-bin/deleted_domain/newposts.cgi

In your script this is line 12 :
my $db = $DB->table('Post');

Does this give you any clues as to what may be going wrong ???
Significant Media
Quote Reply
Re: [Jag] Scripts for last 10 posting In reply to
Yes I get the same error!
The Can't call method "table" and then Premature end of script headers....
Also if I try to use the -w option in the hashbash line I get the same...
Max
The one with Mac OS X Server 10.4 :)
Quote Reply
Re: [maxpico] Scripts for last 10 posting In reply to
Paul took some of his time to help me out on this one so I'll just post what he gave me and enabled me to fix it. It will at least save him the time of writing it again. I hope this OK with himBlush

In Reply To:
That other error means $DB is undefined. Add:

GForum::init('/path/to/admin');

....near the top of newposts.cgi

I did this mod and it worked fine for me.

John
Significant Media
Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
 
$db->select_options("ORDER BY post_time DESC", "LIMIT $limit");

Should it list the last x posten messages ?

I get a listing where the post_id is mixed

2161
2165
2176
2162
2172
...

I would expect that the las post_id should be first to have the last messages listet in descending order

2175
2174
2173
2172
2171
.....

So I tried to change from post_time DESC to post_id DESC but I still get a mixed listing.

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Sir Up] Scripts for last 10 posting In reply to
Ordering by post_id DESC should be working.
Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
In my case not.

When I browse the table post_id by Mysqlman the postings are listed correct,
but the script does not list the postings right.

If I saw the values of the columns post_time and post_id right, both should order
the records right.

I already runned -Reinxed- at Gforum-Admin.

--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Paul] Scripts for last 10 posting In reply to
Thanks for the code Paul.

I'm modifying it to restrict it to specific forums. I don't suppose the API is documented anywhere?Laugh

I tried $db->select_options("WHERE forum = 2", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
and $db->select_options("WHERE forum_id = 2", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
and $db->select_options("WHERE forum IN(1,2,3)", "ORDER BY post_time DESC", "LIMIT $g{'limit'}");
all NO Go Unsure

Obviously I'm just hacking here... How should I do this?
Quote Reply
Re: [kencl] Scripts for last 10 posting In reply to
You can find many useful documents in the Help section of you administration panel. Go to "GT Module Documentation", and you'll find all you need. Take a look at "GT::SQL::Table", which deals with selects.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Scripts for last 10 posting In reply to
Thanks - that's just what I needed! Cool

One thing it doesn't mention though is how to emulate SELECT DISTINCT I want to only list only 1 link per thread, but what's happening is the active threads are returning multiple times.

Suggestions anyone?

Last edited by:

kencl: Feb 4, 2003, 2:29 PM
Quote Reply
Re: [kencl] Scripts for last 10 posting In reply to
I ended up requesting 3 times as many posts as I needed and manually removed duplicate threads.

One other thing I can't do is mimic WHERE post_moved <> 1 The documentation mentions how to emulate less than or greater than or LIKE, but not "not equal" to. I suppose the other alternative would be to emulate WHERE post_moved = NULL , but I'm not sure how to set the value to NULL without turning it into a four letter string.

Any suggestions would be appreciated.
Quote Reply
Re: [kencl] Scripts for last 10 posting In reply to
Hi,

See the docs on GT::SQL::Condition, it's what should be used for any advanced where clauses.

my $cond = GT::SQL::Condition->new('post_moved', '<>', 1);
$table->select($cond);

To do the select distinct, you would do:

$table->select('DISTINCT(column)', $cond);

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Scripts for last 10 posting In reply to
Thanks for the help. Unfortunately the condition '<>' does not seem to work for the NULL value.

Using new('post_moved', '=', 1); produced only moved articles, but

new('post_moved', '<>', 1); returned no articles whatsoever.

Have I stumbled across a bug?
Quote Reply
Re: [kencl] Scripts for last 10 posting In reply to
Oops, use:

GT::SQL::Condition->new('post_moved', 'IS', \'NULL');

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Scripts for last 10 posting In reply to
That did the trick. Thanks :)
> >