only display custom field value on the product listing

  • Posts: 29
  • Thank you received: 3
5 months 5 days 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: 1046
  • Thank you received: 100
  • Hikashop Business
5 months 5 days 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: 29
  • Thank you received: 3
3 weeks 4 days 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: 66836
  • Thank you received: 9872
  • MODERATOR
3 weeks 1 day 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: 29
  • Thank you received: 3
3 weeks 1 day 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: 3 weeks 1 day ago by p30yaran.

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

  • Posts: 23694
  • Thank you received: 3677
  • MODERATOR
3 weeks 20 hours 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.074 seconds
Powered by Kunena Forum