Skip Navigation

[Résolu] Check if field is not empty

This support ticket is created Il y a 8 années et 5 mois. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

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

Last updated by hugoC-3 Il y a 8 années et 4 mois.

Assisted by: Beda.

Auteur
Publications
#353817

I am trying to: display a li only if it is not empty

I used this code:
[wpv-conditional if="( NOT(empty($(wpcf-bijlage))) )"]

  • [icon name="download" class="" unprefixed_class=""] <a href="[types field="bijlage" link="true" output="raw"][/types]">[types field="publicatietitel"][/types]</a>
  • [/wpv-conditional]

    I expected to see: a download link if the field is not empty

    Instead, I got: nothing; the download link doesn't show at all.

    What am I doing wrong?

    #353832

    Thank you for contacting us here in the Support Forum

    With the below code you check if the Custom Field "Bijlage" is NOT empty:

    [wpv-conditional if="( NOT(empty($(wpcf-bijlage))) )"]
    This field is not empty
    [/wpv-conditional]
    

    Now, if you use this in a View or on a Single Post, it will check the current Post, and if the Field is NOT empty, it will display things, if it is empty, not.

    Can you tell me what sort of Field "Bijlage" is?

    Perhaps you can try to remove your conditional and then add in the Views Loop NO conditional but only your list:

    <li>
      [icon name="download" class="" unprefixed_class=""] 
        <a href="[types field='bijlage' link='true' output='raw'][/types]">[types field="publicatietitel"][/types]</a></li>
    

    Does it even display something (if the Field is not empty)?

    If yes, now highlight that code and hit ion the Button "Conditional Output" in the Views editor and set your conditions with the wizard.

    That should work.

    Please don't hesitate to inform me in case the issue persists

    Thank you for your patience.

    #354142

    The field "bijlage" is an attachment upload field. I guess that's why it didn't work; no problem with a regular text field. I used a second field with the title of the attached file in a text field instead of the attachment field and used this as a conditional. Now it works fine.

    This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.