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

#   Custom field in description if

##

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

Less More

- Posts: 432
- Thank you received: 22
-

7 years 5 months ago [\#307108](#307108) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307108 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")* was created by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")*

-- HikaShop version -- : 4.0.3
-- Joomla version -- : 3.9.6
-- PHP version -- : 7.2

I have customized view product/show_default to show some custom fields like that Code:

&lt;div class="row-fluid"&gt; &lt;div class="col-sm-2 phot"&gt;&lt;?php $fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('autorfoto', 'product'); echo $fieldClass-&gt;show($field,$this-&gt;element-&gt;autorfoto); ?&gt; &lt;/div&gt; &lt;div class="col-sm-10 text"&gt;&lt;?php echo $this-&gt;element-&gt;autortext; ?&gt;&lt;/div&gt; &lt;/div&gt;

I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up.
thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) 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: 86541
- Thank you received: 14304
-
-

7 years 5 months ago [\#307112](#307112) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307112 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

Hi,

You can do like that: Code:

if(!empty($this-&gt;element-&gt;autortext)) { // your code }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

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

Less More

- Posts: 432
- Thank you received: 22
-

7 years 5 months ago [\#307209](#307209) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307209 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

I get error. Something doing it wrong. Can you please add me code to my code.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")**
- [![Mohamed Thelji's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar6861.png)](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")
- [ Offline](/forum/user/6861-mohamed-thelji)

Less More

- Posts: 12953
- Thank you received: 1778
-
-
-

7 years 5 months ago [\#307220](#307220) by [Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")  Replied by *[Mohamed Thelji](/forum/user/6861-mohamed-thelji "View Mohamed Thelji's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307220 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

Hello,

You should try it like this : Code:

&lt;div class="row-fluid"&gt; &lt;div class="col-sm-2 phot"&gt;&lt;?php $fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('autorfoto', 'product'); echo $fieldClass-&gt;show($field,$this-&gt;element-&gt;autorfoto); ?&gt; &lt;/div&gt; &lt;div class="col-sm-10 text"&gt;&lt;?php if(!empty($this-&gt;element-&gt;autortext)) { echo $this-&gt;element-&gt;autortext; } ?&gt; &lt;/div&gt; &lt;/div&gt;

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

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

Less More

- Posts: 432
- Thank you received: 22
-

7 years 5 months ago [\#307346](#307346) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307346 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

Sorry for bother.

Now I get in html output
Code:

&lt;div class="row-fluid"&gt; &lt;div class="col-sm-2 avtorphot"&gt;&lt;img class="" src="/poslovno/order/download/field_table-product/field_namekey-YXV0b3Jmb3Rv/name-/thumbnail_x-100/thumbnail_y-100" alt=""&gt; &lt;/div&gt; &lt;div class="col-sm-10 avtortekst"&gt;&lt;/div&gt; &lt;/div&gt;

Image is not selected, so it should be empty. And I need to hide divs to if empty field.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile")
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

7 years 5 months ago [\#307355](#307355) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  Replied by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307355 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

Hi,

Try like this:
Code:

&lt;div class="row-fluid"&gt; &lt;?php $fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('autorfoto', 'product'); if(!empty($fieldClass-&gt;show($field,$this-&gt;element-&gt;autorfoto))) {?&gt; &lt;div class="col-sm-2 phot"&gt;&lt;?php echo $fieldClass-&gt;show($field,$this-&gt;element-&gt;autorfoto);?&gt;&lt;/div&gt; &lt;?php } if(!empty($this-&gt;element-&gt;autortext)) {?&gt; &lt;div class="col-sm-10 text"&gt;&lt;?php echo $this-&gt;element-&gt;autortext;?&gt;&lt;/div&gt; &lt;?php }?&gt; &lt;/div&gt;

Thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) 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: 86541
- Thank you received: 14304
-
-

7 years 5 months ago [\#307347](#307347) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307347 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

Like that then: Code:

&lt;div class="row-fluid"&gt; &lt;?php if(!empty($this-&gt;element-&gt;autorfoto)) { $fieldClass = hikashop_get('class.field'); $field = $fieldClass-&gt;getField('autorfoto', 'product'); echo '&lt;div class="col-sm-2 phot"&gt;' . $fieldClass-&gt;show($field,$this-&gt;element-&gt;autorfoto) . '&lt;/div&gt;'; } if(!empty($this-&gt;element-&gt;autortext)) { echo '&lt;div class="col-sm-10 text"&gt;' . $this-&gt;element-&gt;autortext . '&lt;/div&gt;'; } ?&gt; &lt;/div&gt;

The following user(s) said Thank You: [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

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

Less More

- Posts: 432
- Thank you received: 22
-

7 years 5 months ago [\#307522](#307522) by [mojweb](/forum/user/5128-mojweb "View mojweb's Profile")  Replied by *[mojweb](/forum/user/5128-mojweb "View mojweb's Profile")* on topic *[Custom field in description if](/forum/31-development/897572-custom-field-in-description-if#307522 "-- HikaShop version -- : 4.0.3 -- Joomla version -- : 3.9.6 -- PHP version -- : 7.2  I have customized view product/show&#95;default to show some custom fields like that  I get right output, but row displays if fields are empty. What code to add (some php if) to show row div only when fields filled up. thank you")*

Nicolas, that is working great. Thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg5NzU3Mi1jdXN0b20tZmllbGQtaW4tZGVzY3JpcHRpb24taWY/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) 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.127 seconds

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