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 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 08-03-2004, 11:41 AM
 
zilker zilker is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 89
 

Default V4 - keeping first level subcategories viewable at all times

Hey all,

I'm working with the newest version of x-cart and let me start off by saying that there are a lot of improvements ~ thx x-cart team!!

Now for my delimia. I've made a couple of simple mods to the cart.

http://www.designertrends.com/temp/amish/home.php

The first is simply showing the categories in a horizontal line across the header. Here is the code:

Code:
{* $Id: categories_test.tpl,v 1.23 2004/06/24 09:53:29 max Exp $ *} {capture name=menu} {section name=cat_num loop=$categories} <FONT class="CategoriesList">{$categories[cat_num].category}</FONT> {if !%cat_num.last%} <FONT class="CategoriesList">|</FONT> {/if} {/section} {/capture} { include file="menu_cat.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu }

The second shows available subcategories (if applicable) where the categories menu would normally go. I inserted a simple if statement in customer/home.tpl which takes the place of the categories include statment. Here is the code for that:

Code:
{if $subcategories ne "" and $current_category.category ne "" and $config.General.root_categories ne "Y"} { include file="customer/subcategories.tpl" } {/if}

You'll notice that I have added a file named subcategories.tpl within the customer directory (not to be confused with customer/main/subcategories.tpl). Here is the code for that file:

Code:
{* $Id: subcategories.tpl,v 1.23 2004/06/24 09:53:29 max Exp $ *} {capture name=menu} {section name=cat_num loop=$subcategories} <FONT class="CategoriesList">{$subcategories[cat_num].category}</FONT> {/section} {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_subcategories menu_content=$smarty.capture.menu }

If you follow the url I provided, it will take you to the home page. If you click on one of the categories that has a subcategory (books, videos or dolls) you'll notice the subcategories are shown on the left. That all works great and I'm pleased with it BUT when you click on a subcategory such as videos/cd audio, all of the subcategories (cd audio, dvd, video cassettes) under the root category (videos) disappear.

I would like to keep the first level subcategories visable no matter which subcategory you are in.

Any ideas or suggestions would be greatly appreciated.
__________________
~zilker

uummm...perhaps you should tell me again.

http://www.designertrends.com
Version 4.0.6
Unix
Reply With Quote
  #2  
Old 08-03-2004, 02:52 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Here you go,

I did just this the other day, its a bit crafty how it works but it does the job. It only works for a single level of subcategories though

Code:
| {section name=cat_num loop=$allcategories} {if $allcategories[cat_num].parentid eq $location[1].1|replace:"home.php?cat=":""} <font class=CategoriesList> { $allcategories[cat_num].category|escape } </font>| {/if} {/section}

This is for V4
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 08-03-2004, 03:36 PM
 
zilker zilker is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 89
 

Default

B-E-A-Utiful - thx so much shan.

By the way, if anyone else wants to use this mod in the future, I had to change the if statement in customer/home.tpl to this:

Code:
{if $current_category.category ne "" and $config.General.root_categories ne "Y"} { include file="customer/subcategories.tpl" } {/if}

Now back to fine tuning skin.css
__________________
~zilker

uummm...perhaps you should tell me again.

http://www.designertrends.com
Version 4.0.6
Unix
Reply With Quote
  #4  
Old 08-03-2004, 06:08 PM
 
mizzlewillz mizzlewillz is offline
 

Advanced Member
  
Join Date: Apr 2004
Posts: 45
 

Default

Thanks ALOT... That is very helpful. One additional question: Is there a way to make it so the subcategories appear in columns horizontally? Im trying to figure this out but I might be at a dead end..


THANKS AGAIN!

-mike
Reply With Quote
  #5  
Old 08-03-2004, 06:36 PM
 
zilker zilker is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 89
 

Default

you should be able to use the code that shan provided. I removed the | in his code and replaced it with a
b/c it was lining them up horz.

Good luck and let me know if you need more help.
__________________
~zilker

uummm...perhaps you should tell me again.

http://www.designertrends.com
Version 4.0.6
Unix
Reply With Quote
  #6  
Old 08-04-2004, 07:51 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

heres a similar thread for doing this in versions prior to V4

http://forum.x-cart.com/viewtopic.php?p=54761#54761
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #7  
Old 10-30-2004, 09:51 PM
 
Elky67 Elky67 is offline
 

Newbie
  
Join Date: Oct 2004
Posts: 3
 

Default

I have everything working except the:

{if $subcategories ne "" and $current_category.category ne "" and $config.General.root_categories ne "Y"}
{ include file="customer/subcategories.tpl" }


{/if}

code that should display the subcategories of the left hand side once a root categorie is "clicked".
I place this code where the categories include statment was in the customer/home.tbl file.
If I comment out the {if} statement the subcategorie menu loads fine and will display the correct subcategorie for the root categorie that is clicked.

Why would the if statement not work. Did I put it in the wrong place?
I'm running version 4.0.6.
Thanks for your help..
Reply With Quote
  #8  
Old 10-31-2004, 11:21 PM
 
fernando fernando is offline
 

Member
  
Join Date: Oct 2004
Posts: 29
 

Default

You may want to check this mod out. It works with categories of any depth, although it will only list the first level of sub-categories for the current category.

Open customer/categories.tpl

replace:

Code:
{if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <FONT class="CategoriesList">{$categories[cat_num].category}</FONT> {/section}

With...

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}

Cheers,
__________________
Fernando
Sorry, I\'m not using x-cart anymore, so I am unable to reply to enquiries about modules. Thank you.
Reply With Quote
  #9  
Old 02-14-2005, 11:30 AM
 
BerGer
    
Posts: n/a
 

Default

hey, nice tool, good coding!!!

i'm using version 4.0.11.

i've done many mods and hacks with this great shopsystem. But one problem i couldn't solve.

On the right side there is a navigation panel with the following structure:

MAINPAGE:
MAINCATEGORIES
-entry1
-entry2
-entry3
-entryn


Detailpage of one MAINCATEGORY:
MAINCATEGORIES
-entry1
-entry2
-entry3
-entryn

SUBCATEGORIES to the selected maincat
-sub_entry_child1_1
-sub_entry_child1_2
-sub_entry_child1_3
-sub_entry_child1_n

Never the less there are only maincategories with one "child".

If i've choosen one sub_entry, the following box shuld be shown
SUBCATEGORIES
-sub_entry_child1_1
-sub_entry_child1_2
-sub_entry_child1_3
-sub_entry_child1_n

That means if i've selected a product or one sub_category a box with all subcategories should be shown.


How can i realize this ????
i've there's somebody with icq, my uin is 123126029, please help me!!!
Reply With Quote
  #10  
Old 02-14-2005, 12:39 PM
 
mpj mpj is offline
 

Senior Member
  
Join Date: Feb 2005
Posts: 106
 

Default

Quote:
Originally Posted by BerGer
hey, nice tool, good coding!!!

i'm using version 4.0.11.

i've done many mods and hacks with this great shopsystem. But one problem i couldn't solve.

On the right side there is a navigation panel with the following structure:

MAINPAGE:
MAINCATEGORIES
-entry1
-entry2
-entry3
-entryn


Detailpage of one MAINCATEGORY:
MAINCATEGORIES
-entry1
-entry2
-entry3
-entryn

SUBCATEGORIES to the selected maincat
-sub_entry_child1_1
-sub_entry_child1_2
-sub_entry_child1_3
-sub_entry_child1_n

Never the less there are only maincategories with one "child".

If i've choosen one sub_entry, the following box shuld be shown
SUBCATEGORIES
-sub_entry_child1_1
-sub_entry_child1_2
-sub_entry_child1_3
-sub_entry_child1_n

That means if i've selected a product or one sub_category a box with all subcategories should be shown.


How can i realize this ????
i've there's somebody with icq, my uin is 123126029, please help me!!!

i've been after the problem for a few weeks now.

saw a mod this morning that might be it, but i'm still working on it.

i'll try to keep everyone updated.

it's the never ending {parentid} vs. {categoryid}
__________________
X-Cart 4.0.11


{My simple mods}
Adding Market list and % save on product detail
Quantity input box
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


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 03:54 AM.

   

 
X-Cart forums © 2001-2020