Skip Navigation

[Resolved] Output of notice when view field has no value

This thread is resolved. Here is a description of the problem and solution.

Problem:

Conditional display on custom fields which have empty lines.

Solution:

You can try below custom shortcode:

https://toolset.com/forums/topic/output-of-notice-when-view-field-has-no-value/page/3/#post-2207787

Relevant Documentation:

This support ticket is created 2 years, 6 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 31 replies, has 3 voices.

Last updated by martinG-11 2 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2188903
Bildschirmfoto 2021-10-06 um 16.24.28.jpg

Hello,
I have a view that displays the values of various fields. Sometimes a field has no value. Then it would be nice to be able to output a message instead. For example "not available". How is this possible?

#2188947

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

You can use a Conditional block to only output the label and the field if the field has a value (so if the field had no value it wouldn't output anything).

But if you wanted to display a message you would add 2 Conditional blocks, one to show if the field did have a value and another for what to show if it didn't.

See https://toolset.com/course-lesson/using-toolset-conditional-block/

#2189725
Bildschirmfoto 2021-10-07 um 11.13.49.jpg

My issue is resolved now. Thank you!
Hi Nigel,
thanks for your answer! I was able to create the conditional querys now.

#2189743

One more question:
Something is strange: for posts where there is no value for a certain field, nothing is displayed despite the conditional query (a message "not available" should be displayed). Only after I have opened the post in the editor and saved it again does the message appear. What could be the reason for this?
I can't save all the posts again because there are >1000 posts...

#2189945

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

It looks like you are using the legacy editor with shortcodes rather than the block editor, in which case I think you may need to manually edit the shortcode argument to use empty, like so:

[wpv-conditional if = "( empty( $(wpcf-indexer)) )"]

...or...

[wpv-conditional if = "NOT ( empty( $(wpcf-indexer)) )"]
#2190383

Hello,

Please let me know if you still need assistance for it, thanks

#2190751
before updating.jpg
after updating.jpg

Hi,
I created the content template in block editor and it is working fine for the other fields. Only one field show nothing until I open the page in editor and update it. After that the conditional is working. And after updating I also see the correct path in my breadcrumbs. See screenshots. Can you help me investigate this issue?
Thanks!

#2192459

It might be a compatibility or cache problem, updating post will flush the post cache of some cache plugins, please try these:
1) deactivate all other plugins, and switch to WordPress default theme 2021
2) if the problem is fixed, then activate other plugins one by one, try to locate the problem plugin

#2194603

Hi Luo,

I deactivated plugins and switched theme, but the problem persists. Can you please help me further investigate it?

#2194815

Please provide database dump file(ZIP file) of your website, you can put the package files in your own google drive disk, share the link only, also point out the problem page URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#2195623

I have tried the database dump file in my localhost, there are some MYSQL errors when import it, some tables are missing, so this database dump file is not valid for debug, you can follow duplicator document to export the database only package files:
hidden link

Private message box enabled again

#2196417
not-empty.png

Thanks for the details, I can see the problem with your duplicator package.

The problem is: in those specific problem posts, post field "Heftnummer und/oder Seitenzahl", there is an empty space in the field value, it conducts the problem.

And in your case, I assume you are going to display the title "Heftnummer und/oder Seitenzahl" + fields, only when there is field value in it, if it is, please try these:
1) Edit the content template "Publikationen neu":
- find and select the conditional block for custom field "Heftnummer und/oder Seitenzahl", setup condition as screenshot not-empty.JPG
- Move the text title "Heftnummer und/oder Seitenzahl" into conditional block
2) Edit each problem "Publikation" posts, setup the custom field "Heftnummer und/oder Seitenzahl" values, save it, and test again

#2196649

Hi Luo,

thanks for having a look at this.

When I open a publication in the editor, I do not see a space in the field that remains empty. No matter what I enter in the field, nothing is displayed again after saving. Not even the message "not available". See this publication hidden link
That is very strange.
I have looked at other publications. Not only the field "Heftnummer und/oder Seitenzahl" has these errors, but also the field "Volltext".
For example, look at this publication hidden link.
Here, the "Volltext" field remains empty. Here, too, it is useless to change the content of the field in the editor and save it again.
I have adapted the content template as you wrote. It does not help.

Can you please further investigate the problem with the empty fields?
Thanks a lot and have a nice day!

#2196691

Here is an addendum to my post:
I have deleted the publication where the "Volltext" field remains empty (hidden link) and created a new one. Nevertheless, the field remains empty and there is no "nicht verfügbar/not available" output. I also renamed the linked PDF file to exclude the possibility that it is due to some strange characters in the file name. This did not lead to success either...

#2198771

I have tried again with the duplicator package file you provided, it works fine in my localhost using steps I mentioned above, if you need more assistance for it, please provide a test site with the same problem, fill below private message box with login details, I can setup a demo in your website

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