Gossamer Forum
Quote Reply
Global format
Hi

We have a field in the Links table called desc1 for special links.

How can I get a count of all links with a value at desc1?

I tried:
sub { $DB->table('Links')->count( { 'desc1', 'NOT LIKE', '' } ) }

But it will not work.

Also is it possible to create a list of all those links on one page through a global?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Global format In reply to
Hi,

For other reasons, I've use a special field, to decide if a Link is special or not.

And use:

sub {
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Hits DESC');
$sth = $search_db->select ( { isSpecial => 'Yes', isValidated => 'Yes' });
$output .= Links::SiteHTML::display ('link1', $link);
}
return $output;
}


And then the following should work:

sub { $DB->table('Links')->count( { 'isSpecial', 'Yes', '' } ) }

Best regards from
Bremen/Germany

Lothar

Last edited by:

eljot: Oct 22, 2004, 12:50 AM
Quote Reply
Re: [katabd] Global format In reply to
This should work;

Code:
sub {
my $count = $DB->table('Links')->count(GT::SQL::Condition('desc1', 'LIKE', '%')) || 0;
return $count;
}


...and the answer to you're second question;

Code:
sub {
my @links;
my $sth = $DB->table('Links')->select( GT::SQL::Condition('desc1', 'LIKE', '%') ) ||
return $GT::SQL::error;
while (my $link = $sth->fetchrow_hashref) {
$link->{detailed_url} = $CFG->{build_root_url} . "/Detailed/" . $link->{ID} . ".html";
push @links, $link;
}
return { extra_links => \@links };
}

...call with;

Code:
<%global_name%>
<%if extra_links%>
<%loop extra_links%>
<%include link.html%>
<%endloop%>
<%endif%>

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] Global format In reply to
Thanks Andy

The following works fine:

sub {
my $count = $DB->table('Links')->count(GT::SQL::Condition->new('desc1', 'NOT LIKE', '')) || 0;
return $count;
}
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Global format In reply to
To list all links with desc1 I use:

sub {
# Displays the books links.
my ($output,$sth,$link);
my $search_db = $DB->table('Links');
$search_db->select_options ('ORDER BY Add_Date ASC Limit 150')|| return $GT::SQL::error;
$sth = $search_db->select (select( GT::SQL::Condition->new('desc1', 'LIKE', '%') ) || return $GT::SQL::error;
while ($link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link_short', $link);
}
return $output;
}


But it is returnning a blank list.
Any idea?
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory
Quote Reply
Re: [katabd] Global format In reply to
Code:
$sth = $search_db->select (select( GT::SQL::Condition->new('desc1', 'LIKE', '%') ) || return $GT::SQL::error;

...should be;

Code:
$sth = $search_db->select ( GT::SQL::Condition->new('desc1', 'LIKE', '%') ) || return $GT::SQL::error;

Wink

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] Global format In reply to
thanks Andy
Regards
KaTaBd

Users plug In - Multi Search And Remote Search plug in - WebRing plug in - Muslims Directory