Jump to content

Check if category = subcategory


Recommended Posts

Dear,

 

I have bought a template for prestashop.

 

Now on each category page there is an image from 700 x 240 px.

 

In my template, there is now the following code to show the image:

 

{if $category->id_image}

<div class="align_center">

<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />

</div>

{/if}

 

This shows the category image.

 

What i want, is to hide the image if the category is an subcategory of a main category.

 

For example:

 

Home

Shoes

men

woman

 

On the page shoes the image has to show, but the subcategory men of woman, the image have to hide.

 

Do you guys know if there is a function like:

 

{if $category == subcategory}

// no image //

{else}

{if $category->id_image}

<div class="align_center">

<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />

</div

{/if}

{/if}

 

Hope that someone can help me!

Link to comment
Share on other sites

  • 4 years later...

Sorry to bump this old thread, but it's very near what I want to accomplish.

 

I want to check if I am on a category id 150, or on a subcategory of category id 150.

 

How can I do that?

 

EDIT: FOUND A SOLUTION!

Don't know if it qualifies as a great method, but it works anyway...

 

I did it like this:

{if $category->id AND $category->active}
                        {if ($category->id_category == 150) OR ($category->id_parent == 150) OR ($category->id_parent == 330) OR ($category->id_parent == 167) OR ($category->id_parent == 155)}
Edited by Gomlers (see edit history)
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...