Category custom field value

  • Posts: 5
  • Thank you received: 0
4 years 10 months ago #318897

Hi,

I'm new to hikashop, but i see a huge potential of what can be done using it. I decided to use it for our company B2B platform.

This is a simple issue, but one that has been bothering me and i've spent too much time trying to figure it out...

I've created a custom field for categories (one only) that will store color number for different display options in the front end. The color code is to be added to a div class in :
listing_img_pane.php.

This is what I have:

<div class='cat_color_label cat_color<?php
if(!empty($this->fields)){
$fieldsClass = hikashop_get('class.field');
$fields = $fieldsClass->getFields('frontcomp', $this->row, 'category');

foreach($this->fields as $fieldName => $oneExtraField) {

echo $oneExtraField->field_namekey; //prints fine added just for testing

echo $this->fieldsClass->show($oneExtraField,$this->element->$fieldName); // i get nothing!
}

}?>
'>

Hot to retrieve custom field value from either category or product....

Hope you can help...
Regards
Joe

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

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 10 months ago #318900

Hi,

First, there are two listing_img_pane.php one for the categories listing (so it's called once for each category of the listing) and one for the products listing (so it's called once for each product of the listing, and thus you only have one category):
monosnap.com/file/CSwYHXHWkwIGgANE6rG0yrAX1nvFdB
In a categories listing, you'll find the value of your custom category field directly in $this->row->XXX where XXX is the column name of the custom category field.
In a products listing, you'll find the value of your custom category field directly in $this->element->XXX where XXX is the column name of the custom category field.

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

  • Posts: 5
  • Thank you received: 0
4 years 10 months ago #319013

Thank you Nicolas!

You saved me creating 20-30 odd css styles with category ID's ::pinch:: or messing your code with direct sql for small aestetic effect.....

Much obliged!

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

Time to create page: 0.055 seconds
Powered by Kunena Forum