only display custom field value on the product listing

  • Posts: 31
  • Thank you received: 3
5 years 1 week ago #305763

-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.5
-- PHP version -- : 7.2
-- Browser(s) name and version -- : Firefox last version

hello,
how are you
I create a new custom field for example : name : Mobile Document & Column name : mobile_document
and set the only display to front end
how display value only the product listing
*** <?php echo $this->element->mobile_document; ?> ==== mobile_document is the column name of custom field.
code don't work in product listing , but work in the product detail
please help me to display custom field value on the product listing
thanks

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

  • Posts: 1119
  • Thank you received: 114
5 years 1 week ago #305766

Hi,

It's inside row. Your code should look like this:

<?php echo $this->row->mobile_document; ?>


Thanks

The following user(s) said Thank You: p30yaran

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

  • Posts: 31
  • Thank you received: 3
4 years 7 months ago #310170

hello,
I create custom field Type of Ajax file and set Front-end to : No
I use php code (<?php echo $this->row->document; ?>) to display file to product detail.
but display file name Without link
please help me to display custom field (ajax file) with php code
thanks

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

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
4 years 7 months ago #310201

Hi,

Yes, if you only use that code, it will display the raw data in that field in the database.
If you want the field system to do its magic on the raw data, you need to use such code instead:

<?php
$field = $this->fieldsClass->get(XXX);
echo $this->fieldsClass->show($field, $this->row->document);
?>
Where XXX is the id of the field : monosnap.com/file/MZgl5DbSJu0IxSlWX7vQybCk9D6NpT

The following user(s) said Thank You: p30yaran

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

  • Posts: 31
  • Thank you received: 3
4 years 7 months ago #310222

nicolas wrote: Hi,

Yes, if you only use that code, it will display the raw data in that field in the database.
If you want the field system to do its magic on the raw data, you need to use such code instead:
<?php
$field = $this->fieldsClass->get(XXX);
echo $this->fieldsClass->show($field, $this->row->document);
?>
Where XXX is the id of the field : monosnap.com/file/MZgl5DbSJu0IxSlWX7vQybCk9D6NpT


Thanks Nicolas
I change code but display error
please see the image (attached)
thanks

Attachments:
Last edit: 4 years 7 months ago by p30yaran.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
4 years 7 months ago #310226

Hello,

It looks like your custom field is using the namekey "mobile_document" and not "document" (as your previous message).
So you should use that variable name instead.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.080 seconds
Powered by Kunena Forum