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

Products: Gossamer Links: Development, Plugins and Globals: Re: [MJB] Alphabetical pages: Edit Log

Here is the list of edits for this post
Re: [MJB] Alphabetical pages
Should be possible with a global like this:

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!

Last edited by:

Andy: Dec 3, 2009, 11:54 PM

Edit Log: