[Skip to main content](#vessel-content)

#   Show custom field in product page if it meets the conditions

##

- **[oxido](/forum/user/29793-oxido "View oxido's Profile")**
- [![oxido's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/29793-oxido "View oxido's Profile") Topic Author
- [ Offline](/forum/user/29793-oxido)

Less More

- Posts: 282
- Thank you received: 42
-
-

5 years 5 months ago -  5 years 5 months ago [\#332822](#332822) by [oxido](/forum/user/29793-oxido "View oxido's Profile")  *[Show custom field in product page if it meets the conditions](/forum/4-how-to/902625-show-custom-field-in-product-page-if-it-meets-the-conditions#332822 "-- HikaShop version -- : 4.4.2 -- Joomla version -- : 3.9.26  Hi,  I have a custom field that I want to be visible on the product page, in a specific position, not where custom fields block's section exist's. So I was wandering if what I did it is a good practice or I should do it in a nother way.  This code it's in thew my view: product / show&#95;default.php  Thank you!")* was created by *[oxido](/forum/user/29793-oxido "View oxido's Profile")*

-- HikaShop version -- : 4.4.2
-- Joomla version -- : 3.9.26

Hi,

I have a custom field that I want to be visible on the product page, in a specific position, not where custom fields block's section exist's.
So I was wandering if what I did it is a good practice or I should do it in a nother way.

This code it's in thew my view: product / show_default.php
Code:

$sample_link_Config = hikashop_get('class.field')-&gt;getField('sample_link', 'product'); $frontDisplay = array_filter(explode(';', $sample_link_Config-&gt;field_display)); // field_display = ";compare=0;front_listing=0;back_invoice=0;back_shipping_invoice=0;order_form=0;(etc.);" if (in_array('front_listing=1', $frontDisplay) &amp;&amp; $sample_link_Config-&gt;field_published) : if (isset($this-&gt;element-&gt;evscloud_link) &amp;&amp; $this-&gt;element-&gt;sample_link != ''): ?&gt; &lt;a class="hikabtn evs-sample" href="&lt;?php echo $this-&gt;element-&gt;sample_link; ?&gt;"&gt;&lt;span&gt;Show content&lt;/span&gt;&lt;/a&gt;&lt;?php endif; endif;

Thank you!

Last edit: 5 years 5 months ago by [oxido](/forum/user/29793-oxido "View oxido's Profile"). Reason: I've added some extra info for clarification

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjYyNS1zaG93LWN1c3RvbS1maWVsZC1pbi1wcm9kdWN0LXBhZ2UtaWYtaXQtbWVldHMtdGhlLWNvbmRpdGlvbnM/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86323
- Thank you received: 14283
-
-

5 years 5 months ago [\#332823](#332823) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Show custom field in product page if it meets the conditions](/forum/4-how-to/902625-show-custom-field-in-product-page-if-it-meets-the-conditions#332823 "-- HikaShop version -- : 4.4.2 -- Joomla version -- : 3.9.26  Hi,  I have a custom field that I want to be visible on the product page, in a specific position, not where custom fields block's section exist's. So I was wandering if what I did it is a good practice or I should do it in a nother way.  This code it's in thew my view: product / show&#95;default.php  Thank you!")*

Hi,

It's ok but only if your custom field doesn't have / need translations and it's not a selector custom field (multiple dropdown, single dropdown, radio, checkbox, date picker, AJAX file, AJAX image, etc).
Otherwise, you need to do it like that:
$this-&gt;fieldsClass-&gt;show($sample_link_Config,$this-&gt;element-&gt;sample_link);
That way, the system will properly map the value from the database to what is supposed to be displayed (so instead of getting the value of the selected value, you would see the title of the selected value for a radio/dropdown/checkbox custom field).
Also, since you're doing a customization and you already know that the custom field is published, etc, I wouldn't bother with the first if. But it can be nice if you've working on someone else's website and the custom field could potentially be unpublished or its display settings could change in the future.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzkwMjYyNS1zaG93LWN1c3RvbS1maWVsZC1pbi1wcm9kdWN0LXBhZ2UtaWYtaXQtbWVldHMtdGhlLWNvbmRpdGlvbnM/dG1wbD1tYXJrZG93bg==) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.049 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
