View Single Post
  #12  
Old 11-23-2002, 05:02 PM
 
derrick92130 derrick92130 is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: San Diego, California USA
Posts: 68
 

Default 3.2.1 category customization

Here are the changes described in previous posting:
I'll PREFIX the changes with ##BEGIN and end with ##END

/xcart/include/categories.php
Code:
# # $Id: categories.php,v 1.36.2.1 2002/09/30 08:48:38 alfiya Exp $ # ##BEGIN # Register "lastsub" array for use throughout site # session_register("lastsub"); # # If new category was selected, dump the old subcategories if($topcat == ""){ $lastsub=""; } ##END # # For users some categories may be disabled # 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 avail>0")); } } # # 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)) { $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),"/")) { $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; ##BEGIN # Add values to lastsub array if at first subcategory level if($topcat == ""){ $lastsub[] = $all_category; } ##END } } # # 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); } # # Assign Smarty variables # ##BEGIN $smarty->assign("lastsub",$lastsub); $smarty->assign("topcat",$topcat); ##END $smarty->assign("allcategories",$all_categories); $smarty->assign("categories",$categories); $smarty->assign("subcategories",$subcategories); $smarty->assign("current_category",$current_category); $smarty->assign("cat",$cat); ?>

/xcart/skin1/customer/categories.tpl
Code:
{* $Id: categories.tpl,v 1.14 2002/09/10 12:58:26 zorg Exp $ *} <TABLE border=0 cellPadding=5 cellSpacing=0 width=100%> <TR> <TD class=MenuTitleLine height=26 width=26 valign=center>[img]{$ImagesDir}/dingbats_categorie.gif[/img]</TD> <TD class=MenuTitleLine height=26 valign=center align=middle width="80%"><FONT class=TableLeftTitles>{$lng.lbl_categories}</FONT></TD> </TR> <tr><td colspan=2 class="TableLeftElements" nowrap> {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <font class=CategoriesList>{ $categories[cat_num].category|escape }</font> {/section} {else} ##BEGIN {section name=cat_num1 loop=$categories} { $categories[cat_num1].category|escape } {if $categories[cat_num1].categoryid eq $cat} {section name=cat_num2 loop=$subcategories} <a class=CategoriesList href="home.php?cat={ $subcategories[cat_num2].categoryid }&topcat={$cat}"> { $subcategories[cat_num2].category|escape }</a> {/section} {else} {if $categories[cat_num1].categoryid == $topcat} {section name=cat_num3 loop=$lastsub} <a class=CategoriesList href="home.php?cat={ $lastsub[cat_num3].categoryid }&topcat={$topcat}"> { $lastsub[cat_num3].category|escape }</a> {/section} {/if} {/if} ##END {/section} {/if} </td></tr> </TABLE>

/xcart/skin1/customer/main/products.tpl
Code:
{* $Id: products.tpl,v 1.16 2002/09/25 10:12:05 zorg Exp $ *} {section name=product loop=$products} <table border=0 width=100%> <tr><td width=90 align=center valign=top> ##BEGIN <a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}&topcat={if $topcat == ""}{$cat}{else}{$topcat}{/if}>{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=70 product=$products[product].product} { $lng.lbl_see_details }</a> </td> <td valign=top> <font class=TableCenterProductTitleBlue>{$products[product].product|escape}</font> ##END <font class=TableCenterProductTitleOrange></font> <font size=1> {$products[product].descr|truncate:300:"...":true} </font> <hr size=1 noshade width=230 align=left> {if $active_modules.Subscriptions ne "" and $products[product].catalogprice} {include file="modules/Subscriptions/subscription_info_inlist.tpl"} {else} {if $products[product].price ne 0} {if $products[product].discount ne 0} <font class=MarketPrice>{$lng.lbl_market_price}: <s>{math equation="(price/(100-discount))*100" price=$products[product].price discount=$products[product].discount format="%d.00" assign=unformatted}{include file="currency.tpl" value=$unformatted}</s></font> {/if} <font class=TableCenterProductTitleOrange>{$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}</font><font class=MarketPrice>{include file="customer/main/alter_currency_value.tpl" alter_currency_value=$products[product].price}</font>{if $products[product].discount ne 0}, save {$products[product].discount}%{/if} {else} <font class=TableCenterProductTitleOrange>{$lng.lbl_enter_your_price}</font> {/if} {/if} </td></tr> </table> {/section}

/xcart/skin1/location.tpl
Code:
{* $Id: location.tpl,v 1.6 2002/09/05 12:43:21 zorg Exp $ *} {strip} <a href="home.php"> <font class="TableCenterNavigationPath">{$config.Company.company_name}</font> </a> {if $last_location ne ""} :: {if $last_url ne ""} <a href="{$last_url}"> {/if} <font class="TableCenterNavigationPath">{$last_location}</font> {if $last_url ne ""} </a> {/if} {/if} :: {section name=position loop=$location} {if $location[position].1 ne "" } ##BEGIN <a href="{$location[position].1}&topcat={if $topcat == ""}{$cat}{else}{$topcat}{/if}"> ##END {/if} <font class="TableCenterNavigationPath">{$location[position].0|escape}</font> {if $location[position].1 ne "" }</a>{/if} {if %position.last% ne "true"}:: {/if} {/section} {/strip}

Obviously no warranty on the code, it works for me under 3.2.1. Let me know if you have any issues making this work!
__________________
-Derrick
FreeRangeMinds, LLC
Reply With Quote