Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Latest 10 every category

Quote Reply
Latest 10 every category
Hi

Using this global (courtsey Andy/minesite) which gets the latest 10 additions site wide:

sub {
my $tbl = $DB->table('Links');
$tbl->select_options('ORDER BY Add_Date DESC','LIMIT 10');
my $sth = $tbl->select() || return $GT::SQL::error;
my $back;
while (my $hit = $sth->fetchrow_hashref) {
$back .= Links::SiteHTML::display('newlink',$hit);
}
return $back;
}

Two Questions:

(1) In the above how to include check for "Validated" links only.

(2) Would Want similar thing to display the Lates 10 links on Category Pages Including all the Subcategories meaning that while on any Category Page, 10 latest links (from that Category and Subcategories of that Category) are displayed.

TIA
HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================
Quote Reply
Re: [HyperTherm] Latest 10 every category In reply to
Hi,

I'm afraid I'm a little rushed... but in regards to 1) ... you could try changing;

my $sth = $tbl->select() || return $GT::SQL::error;

...to;

my $sth = $tbl->select( { isValidated => "Yes" } ) || return $GT::SQL::error;

Please note though, this will still include links that have expired. I can't remember the exact format for the condition that is needed, to verify a link is live.

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] Latest 10 every category In reply to
Hi.

Thanks with respect to (1). Expired Links is not a problem as Admin deletes it manually anyway and only users with a valid Gmail Address are allowed to submit links.

Any suggestions for point (2) :)

Thanks
HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================

Last edited by:

HyperTherm: Dec 13, 2004, 9:11 PM
Quote Reply
Re: [HyperTherm] Latest 10 every category In reply to
Something like this for the second part:

sub {
my $tags=shift;
my $back;
my $cat_id = $tags->{ID};

my $all_ids = $DB->table('Category')->children($id);
push @$all_ids,$cat_id;

my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options('ORDER BY Add_Date DESC','LIMIT 10');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','isNew','=','Yes','CategoryID', 'IN', $all_ids);
my $sth = $link_db->select($condition);

while (my $link = $sth->fetchrow_hashref) {
$back .= Links::SiteHTML::display('newlink',$link);
}

return $back;
}
Quote Reply
Re: [afinlr] Latest 10 every category In reply to
Hi.

I get this error:

Unable to compile 'latest10_cat': Global symbol "$id" requires explicit package name at (eval 2030) line 6.

Thanks
HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================
Quote Reply
Re: [afinlr] Latest 10 every category In reply to
Hi

Just played around and changed the line

my $all_ids = $DB->table('Category')->children($id);

to

my $all_ids = $DB->table('Category')->children($cat_id);

Which does give the latest additions.
Is the change correct ... i just did it out of hurry to get it running

Thanks again
HyTC

Thanks
HyTC
==================================
Mail Me If Contacting Privately Is That Necessary.
==================================
Quote Reply
Re: [HyperTherm] Latest 10 every category In reply to
Yes, that's the right change.