Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Search Upgrade

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #21  
Old 07-25-2003, 01:18 PM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

Just out of curiousity, do you have a URL I could look at?
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
  #22  
Old 07-25-2003, 01:22 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

Yep http://www.strollers.com/store/customer/search.php

I modified my search.php to expand the search to include anything in the descriptions, but other than that it is untouched.

and in case I did something wrong in my categories.php, here is my whole file
Quote:
<?
/************************************************** ***************************\
+-----------------------------------------------------------------------------+
| X-Cart |
| Copyright (c) 2001-2002 Ruslan R. Fazliev. All rights reserved. |
+-----------------------------------------------------------------------------+
| The Ruslan R. Fazliev forbids, under any circumstances, the unauthorized |
| reproduction of software or use of illegally obtained software. Making |
| illegal copies of software is prohibited. Individuals who violate copyright |
| law and software licensing agreements may be subject to criminal or civil |
| action by the owner of the copyright. |
| |
| 1. It is illegal to copy a software, and install that single program for |
| simultaneous use on multiple machines. |
| |
| 2. Unauthorized copies of software may not be used in any way. This applies |
| even though you yourself may not have made the illegal copy. |
| |
| 3. Purchase of the appropriate number of copies of a software is necessary |
| for maintaining legal status. |
| |
| DISCLAIMER |
| |
| THIS SOFTWARE IS PROVIDED BY Ruslan R. Fazliev ``AS IS'' AND ANY |
| EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| DISCLAIMED. IN NO EVENT SHALL Ruslan R. Fazliev OR ITS |
| CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| The Initial Developer of the Original Code is Ruslan R. Fazliev. |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2002 |
| Ruslan R. Fazliev. All Rights Reserved. |
+-----------------------------------------------------------------------------+
\************************************************* ****************************/

#
# $Id: categories.php,v 1.43 2002/11/14 07:58:18 zorg Exp $
#

#
# For users some categories may be disabled
#

#for increase speed
$enable_subcategories_count = $config["General"]["count_products"]=="Y"?1:0;

if ($current_area == "C") {
$membership_condition = " AND ($sql_tbl[categories].membership='$user_account[membership]' OR $sql_tbl[categories].membership='') ";
} else {
$membership_condition = "";
}

$categories_data = func_query("select $sql_tbl[categories].*, 0 as product_count from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category"));

#
# Put all categories into $all_categories array and find current_category
# by categoryid stored in $cat
#
if(!$categories_data) $categories_data = array();

$all_categories = $categories_data;

foreach($categories_data as $category_data) {
if ($category_data["categoryid"]==$cat) {
$current_category = $category_data;
$current_category["product_count"] = array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[products] WHERE (categoryid=$category_data[categoryid] OR categoryid1=$category_data[categoryid] OR categoryid2=$category_data[categoryid] OR categoryid3=$category_data[categoryid]) and $sql_tbl[products].forsale='Y'"));
}
}

#
# Put all root categories to $categories array
# Put all subcategories of current_category to $categories array
#

foreach($all_categories as $all_category) {

$category=$all_category["category"];

$cur_dir_len = strlen($current_category["category"]);

if(!strstr($category,"/")) {
$categories[]=$all_category;
if(empty($current_category)) {
if($enable_subcategories_count)
$all_category["product_count"]=array_pop(func_query_first("SELECT COUNT(*) FROM $sql_tbl[products] WHERE $sql_tbl[products].forsale='Y' and (categoryid='$all_category[categoryid]' OR categoryid1='$all_category[categoryid]' OR categoryid2='$all_category[categoryid]' OR categoryid3='$all_category[categoryid]')"));
$subcategories[]=$all_category;
}
}

if(substr($category,0,$cur_dir_len+1) == $current_category["category"]."/" and $category!=$current_category["category"])
if(!strstr(substr($category,$cur_dir_len+1),"/")) {
if($enable_subcategories_count)
$all_category["product_count"]=array_pop(func_query_first("select count(*) from $sql_tbl[products] where $sql_tbl[products].forsale='Y' and (categoryid='$all_category[categoryid]' OR categoryid1='$all_category[categoryid]' OR categoryid2='$all_category[categoryid]' OR categoryid3='$all_category[categoryid]')"));
$all_category["category"]=ereg_replace("^.*/","",$all_category["category"]);
$subcategories[]=$all_category;
}

}
#
# Put subcategory_count to $subcategories array
#
if ($subcategories)
foreach($subcategories as $key =>$subcategory) {

$subcategory["subcategory_count"]=0;

foreach($all_categories as $all_category) {
if ($all_category["categoryid"]==$subcategory["categoryid"]) {
$cur_dir_len = strlen($all_category["category"]);
$current_subcategory=$all_category["category"];
}
}

foreach($all_categories as $all_category) {
$category=$all_category["category"];
if(substr($category,0,$cur_dir_len+1) == $current_subcategory."/" and $category!=$current_subcategory)
if(!strstr(substr($category,$cur_dir_len+1),"/"))
$subcategory["subcategory_count"]++;
}
$subcategories[$key]["subcategory_count"]=$subcategory["subcategory_count"];
}

#
# Generate category sequence, i.e.
# Books, Books/Poetry, Books/Poetry/Philosophy ...
#

$current_category_array = explode("/",$current_category["category"]);
$prev = $current_category_array[0];
list($key,$val)=each($current_category_array);

$new_array = array($val);

while(list($key,$val)=each($current_category_array )) {
$new_array[] = $prev."/".$val;
$prev = $prev."/".$val;
}
unset($current_category_array);

#
# Generate array for displaying categories sequence in location
#

$category_location=array();
reset($all_categories);

$my_cats = array ();

foreach($all_categories as $all_category) {

$categoryid=$all_category["categoryid"];
$category=$all_category["category"];

$my_cats [$categoryid] = $category;
}

asort ($my_cats);

foreach ($my_cats as $categoryid => $category) {
reset ($new_array);
while(list($key,$val)=each($new_array))
if ($val==$category) $category_location[]=array(ereg_replace(".*/","",$val),"home.php?cat=".$categoryid);
}

#
# 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");
$categories_data2[$key][category] = strrchr($categories_data2[$key][category], "/");
}

#
# Assign Smarty variables
#

$smarty->assign("allcategories",$all_categories);
$smarty->assign("categories",$categories);
$smarty->assign("subcategories",$subcategories);
$smarty->assign("current_category",$current_category);
$smarty->assign("enable_subcategories_count",$enable_subca tegories_count);
$smarty->assign("cat",$cat);
?>

Thanks,
Cameron
Reply With Quote
  #23  
Old 07-25-2003, 01:28 PM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

Cameron,

Glad you posted your code.

Add this to the bottom where all the other smarty assignments are:

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

Also,

You can remove the following "last" line of code:
Code:
$categories_data2[$key][category] = strrchr($categories_data2[$key][category], "/");

It should work now, I think
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
  #24  
Old 07-25-2003, 01:37 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

Cool! It works!!! One (hopefully) last question though. How do I get it to display all of the subcategories instead of just the first five? I have 20 2nd level categories under one of my main categories, and 7-8 in the others.

Thanks!
Cameron
Reply With Quote
  #25  
Old 07-25-2003, 01:43 PM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

Cameron,

The mod is designed to only show the first level of sub categories under each main category. If you search any if the categories, the search automatically searchs all the subcategories under it.

If you still want all your categories and subcategories listed, do the following:

Replace the following lines of code in your advanced_search.tpl file:

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

with:

Code:
<select name="in_category"> <option value="">All</option> {section name=cat_num loop=$allcategories} <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>

It's not as pretty, but it gets the job done.
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
  #26  
Old 07-25-2003, 01:51 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

I think I asked the question in a murky way. I only have 2 levels of categories. The changes I made so far with your help are working. However, for my second level categories, it is only showing the first 5 second level categories, even if I have 8, 9, or 20 other second level categories.

If you look at http://www.strollers.com/store/customer/home.php?cat=3
and then at http://www.strollers.com/store/customer/search.php
you will see that in the drop down box for categories, it shows the first 5 stroller brands only, but I would like it to show all 20 or so.

Thanks,
Cameron
Reply With Quote
  #27  
Old 07-25-2003, 02:00 PM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

Cameron,

Just so I can see your db structure, change the code with the last post I put up and then let me know. I think this might have to do with the way your categories are stored.

We'll change the code back after I have a look.
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
  #28  
Old 07-25-2003, 02:09 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

I see what you're after now. I put it in as {section name=cat_num loop=$allcategories} which is what my categories.php has in it. (all_categories shows no categories.) What is odd is that it shows my main categories, then the rest of the categories aren't there, but there is space where they would be at.
Reply With Quote
  #29  
Old 07-25-2003, 02:13 PM
 
machnhed1 machnhed1 is offline
 

eXpert
  
Join Date: Feb 2003
Location: Illinois
Posts: 274
 

Default

Very strange indeed. Good call on the code, I'll edit my previous post now.

What does your xcart_categories table structure look like?

PM me the exported file (if you have phpmyadmin) or post it (with contents) on the board, so I can have a look.
__________________
Following the signature guidelines : xcart pro 3.5.8 - [RedHat]
Reply With Quote
  #30  
Old 07-25-2003, 02:21 PM
 
Cameron Cameron is offline
 

eXpert
  
Join Date: Jan 2003
Location: Washington State, USA
Posts: 224
 

Default

categoryid
image_x
image_y
category
description
meta_tags
avail
views_stats
order_by
membership
threshold_bestsellers


Is that what you're looking for?
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:15 AM.

   

 
X-Cart forums © 2001-2020