Hi,
For anyone who wants to make this mod work with SEO templats (mod_rewrite), you can use this global:
hot_threads
Code:
sub {
my $tags = shift;
my $post_db = $DB->table ('Post');
$post_db->select_options ('WHERE post_root_id=0', 'ORDER BY post_time DESC', 'LIMIT 10');
my $sth = $post_db->select;
my @output;
while (my $post = $sth->fetchrow_hashref) {
$post->{forum_name} = $DB->table('Forum')->select( ['forum_name'], { forum_id => $post->{forum_id_fk} } )->fetchrow;
$post->{cat_id} = $DB->table('Forum')->select( ['cat_id_fk'], { forum_id => $post->{forum_id_fk} } )->fetchrow;
push @output, $post;
}
return { post_loop => \@output };
}
..and then instead of:
Code:
<link>
http://www.yourdomain.com/gforum.cgi?post=<%post_id%></link>
Code:
<link>
http://www.yourdomain.com/<%cat_path($cat_id)%><%escape_name($forum_name)%>_F<%forum_id_fk%>/<%escape_name($post_subject)%>_P<%post_id%>/</link>
(change the bit in red to the URL of your mod_rewrite forum URL)
Also, you need to make sure you have the following globals in your /rssmod template set:
cat_path
Code:
sub {
my $id = shift;
my $category = q|%s_C%d/|;
if (!$GForum::CAT_CACHE{$id}) {
my $Cat = $DB->table('Category');
my $cat = $Cat->get({ cat_id => $id }, 'HASH', ['cat_id', 'cat_name', 'cat_id_fk']);
push @{$GForum::CAT_CACHE{$id}}, $cat;
while ($cat = $Cat->get({ cat_id => $cat->{cat_id_fk} }, 'HASH', ['cat_id', 'cat_name', 'cat_id_fk'])) {
push @{$GForum::CAT_CACHE{$id}}, $cat;
}
}
my @cats = @{$GForum::CAT_CACHE{$id}};
my $cat = shift @cats;
(my $cat_name_e = $cat->{cat_name}) =~ y/ \t\r\n?"'#/__/d;
my $cat_name = sprintf($category, $cat_name_e, $id);
for (@cats) {
($cat_name_e = $_->{cat_name}) =~ y/ \t\r\n?"'#/__/d;
$cat_name = sprintf($category, $cat_name_e, $_->{cat_id}) . $cat_name;
}
return \"/$cat_name";
}
escape_name
Code:
sub {
my $name = shift;
$name =~ y/ \t\r\n?"'#/__/d;
$name = $IN->escape($name);
$name =~ s|%2F|/|gi; # For some reason, Apache doesn't like %2F in the pathinfo, but a real / is fine
\$name;
}
Just thought I'd post this, in case anyone else is trying to do the same thing :)
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!