Jump to content

Multiple Category Trees?


Recommended Posts

Hi all,
I'm wondering if it is possible to have multiple category trees? I ask because I would like to show a different category menu on specific product pages. For example, if I have two main categories: Apparel and Beauty. On the apparel pages, I'd like to show all the categories and sub-cats like:

Tops
Tank Tops
Cardigans

Botoms
Jeans
Leggings

Dresses
Casual
Formal

But then on the "Beauty" products page, I would like to show a new menu with categories/sub-cats specific to beauty products WITHOUT showing the apparel stuff too:

Hair
Shampoo
Styling Products

Skin
Cream
Face wash

A good example can be seen on the bebe.com site:
Apparel: http://www.bebe.com/APPAREL-Products/b/15382841
Shoes: http://www.bebe.com/SHOES-Products/b/675993011

They have two completely different menus for each "main" product page. Is there a way to do this with PrestaShop?? I noticed that our categories and sub-cats are under a main category called "home". Can we create more main categories? If so, where? And, once we create a new main category, how do we get our pages to display that specific menu?

Any help would be appreciated.

Link to comment
Share on other sites

I haven't really looked into it, but the solution i'd try first would be to have two blocks on the left column. One that shows the beauty category + sub categories and another that shows the Apparel + sub categories. And then have an if statement in the product template that says - if product beauty, then show beauty block, else show apparel block.

Or something along those lines.

Link to comment
Share on other sites

Hi Iamcaptain,
thank you for responding :)

Do you mean create my own custom blocks where I just input the categories manually using plain HTML??? And then use if/else statements to show the corresponding one for the page? Just want to be sure I am clear because as far as I know, there is no way to have the cart create the "main" categories for me (or if there is, no one seems to be sharing that info).

I don't know PHP at all but I will give it a try!!! At least I can start somewhere now so thank you!! :)

Link to comment
Share on other sites

I am looking for this also.

Is there a possibility to split up the menu three?

For example. My shop looks like this

T-shirts
Shoes
Jackets
Etc

I need to devide the menu in different parts so i can put them in different divs. One at the top left: for example T-shirts, one at the top right, for example Shoes, and one at the bottom, for example Jackets

Is is possible to split up the menu? How?

Link to comment
Share on other sites

This is possible:

I created a module called blocksubcategories(attached zip-file).

It loads the subcategories of the parent items (only if the parent is not Home or on pages where we don't want this), so you can use the $subcategories variable in your template to make a second menu with the subitems.

Delete the subcategory part in category.tpl:

    {if isset($subcategories)}
   <!-- Subcategories -->

{l s='Subcategories'}

       {foreach from=$subcategories item=subcategory}

getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
                   {else}

                   {/if}



getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}

       {/foreach}




   {/if}



Now configure the blockcategories module to only show the parent categories. Then import subcategory.tpl where you want the menu to show up.

I attached a screenshot where you can see it working.

Now i'm going to look for a way to make the parent category menu item also active.

Upload modsubcategories.zip to the modules folder, hook it to the left and be sure it's loaded after blockcategories (module positions). Then change the template files to get the submenus where you want them (import subcategory.tpl). -> use the code you got from category.tpl instead of the subcategory.tpl attached if you want to use images in your submenu

12970_aGWa9dYyrNIXN9GITR8e_t

subcategory.tpl.zip

blocksubcategories_updated.zip

Link to comment
Share on other sites

Hi hermit,
thanks so much for sharing! From your screenshot I can see that this is pretty much what I have been trying to do!!

I'm a little confused tho.... you said to upload modsubcategories.zip, however, I don't see that zip file in your post? Can you clarify which zip I should be uploading??

Also, how do we configure the blockcategories module to only show the parent categories (as you instructed)? Do we delete the {if $node.children|@count > 0} part in category-tree-branch.tpl??

And one more thing, how do we import subcategory.tpl into our template? Is there a special format we should use to call this file?

Sorry, I'm a newbie still trying to figure this all out :)
Thank you!!!

Link to comment
Share on other sites

Hi Bianca,

I'll try to make a kind of manual:

First, unzip blocksubcategories_updated.zip (I renamed it after updating the code) into the /modules folder (it's in the root of your prestashop map).

After that, it will show up in the modules tab of the back-end.

Look for Subcategories (in Blocks) and click on install. (installSubcategories.png) Now click on positions, it's right under the tab menu (on the modules page). (positions.png)

Choose Transplant a module

Module: Subcategories
Hook into: Left columb blocks

(hook_to_left.png)

Click Save. The module is now loaded.

Scroll down and be sure the subcategories module is loaded after the Categories block, you can change the order with the small black pointers.

---

Now open category.tpl (it's in your template folder) and remove the following code, or cut it if you want images in your submenu.


{if isset($subcategories)}
   <!-- Subcategories -->

{l s='Subcategories'}

       {foreach from=$subcategories item=subcategory}

getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium')}" alt="" />
                   {else}

                   {/if}



getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}">{$subcategory.name|escape:'htmlall':'UTF-8'}

       {/foreach}




   {/if} 



The last step is to choose where you want the submenu to show up, and import subcategory.tpl there

(paste the code you've cut from category.tpl in subcategory.tpl if you want images in there).

{include file=$tpl_dir./subcategory.tpl}



Now the submenu will show up in your template.

You could hide the subcategories in the categories menu with CSS (replace menu with the correct name of the div, can't remember it, probably categories):

DIV#menu UL.tree LI UL LI
{
   display: none;
}



Or click on >> Configure after 'Categories block v1.0' on the modules page. Set Maximum depth to 1. As you probably don't need dynamic mode for sublevels anymore you can switch that off too. Click on Save.
You're done! Hope it helped you,

Herman

13113_iE7NCoj3waFA1O0eMmap_t

13115_hkwWoKPfpHAF0WGqQj1m_t

13116_VO5XddUsnSmY2QVafKqy_t

Link to comment
Share on other sites

Thank you for the full instructions (much easier to understand) :)

But I still can't get it to work. If I place the {include file=$tpl_dir./subcategory.tpl} code into category.tpl, the sub-category links show up below the breadcrumbs. The problem is, I want to put the sub-category on the left of my page but it seems that no matter which file I include the template in, it does not show up at all. I tried adding it to header.tpl and blockcategories.tpl and got absolutely nothing. I even tried adding the code from subcategory.tpl directly into my template file and still nothing.

Am I doing something wrong??

Link to comment
Share on other sites

In your template it must also be loaded after the categories, so that's why it won't work in header.tpl. If you want to put it on the left of your site you need to do some modifications in your template files, like ending header.tpl with this code

(so remove everything from <!-- Header --> down and replace it with this:)

            <!-- Header -->

                   {$HOOK_TOP}
<!-- /header -->

               {$HOOK_LEFT_COLUMN}

   {/if}



Then enter this on top of breadcrumbs.tpl:

{include file=$tpl_dir./subcategory.tpl}



           <!-- Center -->




You might need to create some extra containers to get full css-control.

Link to comment
Share on other sites

Hey, guys.
Is it possible to get parent category of custom product?
For example, I have "new products" module and I need to filter/sort product list by parent categories(iPods, Laptops). I know it's something like separate module, but the simpliest way is to have parent category id and to hide this product if necessary by JS.
Well, thanks for any help.

Link to comment
Share on other sites

hermit, thank you again for sharing this awesome mod!!! It worked wonderfully for me. I had to configure it a little differently because I have A LOT of HTLM in my header and couldn't move everything out of there so instead, I moved the left column div to the breadcrumbs.tpl file and included the subcategory.tpl above it... it worked perfectly!!! I'm soooo very grateful to you, thank you again!!

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 months later...

I would also like to show only menu's for specific departments, but have had trouble getting the modules/instructions in this post to work for me - which is purely down to my inexperience. While I figure it out, I'd like to do the groundwork of creating my departments and adding products to these departments.

If I end up installing another 'catagory' module, does that mean I will have two 'catagory' modules show up in my 'catalog' tab in the Back Office? And would I have to create departments and add products to the specific catagory modules, ie, if I have 'woman's clothes' and 'men's clothes', would I have to assign one module to woman, and one to men, then add catagories and products to them, or can I just add deparments/products as normal and assign them somehow later?

Sorry for the long question, but as I never manged to get this to work (yet), I'm not sure how the Back Office will look.

Advice would be warmly appreciated:-)

Link to comment
Share on other sites

  • 3 months later...

Hai...This is kalyan...I am fresher to prestashop...I saw the topic about Multiple Category Trees....I use the subcategory.tpl.zip and blocksubcategories_updated.zip as you said...but It only recover the second level Category Trees but it doesn't create subCategory Trees of second level Category Tree...Please see the below attachment....

25492_YoVgeDV8uvTmgG3oJzqK_t

Link to comment
Share on other sites

  • 6 months later...
  • 7 months later...
  • 2 weeks later...

I'm sorry for this late reply, I hadn't noticed there were questions about it.

 

Don't expect it to work in PS > 1.2! And don't wait for me to fix it.

 

I stopped using PS because I needed a more flexible shopping solution where these kind of hacks are not needed. So find someone else to fix it, or mail the PS-developers telling them this should be possible without hacks.

 

Good luck with it!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...