Jump to content

Determine if a category is a subcategory in the category block


Recommended Posts

Hi,

 

I am using the default theme and category list block.

 

Currently, it lists all categories and subcategories on the homepage in a bullet list. I would like to only list the main categories on the home page. Then, if the user is on the category page or the corresponding product page, I would like the subcategories for just that main one to also be displayed, preferably wrapped in a div so they can be styled accordingly.

 

I know that I can change the display depth on a menu, but how would I dynamically alter this page by page?

 

Many thanks.

Edited by samiles (see edit history)
Link to comment
Share on other sites

Well, you could target the parent IDS. i can't exactly remember if id_parent is being assigned there, but it should.

 

you can use this kind of ttrick

{if $page_name == 'index'}
{if $category.id_parent != 2}
here the code to show the tree
inside it, when it's time to load the subcategories, use this
{if $category,id_category == $smarty.get.id_category|intval)
show tree
{/if}
{/if}
{/if}

 

Indeed you need to replace those variables with real names

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