Custom field as visible item in product listing

  • Posts: 9
  • Thank you received: 0
10 years 6 months ago #177802

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.6

Hi,

I have a problem with getting the custom fields active in my product listing.
First what I want:
I want my customer to find an overview of courses (yes, I use hikashop as a course managing system, which works quite fine), where the can flter on custom fields as date and amount of participants. Only, in the overview, these custom fields don't show.

What I have done to get theses custom fields active:
I edited via views>content-menus the display of my menu item: Type of content = product, Type of layout=DIV
Parameters for DIV>type of item layout: image and description
in the parameters for products I set the display custom item fields on yes.
I created custom fields in views>custom fields for product. And set everything on active (Front-end, Back-end Form and listing and published).
In the single product view, these custom fields show perfect, no problems here. I can filter on these items too in the product listing. But for my customer, these custom fields are not visible until they enter the product only view. Which is quite annoying when you expect your customer to select on date.

So: how to solve this and mae sure that the custom fields are shown under the description in this particular view?

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

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 6 months ago #177832

Hi,

There is no option to display custom product products on listings.
You need to edit the file "listing_img_desc" of the view "product" for your frontend template via the menu Display>Views and add such line of code to display the value of the custom product field for each product:
<?php echo $this->row->XXX; ?>

where XXX is to be replaced with the column name of the custom product field.

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

  • Posts: 9
  • Thank you received: 0
10 years 6 months ago #177935

Hi,

Thank you for your help. But still, it is not my full wishlist B)

I like these custum fields the be generated automatically. For example, I have an custom field named 'teacher'. This is not a necessary field for all my products. Therefore I like that field not to be shown in my preview as a fixed row. But if it's not empty, it would be great to have it there.
When I have the product detail page, these custum fields are generated automatically (if empty, no fieldname). How can I generate this in my product listing?

Another thing: the date row is not reading a date but just the numbers (20141104000000) How can i fix that?

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

  • Posts: 83832
  • Thank you received: 13572
  • MODERATOR
10 years 6 months ago #177962

Hi,

The code I gave won't display anything if the custom field is empty.
If you add HTML around, then you want something like this:
<?php if(!empty( $this->row->XXX )) echo '<span>'.$this->row->XXX.'</span>'; ?>

For the date, you can do like that:
<?php if(!empty( $this->row->XXX )) echo '<span>'.hikashop_getDate($this->row->XXX,'%d %B %Y %H:%M').'</span>'; ?>

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

Time to create page: 0.070 seconds
Powered by Kunena Forum