Jump to content

Adding more than one level of subcategories to category.tpl


Recommended Posts

I'm trying to increase the number of levels of subcategories that are visible on some category pages in my Prestashop template to achieve a result somewhat like this IKEA page: http://www.ikea.com/us/en/catalog/allproducts/

Let's say that:
Category X is a subcategory of Home.
Category X has 5 subcategories: A, B, C, D and E
Categories A, B, C, D and E each have 5 subcategories.

I would like the following list to appear at the top of the Category X page (without images):

>
</pre>
<ul>
Category A

subcategory A1
subcategory A2
subcategory A3
subcategory A4
subcategory A5


Category B

subcategory B1
subcategory B2
subcategory B3
subcategory B4
subcategory B5


<!-- ETC... -->


Category.tpl allows for subcategories at the top of the page, but they are only one level deep. I'm editing the code to add subsequent category levels and have gotten this far:


       {foreach from=$subcategories item=subcategory}

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

               {foreach <!-- ???????? -->}
 <!-- ???? -->
               {/foreach}


       {/foreach}


So, my questions are:
- What code do I need to call the sub-subcategories into my ul ul li?
- What conditional code should I add to category.tpl to make sure that this list of sub and sub-subcategories only appears on the Category X page and not on the Category Y and Z pages.

Any help would be great! Thanks.

Link to comment
Share on other sites

Ok, I found the conditional code used to show subcategories only on the Category X page:
(from this post)

{if $category->id == 2}
subcategory code from my original post
{else}
leave blank
{/if} 


Where the category id of Category X is "2".

Now, can anyone tell me how to publish subcategories AND sub-subcategories of a category through category.tpl?

I suppose I could use the method described here to recreate another version of the Block Categories module, but I'd prefer to do it using only category.tpl. Is this possible? Anyone?

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