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)
-   -   Need help customizing category listing (https://forum.x-cart.com/showthread.php?t=672)

TelaFirma 11-16-2002 09:51 AM

Need help customizing category listing
 
OK... I need some help from the pros here... I am trying to do a customization for the category listing and just cant figure it out.

What I would like is when you click on a category, that you have the subcategory listing below the catagory that was clicked. I know that you can nest sections, but I can't figure out the proper way to do it. The closest that I have gotten is:

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 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}

{section name=cat_num loop=$categories}
<font class=CategoriesList>{ $categories[cat_num].category|escape }</font>

{section name=cat_num loop=$subcategories}
<font class=CategoriesList>[*]{ $subcategories[cat_num].category|escape }</font>

{/section}
{/section}

{/if}
</td></tr>
</TABLE>


This is close but not right. It list the first category only once, then list the main categories again as su categories. Then when you click on a category, it DOES list the sub categories inder the category clicked, but it does not list the remaining categories.

If I change it to:
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 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}

{section name=cat_num loop=$categories}
<font class=CategoriesList>{ $categories[cat_num].category|escape }</font>

{/section}
{section name=cat_num loop=$subcategories}
<font class=CategoriesList>[*]{ $subcategories[cat_num].category|escape }</font>

{/section}

{/if}
</td></tr>
</TABLE>

it will function halfway right, but it lists the sub categories under all the rest of the categories.

Am I making any sense at all?

derrick92130 11-16-2002 10:51 PM

Cascading Category/SubCategory Listings
 
Unfortunately, I have planned on doing this for a customer, but have not worked through it yet. But, I'll take a stab at this one...

If you are at the top level of the category tree, the subcategories are the same as the top-level categories, and that is why the first piece of code shows the main categories where you are expecting to see subs. The reason they aren't repeated is likely because you are using the same counter (cat_num) for both section loops. When it finishes the second section loop, the counter is left at the end and is falling out of the both the nested and outer loop.

In the second piece of code your two loops are exclusive of one another, meaning that the first loop completes {/section} prior to starting the second loop. At the top level, I would expect it to run the whole category listing twice?

Sorry, this has been more diagnostic of your code and not helping yet.

The first code snippet looks the closest. You need to give each counter variable a different name and add a test to see if the category is the same as the category that was selected prior to listing the subcategories. Otherwise, you will not know where to cascade the subcategory listing. I can work up an example next week if you still are stuck.

Hope this helps!

jeffm 11-18-2002 03:08 PM

I am trying to get this same feature. I found a site that utilizes it on a different platform. oscommerce open source storefront. The store is carnutz.cc. I am not a programmer by any means, but would love to pickup this code.

Thanks

derrick92130 11-18-2002 03:56 PM

SOLUTION - Category Listing w/nested subcategories
 
Much easier than I thought. TelaFirma was _really_ close, just added a simple check for match of $cat. This was made to the 3.2.1 customer/categories.tpl file... I didn't build a third option for root_categories, I just used the "N" option.

Quote:

{* $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 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}
{section name=cat_num1 loop=$categories}
{ $categories[cat_num1].category|escape }

{if $categories[cat_num1].categoryid == $cat}
{section name=cat_num2 loop=$subcategories}
<a class=CategoriesList href="home.php?cat={ $subcategories[cat_num2].categoryid }">
{ $subcategories[cat_num2].category|escape }</a>

{/section}
{/if}
{/section}
{/if}
</td></tr>
</TABLE>

[/quote]

jeffm 11-18-2002 05:49 PM

I am using version 2.4. Was able to get this to work, somewhat. Few issues, not sure if you guys are experiencing with a newer version.

1) Empty categories (no products) are showing up.
2) Once I click on the subcategory, they go away only displaying the top categories. Needs to show the second level sub categories.

Please let me know if you are not having these problems. If not, I will look to upgrading.

Thanks

derrick92130 11-18-2002 06:52 PM

Hmmm
 
Jeff,
I just checked on this and you are right, once you click on the subcategory, the category list reverts back to the top level categories only instead of staying with the subcategory listing. Not a big surprise considering it reparses the category listings using the new "cat" that you just clicked on and it doesn't have any subcategories to the sub-category you just clicked on. Let me think about that and look at the code tomorrow.

What about multi-level sub-categories? The "hack" that I sent out will only work for one level of sub-category. Do you have multiple levels of sub-categories?

On the issue of empty categories being displayed, the existing system already did that. If you want to shut off a category that doesn't have any products, you can "disable" that category in the admin interface.

jeffm 11-19-2002 09:08 AM

I do have multi levels of categories, but I only want to display the main category and the first sub-category on the left bar.

My store will be setup offering different categories and different items under that. For ease of naviagtion, once a customer picks the initial category, which they will most likely remain within, they can then navigate within that category very easily.

I will utilize the disable function on empty categories.

Thank you!

TelaFirma 11-21-2002 05:30 AM

Yes, this is VERY close... I think that if we could just keep the single sub-cateogry list displayed, that would be enough to be useful...

derrick92130 11-21-2002 08:47 AM

Cascading Category Names
 
Sorry for the delay. Looks like I need to make a small change to categories.php. I'm booked solid today, but will get a change out tomorrow (Friday US time) to do this.

TelaFirma 11-21-2002 08:55 AM

No rush... no rush at all....

derrick92130 11-23-2002 04:33 PM

Finished! Indented Sub-categories.
 
OK. I have this working the "simple" way, with only one level of "indentation" in the category tree. The elegant way would have been to build a multi-dimensional array, but figured there was already enough overhead in categories.php, and there isn't really enough room to effectively build a 3+ level navigation model without losing valuable product space.

I had to change:

/xcart/include/categories.php
/xcart/skin1/customer/categories.tpl
/xcart/skin1/location.tpl
/xcart/skin1/customer/main/products.tpl

I made the changes for 3.2.1, but see that categories.php changed for 3.2.2. I'll post the 3.2.1 changes for now and post the 3.2.2 changes if anyone wants them.

See the next message for the specific file changes...

derrick92130 11-23-2002 05:02 PM

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!

TelaFirma 11-25-2002 05:47 PM

I would appreciate the 3.2.2 changes that you were talking about if it is not too much trouble. I already made the upgrade (a lot of which I had to do manually due to existing modifications).

MMB 11-25-2002 05:57 PM

Anyone have this working so I can see what it looks like?

derrick92130 11-25-2002 08:13 PM

Working on a site...
 
I just pulled that demo site down today. I'm working through a rebuild to a different version for an older customer. I'll put my demo site to 3.2.2 and add this code to it this weekend and send a pointer. Bad timing :-)

jeffm 12-11-2002 03:16 PM

Any word on the 3.2.2 update?

Thanks

upleta 01-10-2003 12:01 AM

same here!
 
any word on the latest version listing

derrick92130 01-18-2003 09:48 PM

Finally reworked for 3.3.1
 
I finally had a free moment to make the minor changes for 3.3.1. Please remember that this will only show the category and one level of sub-category. A completely different approach would need to be taken to cascade to more levels.

Here are the 3.3.1 changes required:

I preserved the "root categories" function from the General Settings, so you will need to turn it to "N" for the code below to work.

/xcart/include/categories.php

Code:

<?
#
# $Id: categories.php,v 1.43 2002/11/14 07:58:18 zorg 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
#

#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;
##BEGIN
# Add values to lastsub array if at first subcategory level
if($topcat == ""){
$lastsub[] = $all_category;
}
##END
                }

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

#
# 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("enable_subcategories_count",$enable_subcategories_count);
$smarty->assign("cat",$cat);
?>


/xcart/skin1/customer/categories.tpl

Code:

{* $Id: categories.tpl,v 1.16 2002/10/21 07:06:43 zorg Exp $ *}
<TABLE border=0 cellPadding=5 cellSpacing=0 width=100%>
<TR>
<TD class=VertMenuTitle height=26 width=26 valign=center>[img]{$ImagesDir}/dingbats_categorie.gif[/img]</TD>
<TD class=VertMenuTitle height=26 valign=center width="80%"><FONT class=VertMenuTitle>{$lng.lbl_categories}</FONT></TD>
</TR>
<tr><td colspan=2 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 *}
{* OLD CODE
{section name=cat_num loop=$subcategories}
<font class=CategoriesList>
{ $subcategories[cat_num].category|escape }</font>

*}
{/section}
{/if}
</td></tr>
</TABLE>


/xcart/skin1/customer/main/subcategories.tpl

Code:

{* $Id: subcategories.tpl,v 1.29 2002/11/26 14:55:13 alfiya Exp $ *}
{ include file="location.tpl" }
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}



{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}



{ include file="customer/main/navigation.tpl" }
{if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description|regex_replace:"/[\n]/":"
"}

{/if}
{capture name=dialog}
{assign var="tmp" value="0"}
{section name=cat_num loop=$subcategories}
{if $subcategories[cat_num].category}{assign var="tmp" value="1"}{/if}
{/section}
{section name=cat_num loop=$subcategories}
{ if %cat_num.first% }
{if $tmp} [img]../icon.php?categoryid={$cat}[/img] {/if}
<table border=0 cellspacing=5>
{/if}
{*if $subcategories[cat_num].product_count or $subcategories[cat_num].subcategory_count*}
<tr><td align=left nowrap width=95%>

{* BEGIN CHANGED LINE - ADDED topcat condition *}
<a href="home.php?cat={ $subcategories[cat_num].categoryid }&topcat={if $topcat == ""}{$cat}{else}{$topcat}{/if}">
<font class="ItemsList">{ $subcategories[cat_num].category|escape }</font></a>

</td>
<td align=right nowrap><font class=Text>
{if $subcategories[cat_num].product_count}
{ $subcategories[cat_num].product_count } {$lng.lbl_products}
{elseif $subcategories[cat_num].subcategory_count}
{ $subcategories[cat_num].subcategory_count } {$lng.lbl_categories|lower}
{/if}
</font></td>
</tr>
{*/if*}
{ if %cat_num.last% }
</table>
{/if}
{/section}
{if $tmp and $products ne "" }
<br clear=_all><hr size=1 noshade>
{/if}
{include file="customer/main/products.tpl" products=$products}
{if $products eq "" and $tmp eq "0"}
{$lng.txt_no_products_in_cat}
{/if}
{/capture}
{include file="dialog.tpl" title=$current_category.category|regex_replace:"/.*\//":"" content=$smarty.capture.dialog extra="width=100%"}
{if $products eq ""}
{if $f_products ne ""}



{include file="customer/main/featured.tpl"}
{/if}
{/if}
{ include file="customer/main/navigation.tpl" }


/xcart/skin1/customer/main/products.tpl

Code:

{* $Id: products.tpl,v 1.21 2002/11/19 12:57:48 alfiya 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 *}
{* OLD CODE
<a href=product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}>{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>
{$products[product].product|escape}</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/(1-(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=ProductPrice>{$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}{if $config.General.use_vat eq "Y"}, including VAT {$products[product].vat}%{/if}
{else}
<font class=ProductPrice>{$lng.lbl_enter_your_price}</font>
{/if}
{/if}
</td></tr>
</table>






{/section}


/xcart/skin1/location.tpl

Code:

{* $Id: location.tpl,v 1.7 2002/10/17 13:54:56 zorg Exp $ *}
{strip}
<a href="home.php">
<font class=NavigationPath>{$config.Company.company_name}</font>
</a>
{if $last_location ne ""}
::
{if $last_url ne ""}
<a href="{$last_url}">
{/if}
<font class=NavigationPath>{$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 *}
{* OLD CODE
<a href="{$location[position].1}">
*}
{/if}
<font class=NavigationPath>{$location[position].0|escape}</font>
{if $location[position].1 ne "" }</a>{/if}
{if %position.last% ne "true"}::
{/if}
{/section}
{/strip}




/xcart/customer/main/navigation.tpl

Code:

{* $Id: navigation.tpl,v 1.6 2002/10/22 10:27:05 olga Exp $ *}
{if $total_pages gt 2}
<table cellpadding=0 border=0>
<tr height=14>
{section name=page loop=$total_pages start=1}
{if %page.index% eq 1}
<td>{$lng.lbl_result_pages}: </td>
{if $navigation_page gt 1}
{* ADDED &topcat={$topcat} *}
<td valign=middle>[img]{$ImagesDir}/larrow.gif[/img]</td>
{/if}
{/if}
{if %page.index% eq $navigation_page}
<td align=center>
{%page.index%}
</td>
{else}
<td width=17 background="{$ImagesDir}/page.gif" align=center>
{* ADDED &topcat={$topcat} *}
{%page.index%}
</td>
{/if}
{if %page.last%}
{capture name=total_pages_minus}
{math equation="pages-1" pages=$total_pages}
{/capture}
{if $navigation_page lt $smarty.capture.total_pages_minus}
<td valign=middle>[img]{$ImagesDir}/rarrow.gif[/img]</td>
{/if}
{/if}
{/section}
</tr></table>



{/if}


I think that is it. If you just pull the changed lines you can use the same code changes for 3.2.1 and 3.2.2. Just be sure and only use the changed lines and get them inserted into the comparable positions.

Enjoy.

-Derrick

DrHTM 01-19-2003 08:04 AM

Do you think this would work with any other versions like 3.2?

derrick92130 01-19-2003 09:01 AM

I haven't looked, but seeing that 3.2.1 and 3.2.2 are just "dot" releases, meaning mostly bug fixes, etc. and the fact that it was pretty easy to see the changes made for 3.3.1, it should be very close.

I would begin by looking in categories.php for the comparison.

-Derrick

DrHTM 01-19-2003 09:04 AM

do you mind if we can see an example of what you made...I have no doubt of your abilities but i just want to know if this is really what i want on my site...thanks

derrick92130 01-19-2003 09:50 AM

Sure. I originally did this for a prospect under 3.2.1, but they went away. Since so many people seemed interested, I went ahead and setup a generic test 3.3.1 site and made only this change. I will be pulling this site down to build my next project, but will leave it up for a couple days max.

http://www.freerangeminds.com/shop/

Just the generic 3.3.1 demo products. Remember that this only displays the category and subcategory (1 level). Any deeper and it will only leave the subcategory displayed.

-Derrick

DrHTM 01-19-2003 11:49 AM

wow!!!! it looks so cool.. :lol: .i'm going to implement it on my 3.2 site...i'll let you know if it worked. :P

DrHTM 01-19-2003 08:20 PM

well i tried but i couldn't get it to work?!?

any ideas...i see that the 'topcat' is working (as you can see by the links) but the menu is not working as yours....any ideas...

derrick92130 01-19-2003 08:33 PM

Hmmm. Did you go into admin mode, General Settings and "uncheck" the show root categories?

DrHTM 01-19-2003 08:35 PM

hahahahahaha....no i didn't sorry...working hard at copying and pasting your hack i forgot to do the last thing...it works...thanks...now i have to change all the css to fit the site.

DrHTM 01-19-2003 08:44 PM

it looks tight...thanks a lot...is there anything i can share with you? I would feel better to trade hacks...even though there aren't much i hacked...but maybe i could help with something on your site?

well don't hesitate to ask me for help....is what i'm basically saying...

derrick92130 01-19-2003 08:47 PM

I'm glad it works for you. I think I am all set on the customer sites I have worked up. Thanks for the offer.

DrHTM 01-19-2003 09:05 PM

oh i just realized that you forgot to mention

/customer/main/navigation.tpl

You will notice the problem here(http://www.freerangeminds.com/shop/customer/home.php?cat=105&topcat=103) look at the results page. when you click on the next page you'll notice the menu collapses...

I edit it but since my site is completely reconfigured I'm afraid to add my codes here and get some beginner confused. Derrick, mind adding the original code and corresponding edits.

derrick92130 01-20-2003 09:30 PM

Good catch. I am so use to the cart being setup for longer listings, I completely forgot. I updated the original posting to include the navigation.tpl with the mods.

-Derrick

B00MER 01-20-2003 09:41 PM

I've been working on something similar to this, instead of using HTML I'm building XML that flash is parsing and building a category tree thats browsable without making the clients browser referesh on every click, so far I don't have a demo up, as the client I was doing it for, his hosting provider had an HD crash and lost all my work, so I'll be rewriting this, and hopefully will have a preview. This could be achieved also with some DHTML, it would really be a matter of spacing the menu out, as I've left the basic cat on the left and added my flash category's to the middle area above featured products. This is sorta similar to how macromedia.com's side nav bar works.

None, the less, this is a great HTML mod for the categories, kudos derrick! :wink:

InSite 02-02-2003 04:56 PM

I have added this to my x-cart test installation, and on the customer end it works perfectly... However, there is a problem in the admin panel when trying to add or modify categories. I get the following error message:

Warning: Cannot add header information - headers already sent by (output started at /estore/include/categories.php:160) in /estore/admin/process_category.php on line 56 (or 65)

If I restore the original /xcart/include/categories.php file, then this error goes away, but then the effect no longer works when I am inside a sub-category.

Any help please? :)

InSite 02-06-2003 12:31 AM

Ignore my previous post - I re-uploaded the categories.php file, and it works :oops:

Thanks for a great addition :)

jeffm 04-25-2003 06:52 PM

When installed and items are added to the cart, the sub-category listing closes. To continue shopping, one must re-select the main category to re-list the 1st layer of sub-categories. Any idea how to have the first layer remain open?

Thanks

travisc 05-31-2003 08:57 PM

works fine on 3.4.1
 
just install on 3.4.1 and it seems to work until you get to the product detail...

jeffm 08-17-2003 01:41 PM

Trying to get this category display in the "cart" area. Any ideas? I have had several complaints from customers on being able to continue shopping and this should help.

Added the continue shopping "back" feature, but the category drill down does not return?

Thanks

cjl108 08-18-2003 11:04 PM

I have been trying this code and derivatives of, yet I am unable to get the code to even recognize the $topcat variable.... is there a place where the smarty templates have to grab the variable via PHP before I can use it in the SMARTY templates? I see the variable being passed inthe url... but i can't use it...

any help would be greatly appreciated...

www.budogear.com/customer

only the last category (missing gif) has sub categories... once you click on that, the sub menus appear, but after you click on the submenu,(in the left column) they no longer appear...

enge919 09-19-2003 12:02 AM

Any idea if this will work in 3.4.8?

cbarning 09-24-2003 10:30 AM

X-Cart 3.4.7
 
I just tried this in X-Cart 3.4.7 and it makes the categories blank. Anybody have a clue? Can anybody make this work for this version number?

cbarning 09-24-2003 10:48 AM

Is there anybody else doing this that can also show more than one sub-category.


All times are GMT -8. The time now is 10:57 AM.

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