X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Search Upgrade (https://forum.x-cart.com/showthread.php?t=3684)

machnhed1 07-25-2003 02:26 PM

Partly, if you could post the contents of the table (along with the headings) it would help. If you don't want that on the boards, pm me it in a CSV file and I can look on my own machine.

Cameron 07-25-2003 02:57 PM

This is crazy. I got an e-mail that you PM'd me, but the PM isn't in my inbox. I then PM'd you 3 times, but none of them show in my sent items. Can you e-mail me your e-mail address? I'm at cameron@cameron32.com

funkydunk 07-26-2003 01:59 AM

If you use the code that I posted on earlier on this thread for categories.php and use the following for advanced search - it works.

Code:

{* $Id: advanced_search.tpl,v 1.3 2002/10/08 12:01:17 alfiya Exp $ *}
{include file="location.tpl" last_location=$lng.lbl_advanced_search}
{capture name=adv_search}
<table border=0>
<form action="search.php" name="productsearchbyprice_form">
<tr>
<td>{$lng.lbl_product_title}</td>
<td>
<input type="text" name="substring" size="30" value="{$smarty.get.substring}">
</td>
</tr>
<tr><td>{$lng.lbl_price}, {$config.General.currency_symbol}</td>
<td><input type="text" name="price_search_1" size="6" value="{$smarty.get.price_search_1|escape}"> - <input type="text" name="price_search_2" size="6" value="{$smarty.get.price_search_2|escape}"></td></tr>
<tr><td>{$lng.lbl_category}</td>
<td>
<select name="in_category">
<option value="">All</option>

{section name=cat_num loop=$categories}
<option value="{ $categories[cat_num].categoryid}">{ $categories[cat_num].category|escape }</option>
{section name=cat_num1 loop=$allcategories}
{if $allcategories[cat_num1].topcat eq $categories[cat_num].category_name}
<option value="{ $allcategories[cat_num1].categoryid}">- { $allcategories[cat_num1].category_name|escape }</option>
{/if}
{/section}
{/section}

</select>
</td>
</tr>
<tr><td></td></tr>
<tr><th>{include file="buttons/search.tpl"}</th></tr>
</form>
</table>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_advanced_search content=$smarty.capture.adv_search extra="width=100%"}


Cameron 07-26-2003 09:03 AM

Unfortunately, I'm still on 3.3.5 so I can't use your categories.php -- What seems so odd is that it was mostly working, but it was only displaying the first 5 second level categories instead of all of them, but I can't see what in either categories.php or advanced_search.tpl is making that happen.

Cameron 07-26-2003 09:19 AM

I got it!!! Funky, I was looking at the advanced_search.tpl code you had and decided to try using $allcategories for the second level categories.

Machnhed1, I had replaced the whole drop down code with the $allcategories code that you had me put in before instead of only the 2nd level part. If I messed up there and was supposed to do it for just the 2nd level section, I apologize profusely for wasting your time.

Thank you both for helping me work this out!!!!!!! :)

So, for those who have made it this far through this thread and are using 3.3.x , here is what you need to do:

Store/include/categories.php
Before the lines for # Assign Smarty variables, add this code:
Quote:

#
# 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 $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");
}

at the end of the file, add these lines:
Quote:

$smarty->assign("categories_level_1",$categories_data1);
$smarty->assign("categories_level_2",$categories_data2);

/store/skin1/customer/main/advanced_search.tpl
replace <select name="in_category">
<option value="">All</option>
{section name=cat_num loop=$categories}
<option value="{ $categories[cat_num].categoryid}" {if $smarty.get.in_category eq $categories[cat_num].categoryid or $cat eq $categories[cat_num].categoryid}selected{/if}>{$categories[cat_num].category|escape}</option>
{/section}
</select>

with this:
Quote:

<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=$allcategories}
{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_name|escape}
</option>{/if}
{/section}

{/section}
</select>


Cameron 07-26-2003 09:38 AM

Oops...I just hit another snag here. The search function, even though it is now showing all 2nd level categories is ONLY showing results within a category that has products in it as a "main category" The "category #1 #2 #3 & #4" assignments that you can make in the back office to have a product display in other categories aren't being searched.

As an example: Jogging Strollers has about 16 products in it when you browse directly to the category. However, all of those products are assigned to that category as "Category #3" and when I search Jogging Strollers for *anything* no results appear.

I am willing to pay for the solution to this so that the search will show results from my second level categories, even if the products in them aren't put in as the "main category" without creating a ton of duplicate searches when somebody doesn't drill down to a sub category.

Funky or anybody who can do this, please PM me with a quote. Wait, x-cart PM is being weird. Please *e-mail* me: cameron@cameron32.com

Thanks,
Cameron

Mad 07-27-2003 09:41 AM

Used information within to make subcatagories to be listed at all times on the left side's catagory section. Great post, thank you!

technicaldata 11-16-2005 03:38 PM

X-Cart 4.0.17?
 
Does anyone have a version of this mod that will work with X-Cart Pro 4.0.17?

technicaldata 11-16-2005 03:41 PM

P.S.
 
I started a new thread for this for 4.0.x users:

http://forum.x-cart.com/viewtopic.php?p=115113

I dunno if this was the right idea or not but what the hey.


All times are GMT -8. The time now is 03:43 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.