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.

Our next available supporter will start replying to tickets in about 1.76 hours from now. 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, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#2204397

Thanks for the details, I can login into your website, where I can see the problem you mentioned above:
I have deleted the publication where the "Volltext" field remains empty

Please point out the problem post URL, thanks

#2204619

Hi Luo,

well, there are many posts where the problem occurs. The one I mentioned (https://toolset.com/forums/topic/output-of-notice-when-view-field-has-no-value/page/2/#post-2196691) that I deleted and recreated still doesn't show the output of the field "Volltext":
hidden link

And this one isn't showing the output of the field "Heftnummer und/oder Seitenzahl":
hidden link

This one isn't showing the output of the field "Bibliografische Angaben":
hidden link

I don't see a pattern in there. It's very strange. I hope you can find the reason for this problem and can fix it.
Thanks a lot!
-Martin

#2204637

Hi Luo,

the links I posted are pointing to the wrong domain. It has to be test.nationalpark-unteres-odertal.de and not 2021.nationalpark-unteres-odertal.de. Sorry for the inconvenience...

#2204669

I have tried to replace the those URLs with the new domain name, and tried these URLs:
hidden link
hidden link
hidden link

None of them work in your test website, please check it, make sure your test site is ready for debug, thanks

#2204673

Hi Luo,

thanks for checking the links. The site gave me critical errors. I don't know why. Maybe temporary issue with the hosting provider...

I checked the links and am able to reach them:
hidden link
hidden link
hidden link

Please try again.
Thank you!

#2205705

OK, we can handle the questions one by one:
Q1) "Volltext" field
Please edit the problem "Publikation" post you mentioned above:
There isn't any custom field using name "Volltext", to avoid more misunderstandings, please elaborate the questions with more details.
Which custom field do you want to check, then output something with the conditional shortcode, thanks

#2205735

Hi Luo,
sorry, I named the descriptive titles I used in the front end and not the names of the fields Toolset is working with.

So, at this post for example the field "Heftnummer und/oder Seitenzahl" (slug: issue) is not beeing populated with the correct value. In this case the field has no value, but the conditional shortcode is configured to display a message ("nicht verfügbar") instead. This is not working for this post, but for other posts with the same conditions.
hidden link

The other posts I mentioned with no/wrong output for the fields "Volltext → Dateianhang" and "Bibliografische Angaben" are working now. The conditional shortcode was misconfigured. I don't know why, because the first time I set it put everything was ok...

So, please investigate the issue with the wrong output for the field "Heftnummer und/oder Seitenzahl".
Thanks a lot for your efforts!

#2206669

Thanks for the details, I have tried these in your website:
Edit the problem post:
hidden link
Click into field "Heftnummer und/oder Seitenzahl", press "Delete" key, save the post, test it in front-end:
hidden link
It works fine, please test again, check if it is fixed, thanks

#2206679

Hi Luo,

thanks a lot for your investigation.

I can confirm that your solution is working. I tried with another post where the output of the field "Heftnummer und/oder Seitenzahl" was empty. After editing the post and just pressing delete key in the field the output on frontend is correct. Nice!!

The big question is: why is this so? What is wrong with some of these fields (not all show no output)? What is it that getting deleted?
And most important: how can I find and correct all posts concerned? There are over 1000 posts of the type "Publikation"...

Do you have any idea or solution approach?

Thanks,
Martin

#2206691

I have changed the condition of conditional block "nicht verfügbar" as below:
( ( $(issue) eq '' ) )

Please test again, check if it is fixed in other posts

#2206695

Hi Luo,

No, unfortunately it does not work. For example in this post the field output is still empty...
hidden link

#2206713

It is actually a empty line break, and conducts problem.

I have done below modifications in your website:
1) Dashboard-> Toolset-> Settings-> Custom codes, add an item "remove-empty-lines", with below codes:

add_shortcode('remove-empty-lines', function($atts, $content){
	$content = trim(do_shortcode('$content'));
  	return $content;
});

2) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Third-party shortcode arguments", add the custom shortcode name: remove-empty-lines

3) Edit the content template
hidden link

Add a shortcode block, with below codes:

[wpv-conditional if="(  '[remove-empty-lines][wpv-post-field name="wpcf-issue"][/remove-empty-lines]' eq '' )" ] nicht verfügbar [/wpv-conditional]

Please test again, check if it is fixed, thanks

More help:
hidden link
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-field

#2207107
Bildschirmfoto 2021-10-27 um 16.41.04.jpg

Hi Luo,

just came back from a meeting and I have only now had the opportunity to test...

Fist of all: thanks a lot for your great support!

Well it works for this post:
hidden link

But sadly not for others, for example this one:
hidden link

And I recreated the modifications on my main development site (hidden link) and it gets very unstable with blank pages (http error 500). Only after deactivating some plugins the pages will load again. Why is the server so stressed?

The posts of the type "Publikation" are coming from a Drupal installation. I migrated them with the wordpress plugin "FG Drupal to WordPress". I had a look at the original Drupal posts and, well it's just a blank field (see screenshot). I totally don't understand this problem...

Do you have any further ideas on this?

-Martin

#2207583

I have change the custom codes to:

add_shortcode('remove-empty-lines', function($atts, $content){
	$content = trim(do_shortcode($content));
  	return $content;
});

Please test again, check if it is fixed.

For other new questions:
it gets very unstable with blank pages (http error 500)
There should be some PHP errors in your website, please check if there is any PHP error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#php-debugging

#2207739

Hi Luo,
unfortunately, the adjustment did not work...

There are still posts with no output of the field "Heftnummer und/oder Seitenzahl".

For example: hidden link

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