Skip Navigation

[Resolved] Conditional with relatioship

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 1 voice.

Last updated by pierre-yvesC 1 month ago.

Assisted by: Minesh.

Author
Posts
#2834452

I'm not able to show something only when a field has something. Otherwise, if it's empty, it's hidden

I use legacy view.

I tried:
[wpv-conditional if="( NOT(empty($(wpcf-mission-de-l-organisme))) )"]
[wpv-conditional if="( $(wpcf-mission-de-l-organisme) ne '' )"]
[wpv-conditional if="( $(wpcf-mission-de-l-organisme) eq '' )" evaluate="false"]

I tried all 3 solutions on a test site and all 3 are working.

Except in my real web site, there is a relationship involved (organisme-poste)

So I tried
[wpv-conditional if="( NOT(empty($(wpcf-mission-de-l-organisme item='@organisme-poste.parent'))) )"]
And
[wpv-conditional if="( NOT(empty($(wpcf-mission-de-l-organisme @organisme-poste.parent))) )"]

With no luck, I may don't have the correct syntax.

Any help would be appreciated.

Thx

#2834518

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I wuould like to know the field you want to check agains is it belongs to parent post and you added condition on child post?

Can you please share problem URL and admin access details and tell me what field you want to check agains as not emaplty and tell me your expected results.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2834713

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've adjusted the conditional code as given under within your view's loop:
=> hidden link

[wpv-conditional if="( '[types field='mission-de-l-organisme' output='raw' item='@organisme-poste.parent'][/types]' ne '' )"]
          <h4>Mission :</h4>
          [types field='mission-de-l-organisme' output='raw' item='@organisme-poste.parent'][/types]
          [/wpv-conditional]
          
          [wpv-conditional if="( '[types field='services-de-l-organisme' output='raw' item='@organisme-poste.parent'][/types]' ne '' )"]
          <h4>Services :</h4>
          [types field='services-de-l-organisme' output='raw' item='@organisme-poste.parent'][/types]
          [/wpv-conditional]

Can you please confirm it works as expected.

#2834728

Works perfectly.

Many thx for your help!