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

Newest links in multiple categories.. won't work :(

Quote Reply
Newest links in multiple categories.. won't work :(
Hi,

I've been working on a global to grab the latest xx number of links, in a category/subcategory. The global is as follows;

Code:
sub {

my $ids_to_get = q|7447,7572|;
my $max = 10;

my ($all_ids,$output);
my @tmp = split /,/, $ids_to_get;

my $all_ids_out;
foreach (@tmp) {
my $cat_id = $_;
$all_ids = $DB->table('Category')->children($cat_id);
foreach my $tmp2 (@$all_ids) {
push @$all_ids_out, $tmp2;
}
push @$all_ids_out, $cat_id;

}

# use Data::Dumper;
# return Dumper($all_ids_out);


my $link_db = $DB->table('Links','CatLinks','Category');
$link_db->select_options ("ORDER BY Add_Date DESC LIMIT $max");
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','isNew','=','Yes','CategoryID', 'IN', $all_ids_out);
my $sth = $link_db->select($condition) || return $GT::SQL::error;
my @links;
while (my $link = $sth->fetchrow_hashref) {
#print "Got link: $link->{Title} \n";
push @links, $link;
}


# use Data::Dumper;
# return Dumper(@links);



return { random_links => \@links };
}

..and called with;

Code:
<%load_random_cats%>
<%loop random_links%>
<%include link.html%>
<%endloop%>

However, for some reason @links isn't being grabbed, even though I know for sure that there are links (or in my case, products) in this category.

The first part in red gives;

Quote:
$VAR1 = [ '7825', '7448', '7829', '7821', '7447', '7572' ];

,...but the second part (Dumper(@links)), gives absolutly nothing :/

Can anyone see my boo boo? I certainly can't Pirate

TIA

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: Jun 25, 2005, 1:56 AM
Quote Reply
Re: [Andy] Newest links in multiple categories.. won't work :( In reply to
LOL.. knew that would happen =) I removed the "isNew" part, and it works fine now (the links were older than the specific "new" length) ... doh!

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!