Forums / General Questions / Can you change the alpha sorter from a drop down menu in to a text links?

Can you change the alpha sorter from a drop down menu in to a text links?

Locked

Started by illusionguy on 20 May 2008, 6:22 PM · Views: 2,566

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
20 May 2008, 6:22 PM
#1
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Can you change the alpha sorter from a drop down menu in to a text links?

On the category page how can we change the alpha sorter from a drop down menu in to a text links like so:

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

20 May 2008, 6:45 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Can you change the alpha sorter from a drop down menu in to a text links?

Maybe something like this?:

sperling.com/examples/menuh/

28 May 2008, 5:45 PM
#3
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

Ok there is probably a cleaner way of doing this but, I got this to work on the category page.

<div id="alpha_filter">
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=65" class="alpha_filter">A</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=66" class="alpha_filter">B</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=67" class="alpha_filter">C</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=68" class="alpha_filter">D</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=69" class="alpha_filter">E</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=70" class="alpha_filter">F</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=71" class="alpha_filter">G</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=72" class="alpha_filter">H</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=73" class="alpha_filter">I</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=74" class="alpha_filter">J</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=75" class="alpha_filter">K</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=76" class="alpha_filter">L</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=77" class="alpha_filter">M</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=78" class="alpha_filter">N</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=79" class="alpha_filter">O</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=80" class="alpha_filter">P</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=81" class="alpha_filter">Q</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=82" class="alpha_filter">R</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=83" class="alpha_filter">S</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=84" class="alpha_filter">T</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=85" class="alpha_filter">U</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=86" class="alpha_filter">V</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=87" class="alpha_filter">W</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=88" class="alpha_filter">X</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=89" class="alpha_filter">Y</a>|
  <a href="index.php?main_page=index&cPath=<?=$_GET['cPath']?>&sort=20a&alpha_filter_id=90" class="alpha_filter">Z</a>
</div>

Is there a way to adapt these links to work on the products all page (tpl_products_all_default.php)?

28 May 2008, 6:09 PM
#4
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

Is it even posible to add an alpha sorter to the all products page? I have been playing with this code now for days :frusty:

29 May 2008, 2:12 PM
#5
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

Is it posible to add the alpha sorter to the all products page?

3 Jun 2008, 10:44 PM
#6
flipside avatar

flipside

Zen Follower

Join Date:
Oct 2004
Location:
Ontario
Posts:
114
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

Message me if you are still looking for help.

24 Jul 2008, 2:05 AM
#7
zskiman avatar

zskiman

New Zenner

Join Date:
Mar 2005
Posts:
69
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

just wanted to say thanx for the great post, this was suggested to me to try on our site and i started scratchin my head, thinking of how involved it would be.

i found this post, and it took all but 5 minutes to setup, and it looks and works great.

thanks again!!!

Never be afraid to try something new, remember that amateurs built the ark, professionals built the Titanic

24 Jul 2008, 6:51 PM
#8
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

Thanks for the reply zskiman

I have updated the above code and cleaned it up:

function GetAlphabet($type='string',$lower=false){
    $spacer = " | ";
 $r = ($type == 'string') ? '' : array();
    // chr 65 => A, chr 90 => Z
    for ($c=65; $c <= 90; $c++){
     if (!isset($alpha_filter_id)){$alpha_filter_id = 65;}
        $ch = ($lower) ? strtolower(chr($c)) : '<a href="index.php?main_page=index&cPath='.$_GET['cPath'].'&alpha_filter_id='.$alpha_filter_id.'">'.chr($c)."</a>$spacer";
        if ($type == 'string'){ $r .= $ch; }
        else { $r[] = $ch; }
  $alpha_filter_id = $alpha_filter_id+1;
    }
    return $spacer.$r;
}
echo GetAlphabet();
21 Oct 2008, 8:27 PM
#9
illusionguy avatar

illusionguy

Zen Follower

Join Date:
May 2007
Posts:
136
Plugin Contributions:
0

Re: Can you change the alpha sorter from a drop down menu in to a text links?

I made an update to this code, I added some css when a letter is active it will be bold and black, so that the user knows what page they are on.

function GetAlphabet($type='string',$lower=false){
    $spacer = " | ";
 $r = ($type == 'string') ? '' : array();
    // chr 65 => A, chr 90 => Z
    for ($c=65; $c <= 90; $c++){
     if (!isset($alpha_filter_id)){$alpha_filter_id = 65;}
     if ($alpha_filter_id == $_GET['alpha_filter_id']){$style = ' style="font-weight:bold; font-size:12px; color:#000000;"';}else{$style = '';}
        $ch = ($lower) ? strtolower(chr($c)) : '<a href="index.php?main_page=index&cPath='.$_GET['cPath'].'&alpha_filter_id='.$alpha_filter_id.'"'.$style.'>'.chr($c)."</a>$spacer";
        if ($type == 'string'){ $r .= $ch; }
        else { $r[] = $ch; }
  $alpha_filter_id = $alpha_filter_id+1;
    }
    return $spacer.$r;
}
echo GetAlphabet();