X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   V4 - keeping first level subcategories viewable at all times (https://forum.x-cart.com/showthread.php?t=8755)

zilker 08-03-2004 11:41 AM

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.

shan 08-03-2004 02:52 PM

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

zilker 08-03-2004 03:36 PM

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 ](*,)

mizzlewillz 08-03-2004 06:08 PM

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

zilker 08-03-2004 06:36 PM

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.

shan 08-04-2004 07:51 AM

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

http://forum.x-cart.com/viewtopic.php?p=54761#54761

Elky67 10-30-2004 09:51 PM

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

fernando 10-31-2004 11:21 PM

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,

BerGer 02-14-2005 11:30 AM

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

mpj 02-14-2005 12:39 PM

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}


All times are GMT -8. The time now is 03:01 PM.

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