Gossamer Forum
Home : Products : Gossamer Links : Discussions :

External Link for Alphabetical

Quote Reply
External Link for Alphabetical
Right now I have my listings set up as the highest rated first, but I would like to be able to give the OPTION for people to click a link and have it rebuilt as an alphabetical listing.

How can I do this?

Thank you!
Quote Reply
Re: [Me2Be] External Link for Alphabetical In reply to
hello,

I have build a small list in which you can order links alphabetically

you can use the following global:


sub alphabar {
# -------------------------------------------------------------------
# You call this tag by placing <%Links::BuiltinFunc::Selector::alphabar_desc%> in your
# templates.
#
my $tags = GT::Template->tags;
my $letter = $IN->param ('letter');
my $limit = $IN->param ('limit');
my $order = $IN->param ('order');
my $link_db = $DB->table ('Links');
if ($limit) {
$link_db->select_options ("ORDER BY Title $order", "LIMIT $limit");
}
if (! $limit) {
$link_db->select_options ("ORDER BY Title $order", "LIMIT 25");
}
my $sth = $link_db->select ( GT::SQL::Condition->new ('Title', 'LIKE', $letter.'%') );
my $total = $link_db->hits;
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}



you can claa this script with the following url

http://your_cgi-bin/page.cgi?p=yourtemplate&letter=yourletter&limit=yourlimmit&order=asc

view an examle at
http://ridesworld.com/cgi-bin/ridesworld/page.cgi?p=alphabar&letter=a&limit=25&order=asc&d=1
Quote Reply
Re: [ridesworld] External Link for Alphabetical In reply to
Thanks for your help!!! I tried it, but I got this error -- did you create a new template too?


"Invalid Site HTML method: site_html_alphabar (alphabar.html). Most likely template does not exist in default. at /www/ccc.com/cgi-bin/ccc/admin/Links/SiteHTML.pm line 208."

Last edited by:

Me2Be: Apr 1, 2002, 9:34 AM
Quote Reply
Re: [Me2Be] External Link for Alphabetical In reply to
hello,

yes i build a new template called alphabar.html in which I use the global and this javascript for display options:


<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD CLASS="black" WIDTH="1" HEIGHT="1" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="1" HEIGHT="1" ALT="pixel"></TD>
<TD CLASS="black" WIDTH="340" HEIGHT="1" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="340" HEIGHT="1" ALT="pixel"></TD>
<TD CLASS="black" WIDTH="1" HEIGHT="1" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="1" HEIGHT="1" ALT="pixel"></TD>
</TR><FORM NAME="doublecombo"><TR>
<TD CLASS="black" WIDTH="1" HEIGHT="50" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="1" HEIGHT="50" ALT="pixel"></TD>
<TD CLASS="dateline" WIDTH="340" HEIGHT="50" ALIGN="center" VALIGN="middle" NOWRAP>
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">
<TR>
<TD CLASS="dateline" WIDTH="140" HEIGHT="50" ALIGN="left" VALIGN="middle"><SPAN CLASS="form">&nbsp;Display&nbsp;
<SELECT CLASS="form" NAME="select" onChange="redirect(this.options.selectedIndex)">
<OPTION>----</OPTION>
<OPTION <%if limit eq '10'%>SELECTED<%endif%>>10</OPTION>
<OPTION <%if limit eq '25'%>SELECTED<%endif%>>25</OPTION>
<OPTION <%if limit eq '50'%>SELECTED<%endif%>>50</OPTION>
<OPTION <%if limit eq '75'%>SELECTED<%endif%>>75</OPTION>
<OPTION <%if limit eq '100'%>SELECTED<%endif%>>100</OPTION>
<OPTION <%ifnot limit%>SELECTED<%endif%>>all</OPTION>
</SELECT>&nbsp;Hits</SPAN></TD>
<TD CLASS="dateline" WIDTH="140" HEIGHT="50" ALIGN="left" VALIGN="middle"><SPAN CLASS="form">&nbsp;Ordered&nbsp;
<SELECT CLASS="form" NAME="stage2">
<OPTION VALUE="#" <%if order eq 'asc'%>SELECTED<%endif%>>ascending</OPTION>
<OPTION VALUE="#" <%if order eq 'desc'%>SELECTED<%endif%>>descending</OPTION>
</SELECT></SPAN></TD>
<TD CLASS="dateline" WIDTH="60" HEIGHT="50" ALIGN="left" VALIGN="middle">
<SPAN CLASS="form"><INPUT CLASS="form" TYPE="button" VALUE="go" onClick="go()"></SPAN></TD>
</TR>
</TABLE>
</TD>
<TD CLASS="black" WIDTH="1" HEIGHT="50" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="1" HEIGHT="50" ALT="pixel"></TD>
</TR><TR>
<TD CLASS="black" WIDTH="1" HEIGHT="1" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="1" HEIGHT="1" ALT="pixel"></TD>
<TD CLASS="black" WIDTH="340" HEIGHT="1" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="340" HEIGHT="1" ALT="pixel"></TD>
<TD CLASS="black" WIDTH="1" HEIGHT="1" VALIGN="middle" NOWRAP><IMG SRC="<%build_images_url%>/pixel.gif" WIDTH="1" HEIGHT="1" ALT="pixel"></TD>
</TR>
</TABLE><P>

<SCRIPT LANGUAGE='JavaScript1.2'>
<!--

var groups=document.doublecombo.select.options.length
var group=new Array(groups)
for (i=0; i<groups; i++)
group=new Array()

group[0][0]=new Option("ascending","#")
group[0][1]=new Option("descending","#")

group[1][0]=new Option("ascending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=10&order=asc")
group[1][1]=new Option("descending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=10&order=desc")

group[2][0]=new Option("ascending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=25&order=asc")
group[2][1]=new Option("descending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=25&order=desc")

group[3][0]=new Option("ascending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=50&order=asc")
group[3][1]=new Option("descending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=50&order=desc")

group[4][0]=new Option("ascending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=75&order=asc")
group[4][1]=new Option("descending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=75&order=desc")

group[5][0]=new Option("ascending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=100&order=asc")
group[5][1]=new Option("descending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&limit=100&order=desc")

group[6][0]=new Option("ascending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&order=asc")
group[6][1]=new Option("descending","<%db_cgi_url%>/page.cgi?p=alphabar&letter=<%letter%>&order=desc")

var temp=document.doublecombo.stage2

function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options=new Option(group[x].text,group[x].value)
}
temp.options[0].selected=true
}

function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</SCRIPT>
</FORM>