PDA

View Full Version : How to create alphabetical links within categories/sub-categories



basnyd
05-31-2007, 06:47 PM
I got it working! Here it is:

In the catalog\includes\modules\product_listing.php add this where you want the navigation to be:


<table width="100%" border="0" cellspacing="2" cellpadding="1">
<tr><td class=main align=center>
<a href=index.php?cName=<?php echo $cName?>&alpha=a>A</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=b>B</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=c>C</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=d>D</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=e>E</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=f>F</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=g>G</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=h>H</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=i>I</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=j>J</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=k>K</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=l>L</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=m>M</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=n>N</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=o>O</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=p>P</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=q>Q</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=r>R</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=s>S</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=t>T</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=u>U</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=v>V</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=w>W</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=x>X</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=y>Y</a> |
<a href=index.php?cName=<?php echo $cName?>&alpha=z>Z</a><br /><br />
</td></tr></table>


In catalog\index.php modifying the existing query to read (towards end of file):



} else { // either retail or no need to get correct special prices
// LINE CHANGED: MS2 update 501112
// added alpha page selections to query
if (!is_null($_GET['alpha'])) $addregex = "pd.products_name REGEXP '^[".strtoupper($_GET['alpha'])."!".strtolower($_GET['alpha'])."].*$' and ";

$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id left join " . TABLE_SPECIALS_RETAIL_PRICES . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where ".$addregex." p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} // end else { // either retail...
// EOF: MOD - Separate Pricing Per Customer
}
}


I hope this helps others.
Barb