Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Post forum on main page!

Quote Reply
Post forum on main page!
Hello, can someone help me to find out the way to post a forum on other static html pages, for example i would like to list the Announcements out of the usual forum folder. How to do so?

Thanks for helping a stupid guy!Blush

Antoine
Quote Reply
Re: [antoined] Post forum on main page! In reply to
There's no extremely simple way to do this, but it isn't impossible.

You are probably going to need to enable SSI on your main page. Then, what you do is add something like:

<!--#include virtual="/cgi-bin/new_posts.cgi"-->

The contents of the "new_posts.cgi" file that you'll create should be something like this:

Code:
#!/usr/bin/perl

use lib '/path/to/gforum/admin';
use GForum qw/$DB/;

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

my $p = $DB->table("Post");
$p->select_options("ORDER BY post_latest_reply", "LIMIT 10");
my $sth = $DB->table("Post")->select('post_id', 'post_subject', 'post_time' => {
forum_id_fk => 123,
post_root_id => 0
});

print "Content-type: text/html\n\n";
while (my ($id, $subject, $time) = $sth->fetchrow) {
$subject = GT::CGI::html_escape($subject);
print qq|<li><a href="/url/to/gforum.cgi?post=$id">$subject</a></li>\n|;
}

Now, if you access that new_posts.cgi (you'll probably need to 'chmod 755' it first) you should see a list of topics, each linked to the appropriate thread. You'll need to change the bit in red to the proper forum ID, and the part in orange to the number of posts you want to display. Of course, you can also change the <li> and <a> tags as required to fit the appearance you desire.

Now, if the SSI is working, you should see the HTML produced by that CGI on your main page, where the SSI include was. We use something similar to this for the "news" section of our site, based on the threads of the Announcement forum.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Post forum on main page! In reply to
Hello, and thank you for replying,

I don't know how to enable SSI!!! can you gently give me a hint!Blush

Antoine
Quote Reply
Re: [antoined] Post forum on main page! In reply to
Add a file in your folder you want to run the SSI file from, called .htaccess. Include the following into it;

Code:
AddHandler Server-Parsed .html .shtml .shtm

Then add the SSI call into your page....

I'm hoping I got the .htaccess content correct Smile

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: [Jagerman] Post forum on main page! In reply to
Hi Jason

Can you tell me how i can use it, but in a template inside the gforum, like login.html, or so?



Thanx.Wink




http://www.webconferencia.net/
Quote Reply
Re: [Andy] Post forum on main page! In reply to
Hi, I realise this solution was posted sometime ago but it was just what I was looking for. However I've got a slight problem with it.

I've created the cgi script and if I call it directly it displays the topics exactly as it should, however if I put the

Code:
<!--#include virtual="my/server//cgi-bin/new_posts.cgi"-->

into the page in the right place and then call the .shtml page I get a message in place of the topics saying [an error occurred while processing this directive]

Does anyone have any clues on this one for me please? Any help would be hugely appreciated.

Cheers
Sal
Quote Reply
Re: [SalB] Post forum on main page! In reply to
Hi,

*exactly* what are you using in the virtual="...." part? Thats most likely your problem. Its a *literal* path, and not absolute. i.e we use stuff like;

virtual="/cgi-bin/new_posts.cgi"

Cheers

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: [Andy] Post forum on main page! In reply to
Hi Andy,

I tried it first with a virtual and then with an absolute path and it returned the same result both times.

I'd love to get this to work but am thinking I'm going to have to give up on the idea unless you've got any other thoughts on this?

Thanks for replying
Sal

Last edited by:

SalB: Feb 28, 2006, 1:04 PM
Quote Reply
Re: [SalB] Post forum on main page! In reply to
Hi, I'm still struggling with this and wondered if anyone had any further ideas.

I've made sure the directory the page is in has htaccess for .shtml files but I'm still getting the same result.

Anyone with any help would be greatly appreciated.

Thanks
Sal
Quote Reply
Re: [SalB] Post forum on main page! In reply to
Hi,

When trying to debug something, it helps to see a cut/paste of what is giving you problems, and what you tried. Sometimes it's a typo, other times, seeing the code gives people an idea what is going on.

Just a suggestion not only for you, but anyone asking for help in any thread.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Jagerman] Post forum on main page! In reply to
I've just set this up and was playing around with some of the options. I added ;page=last to the end of the URL to take me to the last page in the thread. I wondered if the script could be easily extended to show the latest threads from more than one forum ID?

Jason
Quote Reply
Re: [wickedmoon] Post forum on main page! In reply to
Hi,

You could try this (untested!);

Code:
#!/usr/bin/perl

use lib '/path/to/gforum/admin';
use GForum qw/$DB/;
use GT::SQL::Condition;

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

my $p = $DB->table("Post");
$p->select_options("ORDER BY post_latest_reply", "LIMIT 10");
my $cond = new GT::SQL::Condition;

$cond->add('forum_id_fk','=','123','post_root_id','=','0');
$cond->add('forum_id_fk','=','343','post_root_id','=','0');
$cond->add('forum_id_fk','=','234','post_root_id','=','0');

$cond->bool('OR');
my $sth = $DB->table("Post")->select('post_id', 'post_subject', 'post_time' => $cond );

print "Content-type: text/html\n\n";
while (my ($id, $subject, $time) = $sth->fetchrow) {
$subject = GT::CGI::html_escape($subject);
print qq|<li><a href="/url/to/gforum.cgi?post=$id">$subject</a></li>\n|;
}

Hope that helps.

Cheers

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: [wickedmoon] Post forum on main page! In reply to
There are different ways of doing this, but on my server, if you want to display the output of the perl script in a php page, you can try this:

<?php virtual("/cgi-bin/new_posts.cgi"); ?>

Jason
Quote Reply
Re: [Andy] Post forum on main page! In reply to
Is there a way to extend the script to also display the first post in the thread?

Jason
Quote Reply
Re: [wickedmoon] Post forum on main page! In reply to
Hi,

The changes below (in bold) will let you show the "message" from the first post in a thread. However, it won't do the [..] type tag stuff (i.e [b]something[/b] will just show up as [b]something[/b], instead of something).

Code:
my $sth = $DB->table("Post")->select('post_id', 'post_subject', 'post_time', 'post_message' => $cond );

print "Content-type: text/html\n\n";
while (my ($id, $subject, $time,$post_message) = $sth->fetchrow) {
$subject = GT::CGI::html_escape($subject);
print qq|<li><a href="/url/to/gforum.cgi?post=$id">$subject</a> - $post_message</li>\n|;
}

Hope that helps.

Cheers

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: [Andy] Post forum on main page! In reply to
That's looking good, thanks. But like you say, the HTML isn't rendered in the page. Is there a way round that?

Jason