Skip Navigation

[Resolved] Conditional Display displays Empty field

This support ticket is created 7 years, 8 months ago. 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by Shane 7 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#421959

I do not want a VIEW result to display if an image field is empty (wpcf-chicago-apartments-photos).

[wpv-conditional if="( $(wpcf-chicago-apartments-photos) ne '' )"]
TEMPLATE CONTENT
[/wpv-conditional]

The above code works except the EMPTY field displays with no content and there is an empty space. What am I missing?

Thanks!

#421971

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

Thank you for contacting our support forum.

I'm more than happy to assist you with this 🙂

You can actually check if a field is empty by taking a look at the link below.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

This should guide you through the proper way of setting up the conditional shortcode.

Please let me know if this helps.
Thanks,
Shane

#421977

Hi:

That was the post I referred to for guidance. I can't figure out why the above code displays empty fields?

#421983

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

Could you explain what you want to achieve with the conditional code?

Maybe I can provide a solution for you 🙂

Thanks,
Shane

#422024

Thanks @shane

I am using Views to perform a real estate search. I only want real estate custom post types to display in the results if a specific real estate custom post field (an image field) has an image.

Does that make sense?

#422203

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

Thank you for the clarity.

Would you mind allowing me to have admin access to the website so that I can check on this for you ?

The private fields will be enabled for your next response.

Thanks,
Shane

#422251

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

Thank you for the credentials.

Unfortunately i'm not able to access them at the moment.
It seems we are experiencing a few issues with the forum.

Once i'm able to access the fields I'll update you on my progress.

Thanks,
Shane

#422282

Thanks. I really appreciate the help.

#422435

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

I was able to access the private field.

Could you let me know which view I should be looking at ?

Thanks,
Shane

#422491

Hi:

It is the apartment View. This view appears on the home page and displays the apartments.

#422512

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

I took a look at this for you.

The proper way to do it is to wrap the shortcode around the rows themselves.

However I noticed that there is a orphaned [/wpv-conditional] on the page.

Any idea what might be causing this ?

Thanks,
Shane

#422534

That did it... Thanks! Yes, I found the orphaned [/wpv-conditional] and removed it.

The new code now produces 2 columns not 3 columns as before. Going line by line through the code I can not finding the "why" this is happening....

#422614
blank_area.png

OK.. I have been looking at this coding to long. Figured out the columns.

But there are still blank areas displayed where there is not an image.

#423000

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Randi,

I believe I know why this occurs and it has to do with how views is indexing the items.

So you notice that above each call for the content template you see this [wpv-item index=1]

So how it works that it picks off each of the posts out of the list of posts being returned. So the post is being returned even if it has no image. Technically the space will still be there but the post will be hidden because of the conditions not being met.

This seems to be a limitation to how views work.

Thanks,
Shane

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