Content module -> display category name

  • Posts: 57
  • Thank you received: 5
10 years 8 months ago #153294

Hi hika team,

I have created a content module with the purpose of displaying a list of products. The content module will be published in a module position of my choice.

The layout is set to list and now I have a nice single column list of products from the category of my choice.

What I would like to do is display the category name on top of the list.

I believe this line should solve my problem (pls correct me if I am wrong).

<?php echo $this->row->category_name ?>

I dug it out from a hika view file, however I do not know in which file to paste it in. Please give me a hint.

My Hikashop version is 2.1.3.

Kind regards,

Drago.

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

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
10 years 8 months ago #153321

Hi,

That code is wrong. It will only work inside categories listings.
In products listings, it's that code that you want to use:
<?php echo $this->element->category_name; ?>
You can add it at the beginning of the file "listing" of the view "product" via the menu Display>Views and it will display for all your products listings.

The following user(s) said Thank You: Hristov

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

  • Posts: 57
  • Thank you received: 5
10 years 8 months ago #153452

Thanks,

It worked like a charm.

If anybody else stumbles over this thread, I'd like to clarify that if you want to display your category on top of your list the file you need to edit is called "listing_list" of the view "product" and it is accessible through the views in the hikashop backend.

I added Nicolas' code under line 43 (after the ul tag) and created my own <li> item with my own class. Below is the code snippet with the modification for reference.

<ul class="hikashop_product_list<?php echo $this->params->get('ul_class_name'); ?>">
      <li class="product_list_category_name"><?php echo $this->element->category_name; ?></li>

Please note that this is for hikashop version 2.1.3 and the code line I gave above might be wrong in later versions of hikashop.

Kind regards,

Drago.

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

  • Posts: 83041
  • Thank you received: 13405
  • MODERATOR
10 years 8 months ago #153563

We're at version 2.3.0 so far and the same modification will work for that version too, as long as you select the "type of layout" "list" in your category listing (as it's the case by default with the categories listing modules that are pre created by HikaShop during the installation).

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

Time to create page: 0.055 seconds
Powered by Kunena Forum