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

V4 - keeping first level subcategories viewable at all times

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #31  
Old 09-25-2005, 08:57 AM
 
Impact_1 Impact_1 is offline
 

Advanced Member
  
Join Date: Jan 2005
Posts: 88
 

Default

As above, I would really like a menu like that.
__________________
Version: 4.1.3

One of the largest UK Suppliers of Car Modification Accessories
http://www.impact-styling.com
Reply With Quote
  #32  
Old 09-25-2005, 10:38 AM
 
Mr Bob Mr Bob is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 199
 

Default

Code:
{* $Id: left_subcategories.tpl,v 1.00.0.0 2005/11/24 04:10:00 mclap Exp $ *} <div id="siteBodyLeftSubCats"> <div id="siteBodyLeftSubCatsTitle"> <div id="siteBodyLeftSubCatsTitleLeft"></div> {$current_category_top.category} <div id="siteBodyLeftSubCatsTitleRight"></div> </div> <ul class="subNav"> {section name=cat_num loop=$allcategories} {if $allcategories[cat_num].parentid eq $location[1].1|replace:"home.php?cat=":""} <li class="subNavLink">{ $allcategories[cat_num].category|escape } {if $config.Appearance.count_products eq "Y"}{if $subcat.product_count}({ $subcat.product_count }){/if}{/if} {/if} {/section} [/list] <div id="siteBodyLeftSubCatsLL"></div> <div id="siteBodyLeftSubCatsLR"></div> </div>

First, my code above displays all the time, everytime. I need an if statement that will only display after you have clicked on a category. Once you click on a category, the code above should display.

Next, I need to name the subcategory that they selected. I tried {$current_category_top.category} which didn't work. Then I tried {$current_category.category} which just displays the name of the item you are on. If I click on a sub cat, it will display the sub cat name, then if I click on a product, it will display the product name. I only want it to display the sub cat name for the 2nd level sub cat.
__________________
Product: X-Cart Gold
Current version: 4.0.14

Additional Mods: X-Affiliate
Reply With Quote
  #33  
Old 09-25-2005, 02:42 PM
 
fernando fernando is offline
 

Member
  
Join Date: Oct 2004
Posts: 29
 

Default

I solved that by using a cookie. When I'm browsing a category, I'll create a cookie (e.g. X_CURRENT_CATEGORY). Then, when I'm in a product, I just retrieve the value of the cookie.

BTW: this is very useful if you want to add a Keep Shopping button on cart.php. You click it, and return to the last category you were on. If you want to refine it even more, you could even add an X_CURRENT_CATEGORY_PAGE cookie

Regards
__________________
Fernando
Sorry, I\'m not using x-cart anymore, so I am unable to reply to enquiries about modules. Thank you.
Reply With Quote
  #34  
Old 09-25-2005, 02:52 PM
 
Mr Bob Mr Bob is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 199
 

Default

I'd rather not use a cookie. You should be able to do this easily using some logic statements, but I just don't know what the variables are in xcart.
__________________
Product: X-Cart Gold
Current version: 4.0.14

Additional Mods: X-Affiliate
Reply With Quote
  #35  
Old 09-30-2005, 01:58 PM
 
Mr Bob Mr Bob is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 199
 

Default

Anyone?
__________________
Product: X-Cart Gold
Current version: 4.0.14

Additional Mods: X-Affiliate
Reply With Quote
  #36  
Old 10-02-2005, 10:25 PM
 
Mr Bob Mr Bob is offline
 

Senior Member
  
Join Date: Jul 2005
Posts: 199
 

Default

This seems to work just fine

Code:
{if $main ne "catalog" and $current_category.category eq ""} {else} {include file="customer/main/left_subcategories.tpl"} {/if}

The only problem is that I want the title of the subcategories (in the code in my last post) to show the sub cat title, not the product title.
__________________
Product: X-Cart Gold
Current version: 4.0.14

Additional Mods: X-Affiliate
Reply With Quote
  #37  
Old 03-09-2006, 12:51 PM
  Hyperdelicious's Avatar 
Hyperdelicious Hyperdelicious is offline
 

Senior Member
  
Join Date: Sep 2002
Location: In the Middle of Nowhere
Posts: 138
 

Default subcategory mod not working w/ x-cart 4.1.0

Had this working with x-cart 4.0.13 however does not seem to work when upgrading to x-cart 4.1.0 ... any ideas?
Reply With Quote
  #38  
Old 05-18-2006, 05:56 PM
 
bycv bycv is offline
 

Member
  
Join Date: Apr 2006
Posts: 15
 

Default

Hello Fernando,

I have used your code
Code:
{if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <FONT class="CategoriesList">{$categories[cat_num].category}</FONT> {* Added by Fernando. Show first level of subcategories *} {if $current_category ne "" } {section name=subcat loop=$allcategories} {assign var=topmostcat value=$allcategories[subcat].categoryid_path|regex_replace:"/\/.*/":""} {assign var=current_category_top value=$current_category.categoryid_path|regex_replace:"/\/.*/":""} {if $current_category_top eq $topmostcat and $categories[cat_num].categoryid eq $topmostcat and $allcategories[subcat].parentid eq $topmostcat and $allcategories[subcat].categoryid ne $current_category_top} {$allcategories[subcat].category|truncate:20:"...":true} {/if} {/section} {/if} {* End added by Fernando *} {/section}
Thank you so much. It really helped me a lot.

Is there any way to use the same thing a second time with the first or top subcategory intead of the top category? or to say second from the top of the category tree?

Thank you in advance.
__________________
X-Cart Gold Version 4.0.18
Add-on: X-RMA
Add-on: X-AOM
Reply With Quote
  #39  
Old 08-09-2006, 11:29 PM
 
Sarnix Sarnix is offline
 

Member
  
Join Date: Jul 2006
Posts: 10
 

Default

As Hyperdelicious said, it doesnt seem to be working in x-cart 4.1.
I believe there are only 2 arrays present in the template that contain categories.
* $categories, which contains the toplevel categories.
* $subcategories, which contains the subcategories of the current category.
Is this correct?
And if it is I assume the only thing get the subcats of the parent category is to perform an extra query and assign the results to smarty?

I think the nicest thing to use would be that the category structure is available as a tree
__________________
X-Cart Gold 4.1.2 + X-Affiliate on LAMP server
Reply With Quote
  #40  
Old 08-17-2006, 08:07 AM
 
Hollistergj Hollistergj is offline
 

Newbie
  
Join Date: Jan 2006
Posts: 4
 

Default

Has anyone been able to figure out how to do this in 4.1?
__________________
Holli
x-cart gold: 4.2
php: 5.2.6
mysql: 5.0.67-community
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:00 AM.

   

 
X-Cart forums © 2001-2020