Gossamer Forum
Quote Reply
display global
I have been looking through the forums for the answer to this but cannot get anything to work.

I'm looking for a global that will do this:
using the search results
display only the first record
that has the field 'axis' filled in.

ie: if the first record found has the field 'axis' filled in, it will be displayed in the results.
if, however, the first record does not have the field 'axis' filled in, it will keep doing down the list until it finds a record to display.

Can anyone help me with this?
Thanks
Quote Reply
Re: [Alba] display global In reply to
Found the answer- funny how you find things as soon as you post the question- after hours of looking !

Quote:
sub {
my $tags = shift;
my $query = $tags->{query};
my $sth = $DB->table('Links')->query_sth ( { query => $query,ma => 1 ,mh => 5,nh=>1} );
my $output; while (my $link = $sth->fetchrow_hashref) {
next unless($link->{axis} ne '');
$output .= Links::SiteHTML::display('demo', $link);
}
return $output;
}
Quote Reply
Re: [Alba] display global In reply to
I now need to take this global further- to work with paging.

Quote:
sub {
my $tags = shift;
my $query = $tags->{query};
my $sth = $DB->table('Links')->query_sth ( { query => $query,ma => 1 ,mh => 1,nh=>1} );
my $output; while (my $link = $sth->fetchrow_hashref) {
next unless($link->{axis} ne '');
$output .= Links::SiteHTML::display('demo', $link);
}
return $output;
}

I need to return the first result on the page that is showing at the time.

ie:
page 1 shows result 1.
page 2 shows result 11
page 3 shows result 21

etc.