Skip Navigation

[Résolu] Hiding Empty Fields when Listing Them in Views

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 réponses, has 2 voix.

Last updated by jamesH-3 Il y a 8 années.

Assigned support staff: Ana.

Auteur
Publications
#167929

Hi

I have four conditions to list for my coupons and only one of them is required. When I try to list them, the empty fields are also listed with a bullet (*) with no data. I have tried to use [wpv-if] shortcode (based on what I Caridad recommended for someone else at https://toolset.com/forums/topic/wpv-if-dont-display-custom-field-if-blank/) but I could not make it work.

I would appreciate your help on this one?

Thanks

  • <div>[types field="coupon-condition-1" id=""][/types]</div>
  • [wpv-if coupon-condition-2="wpcf- coupon-condition-2" evaluate="!empty($coupon-condition-2)"]

  • <div>[types field="coupon-condition-2" id=""][/types]</div>
  • </wpv-if>
    [wpv-if coupon-condition-3="wpcf- coupon-condition-3" evaluate="!empty($coupon-condition-3)"]

  • <div>[types field="coupon-condition-3" id=""][/types]</div>
  • </wpv-if>
    [wpv-if coupon-condition-4="wpcf- coupon-condition-4" evaluate="!empty($coupon-condition-4)"]

  • <div>[types field="coupon-condition-4" id=""][/types]</div>
  • </wpv-if>

#167940

Hi Just noticed that I had not closed [wvp-if] properly. I have done it changed it to:

  • <div>[types field="coupon-condition-1" id=""][/types]</div>
  • [wpv-if coupon-condition-2="wpcf- coupon-condition-2" evaluate="!empty($coupon-condition-1)"]

  • <div>[types field="coupon-condition-2" id=""][/types]</div>
  • [/wpv-if]
    [wpv-if coupon-condition-3="wpcf- coupon-condition-3" evaluate="!empty($coupon-condition-1)"]

  • <div>[types field="coupon-condition-3" id=""][/types]</div>
  • [/wpv-if]
    [wpv-if coupon-condition-4="wpcf- coupon-condition-4" evaluate="!empty($coupon-condition-1)"]

  • <div>[types field="coupon-condition-4" id=""][/types]</div>
  • [/wpv-if]

However, it is still not working

Thanks

#167967

Ana
Supporter

Hi James,

when setting a variable to the wpv-if statement you should avoid hyphens, also you should use that variable in the evaluate parameter. So please try with the following:

[wpv-if coupon_condition="wpcf- coupon-condition-2" evaluate="!empty($ccoupon_condition)"] <li><div>[types field="coupon-condition-2" id=""][/types]</div></li>[/wpv-if]
[wpv-if coupon_condition="wpcf- coupon-condition-3" evaluate="!empty($coupon_condition)"] <li><div>[types field="coupon-condition-3" id=""][/types]</div></li>[/wpv-if]
[wpv-if coupon_condition="wpcf- coupon-condition-4" evaluate="!empty($coupon_condition)"] <li><div>[types field="coupon-condition-4" id=""][/types]</div></li>[/wpv-if]

For more information about conditional display you can check this page: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,

#168337

Hi Ana

It worked (after correcting a typo on line 1 - $coupon_condition instead of $ccoupon_condition)

Thanks heaps 🙂