![]() |
Search Upgrade
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 I modified is so that it has the following: Code:
All Here's how I did it. I modified categories.php by adding the following... Code:
# Then I modified the customer/main/advancedsearch.tpl by replacing the drop down box code with the following: Code:
<select name="in_category"> 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 I would really appreciate any help I am brain farting at the moment. So, if you like code return a favor :) Thanks everyone. |
{$categories_level_2[cat_num][0][cat_num1].category_name|escape}
I spend ages working that one out for a drop down menu system for a site. :lol: Nice coding 8) |
FD,
Thanks for the complement. I tried implementing your solution. It printed the values of the select options, but not the select options. I don't have a category_name column in my table (3.3.6) so that may be the problem. Here is a list of my xcart_categories table columns: categoryid image_x image_y category description meta_tags avail views_stats order_by membership threshold_bestsellers Any ideas? Thanks again :!: |
There isn't in mine either - but it does a little ditty with the dbase query in include/categories.php:
This may be missing from your coding :) |
My categories.php code: (version 3.4.2)
Code:
<? Then in the categories.tpl you could have something like: Code:
{section name=cat_num loop=$categories} This shows each main section then that section subsections under it... Cat 1 - sub cat 1 - sub cat 2 Cat 2 - sub cat 3 - sub cat 4 etc hth :) |
Heck yeah, it worked really well. I simply updated my SQL statement from:
Code:
$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"); To: Code:
$categories_data2[$key][] = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name 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"); Thanks a ton, I would have never of guessed to updated my SQL statement, I was stuck on a PHP solution. :oops: |
I do that...get caught up solving a really big issue and some smart r's comes along :lol:
BTW - if someone wants to use the code above to produce a javascript drop down menu (that's what I used it for - obviously stripped the JS out for this post) then feel free. |
I didn't catch that the first 3 times, can you please repeat it?
:lol: |
Yeah alright already, we heard you the first time ;)
Someone prod funky he's gone into a loop. |
slight connection problem - just kept pressing submit :lol:
Code:
<?php welcome to my loop :) |
All times are GMT -8. The time now is 08:53 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.