Detect parent category

  • Posts: 162
  • Thank you received: 0
6 years 11 months ago #292695

Hi,

How can I detect if a category is a parent category on the com_hikashop/views/category/tmpl/listing.php ?

thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 83778
  • Thank you received: 13566
  • MODERATOR
6 years 11 months ago #292697

Hi,

I'm not sure what you want exactly so hard to say.
On a category listing, there are:
- the main category of the listing
- the categories (which are sub categories of that main category)
- the products of the main category

Do you want :
- to know if the main category has sub categories ?
- to know if each sub category has itself sub categories ?
- something else ?

Please Log in or Create an account to join the conversation.

  • Posts: 162
  • Thank you received: 0
6 years 11 months ago #292766

Hi,

yes, I want to know if the main category has subcategories.

I want to write a condition when a category has subcategories.

thanks!

Last edit: 6 years 11 months ago by info@vesica.org.

Please Log in or Create an account to join the conversation.

  • Posts: 83778
  • Thank you received: 13566
  • MODERATOR
6 years 11 months ago #292772

Hi,

Then you can do like that:

if(empty($this->rows)) {
 // no sub categories
} else {
 // has sub categories
}

The following user(s) said Thank You: info@vesica.org

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum