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

How do I get this into a valid global's syntax?

Quote Reply
How do I get this into a valid global's syntax?
Hi everybody,

I need some help with a global.

What I want to do is to display random logos of links (logo-upload) of the current category.

So it has to be checked:
a) if the link is validated
b) if the link's filed "Premium" is set to "2"
c) if there is a logo (was a logo uploaded by the link-owner: field "Logo_add" not empty
d) if the link is in the current category


So I need a valid global-code that does more or less the following:

Code:

sub {
# Display random premium-link logos by category
my ($id, CatId) = shift;
my $sth = SELECT RAND($ID) FROM Links, Category WHERE Links.Premium="2" AND Links.isValidated="Yes" AND Links.Logo_add AND Category.ID='$CatId' ORDER BY RAND() LIMIT 1,10

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


It would be very nice, if someone here could help me creating the proper global.



Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] How do I get this into a valid global's syntax? In reply to
Try this:

Code:
sub {
# Display random premium-link logos by category
my $catid = shift;
my $output;

my $cond = GT::SQL::Condition->new(
"Links.Premium" => "=" => 2,
"Links.isValidated" => "=" => "Yes",
"Links.Logo_add" => "IS NOT" => \"NULL",
"CatLinks.CategoryID" => "=" => $catid
);

my $db = $DB->table(qw/Links CatLinks/);
$db->select_options("ORDER BY RAND() LIMIT 1,10");
my $sth = $db->select($cond);

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

return $output;
}

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] How do I get this into a valid global's syntax? In reply to
Thank you very much! It works like charme!

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.