| mikea93449 |
08-03-2004 02:38 AM |
Hi Carrie,
I'm not sure if I did something wrong or not but the categories are now kind of screwed up in how they are displaying. You can view what it is doing at http://www.solutionsforliving.biz and clicking on any of the category links across the top portion of the page. I'm posting the code for the 3 files that seem to be affected:
include/categories.php:
Code:
#
# $Id: categories.php,v 1.52.2.5 2004/04/21 05:36:49 mclap Exp $
#
if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }
if (empty($cat)) $cat = 0;
#
# For users some categories may be disabled
#
if ($current_area == "C" and !empty($user_account)) {
$membership_condition = " AND ($sql_tbl[categories].membership='$user_account[membership]' OR $sql_tbl[categories].membership='') ";
} else {
$membership_condition = " AND ($sql_tbl[categories].membership='') ";
}
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name 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();
$current_category = "";
foreach($categories_data as $k=>$category_data) {
if ($current_area == "C") {
$int_res = func_query_first("SELECT * FROM $sql_tbl[categories_lng] WHERE code='$store_language' AND categoryid='$category_data[categoryid]'");
if (!empty($int_res["category"])) {
$categories_data[$k]["category_name_orig"] = $category_data["category_name_orig"] = $category_data["category_name"];
$categories_data[$k]["category_name"] = $category_data["category_name"] = $int_res["category"];
}
if (!empty($int_res["description"]))
$categories_data[$k]["description"] = $category_data["description"] = $int_res["description"];
}
if ($category_data["categoryid"]==$cat) {
$current_category = $category_data;
}
}
if (empty($current_category)) $cat = 0;
$all_categories = $categories_data;
#
#
#
if (!empty($active_modules["Fancy_Categories"]))
@include $xcart_dir."/modules/Fancy_Categories/fancy_categories.php";
# BCSE Begin
if(empty($subcategories))
{
$pos=strpos($current_category["category"],"/");
while(!$pos===false)
{
$previous_pos=$pos;
$pos=strpos($current_category["category"],"/",$pos+1);
}
$parent = substr($current_category["category"],0,($previous_pos+$pos));
if (!empty($parent))
$cur_dir_len = strlen($parent);
foreach($all_categories as $all_category)
{
$category=$all_category["category"];
if(!strstr($category,"/")) {
$categories[]=$all_category;
if(empty($parent)) {
$super_subcategories[]=$all_category;
}
}
if(!empty($parent) and substr($category,0,$cur_dir_len+1) == $parent."/" and $category!=$parent)
{
if(!strstr(substr($category,$cur_dir_len+1),"/"))
{
$all_category["category"]=ereg_replace("^.*/","",$all_category["category"]);
$super_subcategories[]=$all_category;
}
}
}
if(!empty($super_subcategories))
{
$smarty->assign("super_subcategory",$super_subcategories);
}
}
# BCSE End
#
# Put all root categories to $categories array
# Put all subcategories of current_category to $categories array
#
if (!empty($current_category))
$cur_dir_len = strlen($current_category["category"]);
foreach($all_categories as $all_category) {
$category=$all_category["category"];
if(!strstr($category,"/")) {
$categories[]=$all_category;
if(empty($current_category)) {
$subcategories[]=$all_category;
}
}
if(!empty($current_category) and 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["category"]=ereg_replace("^.*/","",$all_category["category"]);
$subcategories[]=$all_category;
}
}
#
# Put subcategory_count to $subcategories array
#
if (!empty($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 ...
#
if (!empty($current_category)) {
$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) {
foreach($categories_data as $category_data) {
if ($category_data["categoryid"] == $categoryid)
$val = $category_data["category_name"];
}
$category_location[]=array(ereg_replace(".*/","",$val),"home.php?cat=".$categoryid);
}
}
}
}
if ($current_area == "C" and !empty($current_category) and $config["Images"]["icons_location"] == "FS") {
$current_category["image_path"] = array_pop(func_query_first("SELECT image_path FROM $sql_tbl[icons] WHERE categoryid='$cat'"));
if (eregi("^(http|ftp)://", $current_category["image_path"])) {
# image_path is an URL
$current_category["icon_url"] = $current_category["image_path"];
}
elseif (!strncmp($xcart_dir, $current_category["image_path"], strlen($xcart_dir))) {
# image_path is an locally placed image
$current_category["icon_url"] = $current_location.substr($current_category["image_path"], strlen($xcart_dir));
}
}
#
# Assign Smarty variables
#
$smarty->assign("allcategories",$all_categories);
$smarty->assign("categories",$categories);
if (!empty($subcategories))
$smarty->assign("subcategories",$subcategories);
if (!empty($current_category))
$smarty->assign("current_category",$current_category);
$smarty->assign("cat",$cat);
?>
catagories.tpl:
Code:
{* $Id: categories.tpl,v 1.19.2.1 2004/03/16 12:12:16 svowl Exp $ *}
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{include file="`$fancycategories_config.modules_path`/fancy_categories.tpl"}
{else}
{if $config.General.root_categories eq "Y"}
{section name=cat_num loop=$categories}
<font class=CategoriesList>{$categories[cat_num].category_name}</font>
{/section}
{else} {section name=cat_num loop=$subcategories}
<font class=CategoriesList>{$subcategories[cat_num].category_name}</font>
{/section}
{* BCSE Begin *}
{section name=super_idx loop=$super_subcategory}
<font class=CategoriesList>{$super_subcategory[super_idx].category_name}</font>
{/section}
{* BCSE End *}
{/if}
{/if}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu }
and head.tpl:
Code:
{* $Id: head.tpl,v 1.30.2.3 2004/03/09 08:28:25 svowl Exp $ *}
<table border="0" width="768" cellspacing="0" cellpadding="0">
<tr>
<td width="768">
<img src ="{$ImagesDir}/logo1_01.gif" border="0"><img border="0" src ="{$ImagesDir}/logo1_06.gif"><img border="0" src ="{$ImagesDir}/logo1_07.gif"><img border="0" src ="{$ImagesDir}/logo1_08.gif"><img border="0" src ="{$ImagesDir}/logo1_09.gif"><img border="0" src ="{$ImagesDir}/logo1_10.gif"><img border="0" src ="{$ImagesDir}/logo1_11.gif"><img border="0" src ="{$ImagesDir}/logo1_12.gif"></td>
</tr>
</table>
<table width="768" border="0" cellpadding="0" cellspacing="0"><tr><td width="8">[img]{$ImageDir}/logo1_13.gif[/img]</td>
{section name=cat_num loop=$categories}
<td width="760">
<a href="home.php?cat={$categories[cat_num].categoryid}" >
<img src ="{$ImagesDir}/navpics/{$categories[cat_num].categoryid}.gif" border="0">
</a>
</td>
{/section}
</tr>
</table>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="768">
<TR>
<TD colspan=2 class=VertMenuBorder>[img]{$ImagesDir}/spacer.gif[/img]</TD>
</TR>
<TR>
<TD class=HeadLine height=22>
{if $usertype eq "C"}
{ include file="customer/search.tpl" }
{/if}
</TD>
<TD class=HeadLine align=right>
{if $usertype eq "C" and $all_languages_numba gt 1}
<table border=0 cellpadding=0 cellspacing=0>
<FORM action="home.php" method=GET name=sl_form>
<INPUT type=hidden name="redirect" value="{$smarty.server.PHP_SELF}?{$smarty.server.QUERY_STRING}">
<tr>
<td>
{$lng.lbl_select_language}:
<SELECT name=sl onChange="javascript: document.sl_form.submit()">
{section name=ai loop=$all_languages}
<OPTION value="{$all_languages[ai].code}"{if $store_language eq $all_languages[ai].code} selected{/if}>{$all_languages[ai].language}</OPTION>
{/section}
</SELECT>
</td></tr>
</FORM>
</table>
{elseif ($usertype eq "P" or $usertype eq "A") and $login and $all_languages_numba gt 1}
<table border=0 cellpadding=0 cellspacing=0>
<FORM action="{$smarty.server.REQUEST_URI}" method=POST name=asl_form>
<tr>
<td>Current language:</td>
<td>
<INPUT type=hidden name="redirect" value="{$smarty.server.QUERY_STRING}">
<SELECT name=asl onChange="javascript: document.asl_form.submit()">
{section name=ai loop=$all_languages}
<OPTION value="{$all_languages[ai].code}"{if $current_language eq $all_languages[ai].code} selected{/if}>{$all_languages[ai].language}</OPTION>
{/section}
</SELECT>
</td></tr>
</FORM>
</table>
{else}
{/if}
</TD>
</TR>
<TR>
<TD colspan=2 class=VertMenuBorder>[img]{$ImagesDir}/spacer.gif[/img]</TD>
</TR>
{*<TR>
<TD colspan=2 class=NumberOfArticles align=right>{insert name="productsonline"} {$lng.lbl_products} {if $config.Appearance.show_in_stock eq "N"}{$lng.lbl_and} {insert name="itemsonline"} {$lng.lbl_items} {/if}{$lng.lbl_online}</TD>
</TR>*}
</TABLE>
I really don't know what to do to fix this at this point so any help you can offer will be much appreciated.
Thanks again,
Mike
|