You are here:  » Filter by First Letter of Product Name

Support Forum



Filter by First Letter of Product Name

Submitted by stevencrocker on Sat, 2009-04-04 14:20 in

I am wondering if this can even be done.

I have one category that contains a large number of products. In order to make browsing by product a bit easier I was wondering if I could somehow create a link that would filter all the products in that category by the first letter of their name/

Because this is a main category to me I was thinking of putting something like this in the index sidebar
:
Browse Products in Category 1 by Name
A (link - to display all products in Category 1 that start with A)
B (link - to display all products in Category 1 that start with B)
and on thru the alphabet...

Thanks again David for all the help. I really appreciate it, my site is coming along thanks to you.

Steven

Submitted by support on Mon, 2009-04-06 07:32

Hi Steven,

A very simply mod would support this in fact. In search.php, look for the following code on line 43:

if (isset($parts[2])) if ($parts[2]) $where .= "AND search_name LIKE '%".database_safe(tapestry_search($parts[2]))."%'";

...and REPLACE this with:

if (isset($parts[2]))
{
  if (strlen($parts[2])==1)
  {
    $where .= "AND search_name LIKE '".database_safe(tapestry_search($parts[2]))."%'";
  }
  elseif($parts[2])
  {
    $where .= "AND search_name LIKE '%".database_safe(tapestry_search($parts[2]))."%'";
  }
}

With that in place, you can now link to the search results for a given category with products beginning with, say, letter A as follows:

search.php?q=category:Some+Category:A

Cheers,
David.

Submitted by stevencrocker on Mon, 2009-04-06 15:34

Thanks David.