Custom field display on product listing page

  • Posts: 162
  • Thank you received: 0
10 years 9 months ago #168798

-- HikaShop version -- : 2.3.1
-- Joomla version -- : 2.5.24
-- PHP version -- : 5.4.29

Hi,

I want to display a custom field in the product listing page but it should not be visible on the product page.

Please see attached screenshot.

Could you please tell me how can I do that?

Attachments:

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

  • Posts: 12953
  • Thank you received: 1778
10 years 9 months ago #168804

Hello,
You'll probably find your answer through that thread : hikashop.com/forum/install-update/869869...product-listing.html

You'll just have to create a product custom field and un-publish it for the front-end, and then use the code :

<?php echo $this->row->CUSTOMFILED_NAME; ?>
Through the "listing_img_title" file of the "product" view of your front-end template.

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

  • Posts: 162
  • Thank you received: 0
10 years 9 months ago #168952

Hi,

thanks it's working great, but actually the "CUSTOMFILED_NAME" is "Column Name" :)

Could you please tell me if is there a possibility to display the field label also?

thanks!

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

  • Posts: 13201
  • Thank you received: 2322
10 years 9 months ago #168954

Hi,

To display the label, you can directly use the code:

<?php echo "your text"; ?>

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

  • Posts: 162
  • Thank you received: 0
10 years 9 months ago #169078

Hi,

that I knew. :)

I'm more interested if there is a way to pull and display the label from the database? I mean what I've type in the back-end in the label input box field, can be displayed in the front-end?

thanks!

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

  • Posts: 12953
  • Thank you received: 1778
10 years 9 months ago #169093

Hello,
Your custom field label will be "static" and won't change, so you can directly write it through an "echo" message, if not, can you give us more information about what you really want to do ?

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

  • Posts: 112
  • Thank you received: 3
10 years 1 month ago #201358

I need to add a custom field underneath the product name using the tabular layout. This custom field has been created as a product custom field.

My guess is I will need to insert this code into the layout show_tabular: <?php echo $this->row->productsubheading; ?>

where productsubheading is a custom field.

First, is this the correct code? Second, is this the correct view. Third, where does the code go? Can you provide a line number or adjacent code? I would like it to go directly under the product name on ignites.us/nouvelle2

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

  • Posts: 12953
  • Thank you received: 1778
10 years 1 month ago #201395

Hello,
Yes that's the correct file to edit via "Hikashop->Dispkay->Views", you'll just have to use that code :

<?php echo $this->element->productsubheading; ?>
Just after these lines :
    <span id="hikashop_product_name_main" class="hikashop_product_name_main">
      <?php
      if (hikashop_getCID('product_id')!=$this->element->product_id && isset ($this->element->main->product_name))
        echo $this->element->main->product_name;
      else
        echo $this->element->product_name;
      ?>
    </span>

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

  • Posts: 112
  • Thank you received: 3
10 years 1 month ago #201418

Mohamed,

Thanks for your speedy response. We are trying to finish this project today. I placed the code as described in the View product > view_tabular and nothing happened. This is a page in the URL that contains some test subheading text:

igsites.us/nouvelle2/index.php/products/...ulas/companion-joint

The text in that general section is:

<h1>
<span id="hikashop_product_name_main" class="hikashop_product_name_main">
<?php
if (hikashop_getCID('product_id')!=$this->element->product_id && isset ($this->element->main->product_name))
echo $this->element->main->product_name;
else
echo $this->element->product_name;
?>
<hr></hr>
</span>
<?php if ($this->config->get('show_code')) { ?>
<span id="hikashop_product_code_main" class="hikashop_product_code_main">
<?php
echo $this->element->product_code;
?>
</span>
<?php echo $this->element->productsubheading; ?>
<?php } ?>
</h1>

The variable name "productsubheading" is correct.

Last edit: 10 years 1 month ago by tbroderick.

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

  • Posts: 83995
  • Thank you received: 13605
  • MODERATOR
10 years 1 month ago #201422

Hi,

You didn't add the code in the correct place as Mohamed told you.
The way you added it, the value of the field will only display on the product if you turn on the "Display product code" setting of the HikaShop configuration.

The following user(s) said Thank You: tbroderick

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

  • Posts: 112
  • Thank you received: 3
10 years 1 month ago #201459

Nicolas,

I am getting new glasses. You are correct. My apologies.

Thank you.

Last edit: 10 years 1 month ago by tbroderick.

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

  • Posts: 59
  • Thank you received: 2
  • Hikashop Business
8 years 6 months ago #255718

Hi Nicolas
I am trying to get a custom field to display above or below the contact button on the product page. I am able to do this, but my custom field still shows on the second tab. How do I only display this custom field to the right of the product and not on the tab. I apologize if you have answered this before somewhere else, but this seemed similar to what I needed.

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

  • Posts: 83995
  • Thank you received: 13605
  • MODERATOR
8 years 6 months ago #255748

Hi,

If you're talking about tabs, I suppose that you've changed the "layout on product page" setting to "tabular" instead of "default" and that you're talking about custom fields of the table "product" which indeed display in a tab if you select the "tabular" display. Change that setting to "default" and you'll get the custom product fields on the right side of the product page.
If you want to further customize the display of your product page, you can edit the file "show_default" (or "show_tabular") via the menu Display>Views:
www.hikashop.com/support/documentation/1...-display.html#layout

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

  • Posts: 59
  • Thank you received: 2
  • Hikashop Business
8 years 6 months ago #255874

Hi Nicolas,
This issue is resolved if I add the text into the custom field on the product form and then afterwards unpublish the custom field. This results in the description appears in the description tab, the specs description appears in the second tab and the 3rd custom field appears to the right of the product as I wanted and not under the second tab. I understand that this is a workaround, but it is now working. :)

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

Time to create page: 0.097 seconds
Powered by Kunena Forum