Hi Everyone,
I have modified the advanced search so that the customer can search not only the main categories, but also the first level of sub categories. For example currently x-cart has:
Code:
All
Books
CD - DVD - Video
Computer hardware
Electronics
Games and toys
Household
Men Clothes
Software
Sport
I modified is so that it has the following:
Code:
All
Books
Books/Internet
Books/Software
CD - DVD - Video
CD - DVD - Video/Subcat1
CD - DVD - Video/Subcat2
etc...
Here's how I did it. I modified categories.php by adding the following...
Code:
#
# Mod: Get all main categories and level 1 subcatgories and store them in an array
#
$categories_data1 = func_query("select * from $sql_tbl[categories] where category NOT LIKE '%/%' and avail='Y' group by $sql_tbl[categories].categoryid order by order_by");
foreach ($categories_data1 as $key=>$value) {
$categories_data2[$key][] = func_query("select * from $sql_tbl[categories] where category LIKE '".$value[category]."/%' and category NOT LIKE '".$value[category]."/%/%' and avail='Y' group by $sql_tbl[categories].categoryid order by order_by");
$categories_data2[$key][category] = strrchr($categories_data2[$key][category], "/");
}
Then I modified the customer/main/advancedsearch.tpl by replacing the drop down box code with the following:
Code:
<select name="in_category">
<option value="">All</option>
{section name=cat_num loop=$categories_level_1}
<option value="{ $categories_level_1[cat_num].categoryid}" {if $smarty.get.in_category eq $categories_level_1[cat_num].categoryid or $cat eq $categories_level_1[cat_num].categoryid}selected{/if}>
{$categories_level_1[cat_num].category|escape}
</option>
{section name=cat_num1 loop=$categories_level_2}
{if $categories_level_2[cat_num][0][cat_num1].categoryid ne ""}<option value="{ $categories_level_2[cat_num][0][cat_num1].categoryid}" {if $smarty.get.in_category eq $categories_level_2[cat_num][0][cat_num1].categoryid or $cat eq $categories_level_2[cat_num][0][cat_num1].categoryid}selected{/if}>
{$categories_level_2[cat_num][0][cat_num1].category|escape}
</option>{/if}
{/section}
{/section}
</select>
My question is this: Can anyone figure out how I can modify the subcategories so that only the subcategory shows up in the drop down box? So it would be -
Code:
All
Books
Internet
Software
CD - DVD - Video
Subcat1
Subcat2
etc...
I would really appreciate any help I am brain farting at the moment. So, if you like code return a favor
Thanks everyone.