Should be possible with a global like this:
get_links_by_letter
my $tbl = $DB->table('Links');
$tbl->select_options("ORDER BY Title");
my $letter = $IN->param('letter');
my $sth = $tbl->select( GT::SQL::Condition->new('isValidated','=',"Yes",'Title','LIKE',"$letter%") );
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $hit->{ID} ); }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @loop, $hit;
}
return { links_loop => \@loop };
}
Then make a new template (called get_links_by_letter.html) ... and call that global with:
<%if links_loop.length%>
<ul>
<%loop links_loop%>
<li><%Title%></li>
<%endloop%>
</ul>
<%else%>
No matches
<%endif%>
Then call with page.cgi?p=get_links_by_letter;letter=A (that should get a list of all links where "Title" starts with "A" or "a")
Untested - and was written literally after getting out of bed - so could be some issues that may need fixing :)
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!
get_links_by_letter
Code:
sub { my $tbl = $DB->table('Links');
$tbl->select_options("ORDER BY Title");
my $letter = $IN->param('letter');
my $sth = $tbl->select( GT::SQL::Condition->new('isValidated','=',"Yes",'Title','LIKE',"$letter%") );
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $hit->{ID} ); }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @loop, $hit;
}
return { links_loop => \@loop };
}
Then make a new template (called get_links_by_letter.html) ... and call that global with:
Code:
<%get_links_by_letter%> <%if links_loop.length%>
<ul>
<%loop links_loop%>
<li><%Title%></li>
<%endloop%>
</ul>
<%else%>
No matches
<%endif%>
Then call with page.cgi?p=get_links_by_letter;letter=A (that should get a list of all links where "Title" starts with "A" or "a")
Untested - and was written literally after getting out of bed - so could be some issues that may need fixing :)
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!