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

Translate sql-query into links2 global

Quote Reply
Translate sql-query into links2 global
Can anybody translate this into a global?

select Title, LinkOwner from lsql_links where ID BETWEEN "300" AND "1000" and Title LIKE "%<%Title%>%" ;

I inserted content from a third party and using this for a special purpose!
I want to use this in the Link.html template.

Thanks,
Ron

Last edited by:

rsahertian: Oct 7, 2004, 5:36 AM
Quote Reply
Re: [rsahertian] Translate sql-query into links2 global In reply to
Something like this should get your started :)

Code:
sub {

my $tags = shift;
my $title = $tags->{Title};

my $cond = GT::SQL::Condition->new('ID','>=','300','ID','<=','1000');
$cond->bool('AND');

my $cond2 = GT::SQL::Condition->new('Title','LIKE',"%$title%");
my $sth = $DB->table('Links')->select( ['Title','LinkOwner'], $cond2, $cond ) || die $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
print "Title: " . $hit->{Title} . "<BR>";
}

}

Call with <%global_name%>

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] Translate sql-query into links2 global In reply to
Hi Andy,

Thanks for responding...

NO result and also NO error with your code!
Must it show always it's own Title with this piece of code???

thanks,
ron
Quote Reply
Re: [rsahertian] Translate sql-query into links2 global In reply to
Sorry Andy,

Just tested it out at home again and the query works.

But there is a small problem with it. I placed it it link.html so every link must produce it's similar link. But the global produces one list on top of the category!!!. How is that possible????


Thanks,
Ron
Quote Reply
Re: [sahertianr] Translate sql-query into links2 global In reply to
Glad to hear its working. It was only an example though Wink

Try something like;

Code:
my $back;
while (my $hit = $sth->fetchrow_hashref) {
$back .= "Title: " . $hit->{Title} . "<BR>";
}

return $back;

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] Translate sql-query into links2 global In reply to
SmileWinkamazing.....