Gossamer Forum
Home : Products : Gossamer Links : Discussions :

New Links Question

Quote Reply
New Links Question
Hi:
A two-part question:
1.) I want my "new links" to appear directly on my home page, without the surfer having to click a link to new.html. (I'd put the links inside either my left or right sidebars.)
Any way to do this?
2. By default, I'd like the "new links" to show as a list of urls (new sites) rather than as a list of dates added.
Is there a way to do this?
Thanks in advance for any help,
Quote Reply
Re: [leesar] New Links Question In reply to
Hi,

Try this global:

get_newest_links ==>

Code:
sub {

my $num_new_links = 20;

my $tbl = $DB->table('Links');
$tbl->select_links("LIMIT 20");
my $sth = $tbl->select( { isNew => 'Yes', isValidated => 'Yes' } ) || die $GT::SQL::error;
my @links;
while (my $link = $sth->fetchrow_hashref) {
push @links, $link;
}
return { links_loop_new => \@links }
}

...then in home.html, call with:

Code:
<%get_newest_links%>
<%loop links_loop_new%>
<%include link.html%>
<%endloop%>

That should do the trick (sorry if there are any boo boo's, I didn't test it =))

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] New Links Question In reply to
Hi:
Thanks for your help, but I couldn't make the global work.
I installed the global, then the call on home.html.
But when I try to build the home page, the process is aborted, with the following message: A fatal error has occured: GT::SQL::Table (1625): Unknown method 'select_links' called at (eval 44) line 6.
Any further ideas?
Thanks again.
Quote Reply
Re: [leesar] New Links Question In reply to
leesar,

Change select_links in code to select_options /in red below/ Wink

Code:
sub {

my $num_new_links = 20;

my $tbl = $DB->table('Links');
$tbl->select_options("LIMIT 20");
my $sth = $tbl->select( { isNew => 'Yes', isValidated => 'Yes' } ) || die $GT::SQL::error;
my @links;
while (my $link = $sth->fetchrow_hashref) {
push @links, $link;
}
return { links_loop_new => \@links }
}

Cheers,
Boris

Facebook, Twitter and Google+ Auth for GLinks and GCommunity | reCAPTCHA for GLinks | Free GLinks Plugins
Quote Reply
Re: [eupos] New Links Question In reply to
Hi:
It works perfectly.
Amazing!
Thanks for your help and expertise.
Leesa
Quote Reply
Re: [leesar] New Links Question In reply to
Ooops, sorry - was rushing =) Glad it works now though.

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] New Links Question In reply to
Hi Andy,
Good to see you backCool
Is it possible to select the new links that will be shown from several categories (more than one) and not just from one category or all of them?
Thanks,
Nir
Quote Reply
Re: [nir] New Links Question In reply to
Hi,

Something like this should work:

Code:
sub {

my $num_new_links = 20;

my $tbl = $DB->table('CatLinks','Links');
$tbl->select_options("LIMIT 20");
my $sth = $tbl->select( { 'CatLinks.CategoryID' => 1234, isNew => 'Yes', isValidated => 'Yes' } ) || die $GT::SQL::error;
my @links;
while (my $link = $sth->fetchrow_hashref) {
push @links, $link;
}
return { links_loop_new => \@links }
}

(untested)

Change 1234, to the category ID you want to grab.

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] New Links Question In reply to
Hi Andy,
Thanks for your help.
Your function works but I can't add another category, and I need to read links from 2-3 different categories.
my $sth = $tbl->select( { 'CatLinks.CategoryID' => 1234, 'CatLinks.CategoryID' => 6789, isNew => 'Yes', isValidated => 'Yes' } ) || die $GT::SQL::error;
Quote Reply
Re: [nir] New Links Question In reply to
Hi,

Try this:

Code:
use GT::SQL::Condition;
my $cond = new GT::SQL::Condition;
$cond->add('CatLinks.CategoryID','=','6789');
$cond->add('CatLinks.CategoryID','=','12345');
$cond->add('CatLinks.CategoryID','=','123456');
$cond->bool('OR');


my $sth = $tbl->select( $cond, { isNew => 'Yes', isValidated => 'Yes' } ) || die $GT::SQL::error;

Untested, but should work.

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] New Links Question In reply to
Thanks Andy it work:)
Quote Reply
Re: [nir] New Links Question In reply to
heheh.. glad to hear it =) Havn't used that format for a while, so wasn't quite sure I had it right Tongue

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!