Gossamer Forum
Quote Reply
Cat new link
How I can display new link but for list of categories – somting like
New_link_cats(1,3,5,8)
And that the categories are not subcategories.
Quote Reply
Re: [nir] Cat new link In reply to
Untested, but try this:

get_new_by_cat
Code:
sub {
my @cat_ids = split /,/, $_[0];

my $cond = new GT::SQL::Condition;
foreach (@cat_ids) { $cond->add('CatLinks.CategoryID','=',$_) }

$cond->bool('OR');

my $tbl = $DB->table('CatLinks','Links','CatLinks');
$tbl->select_options("ORDER BY Title");

my $sth = $tbl->select( ['Links.*'], $cond, { isNew => "Yes" } ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
push @loop, $hit;
}

return { links_loop_by_cat => \@loop }


}

Call with:

Code:
<%get_new_by_cat('1,2,3,4')%>
<%if links_loop_by_cat.length%>
<%loop links_loop_by_cat%>
<%include link.html%>
<%endloop%>
<%endif%>

Replace:

'1,2,3,4'

..with the list of Categories you want to select from.

Hopefully that will work =)

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: Jul 29, 2008, 5:54 AM
Quote Reply
Re: [Andy] Cat new link In reply to
HI Andy
Thanks.
I get this error
GT::SQL::Table (20227): Invalid table name 'glinks_ARRAY(0x128db10)' at (eval 25) line 1.
Quote Reply
Re: [nir] Cat new link In reply to
Sorry, my mistake - were some errors in that global =) Please try the modified version above.

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] Cat new link In reply to
coolCool