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

Select one link via global

Quote Reply
Select one link via global
Hello,

i try to select one link with a global like this:

sub {

my $linkid = $IN->param('linkid');
my $link_db = $DB->table('Links');
my $sth = $link_db->select ({ID => $linkid, isValidated => 'Yes' });

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

return $output;
}

and use
<%tipp_of_the_day($linkid,'43')%> in template but
get no result.
can anyone help me please?

Sör
Quote Reply
Re: [Sör] Select one link via global In reply to
Hi Sör,

This should work. I'm not sure the second parameter is for

Code:
sub {

my $linkid = shift;

my $link_db = $DB->table('Links');
my $sth = $link_db->select ({ID => $linkid, isValidated => 'Yes' });

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

return $output;
}

Cheers,



Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Select one link via global In reply to
Thanks Dat,

I use another way now. Instead of changing
the Id in templates, I change it now every
day in the subroutine Cool
Quote Reply
Re: [tandat] Select one link via global In reply to
..or;

Code:
sub {
my $link = $DB->table('Links')->select ({ID => $_[0] , isValidated => 'Yes' })->fetchrow_hashref;
return Links::SiteHTML::display ('link', $link);
}

..or if you want the tags like detailed_url, etc.. this would prob be better:

Code:
sub {
my $link = $DB->table('Links')->get( { ID => $_[0] });
return Links::SiteHTML::display ('link', $link);
}

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!