Gossamer Forum
Quote Reply
Top Rated on other pages
How do I get other pages to recognise <%~loop top_rated_loop%>

I've tried to modify a seperate global but can't get it to replicate the list correctly.
Quote Reply
Re: [MJB] Top Rated on other pages In reply to
Hi,

It should be as simple as a new global:

Code:
sub get_top_rated {
my $links = $DB->table('Links');

require GT::SQL::Condition;
my $cond = GT::SQL::Condition->new('Votes', '>=', 10, VIEWABLE);
$GRAND_TOTAL ||= _grand_total();

$links->select_options("ORDER BY Rating DESC", "LIMIT 10");
my $rated = $links->select($cond);

$links->select_options("ORDER BY Votes DESC", "LIMIT 10");
my $voted = $links->select($cond);

my (@top_votes_loop, @top_rated_loop);
while (my $link = $voted->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_detail_url} . '/' . $links->detailed_url($link->{ID}) if $CFG->{build_detailed};
push @top_votes_loop, $link;
}
while (my $link = $rated->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_detail_url} . '/' . $links->detailed_url($link->{ID}) if $CFG->{build_detailed};
push @top_rated_loop, $link;
}

# And write it to a file.
return Links::SiteHTML::display(rate_top => {
top_rated_loop => \@top_rated_loop,
top_votes_loop => \@top_votes_loop
});

}

Call with:

Code:
<%global_name%>

<%loop top_rated_loop%>
<%include link.html%>
<%endloop%>

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!

Last edited by:

Andy: Mar 20, 2020, 2:37 AM
Quote Reply
Re: [Andy] Top Rated on other pages In reply to
Thanks Andy. I had Votes and Rating on the same line, not separate.

I'll give this a go when I get some time later.

Last edited by:

MJB: Mar 20, 2020, 5:32 AM