Skip Navigation

[Resolved] Issue with conditional block in view

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
- 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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by javierP-9 1 year, 4 months ago.

Assisted by: Waqar.

Author
Posts
#2507335
conditional-block.jpg

Hi! I have a view in my front page showing all the CPT Tours. In each tour I'm displaying several custom fields, including next confirmed departure date. Confirmed departure date is a custom field that can have a list of departure dates. In this view I'm showing a blue element with the nearest confirmed departure date, if exists, so I did this: I created a fields & text block and use a shortcode to display only the first confirmed departure date. That's working OK. Then I created a conditional field and configured it so it only shows up if the confirmed departure date is not empty and put the fields & text block inside.

But it's not working fine. In the tours with at least one confirmed departure date saved it works fine, but I have some tours with no date and the blue area is showing but with no date, in other tours it's not showing at all correctly. Please help.

Thanks in advance!

hidden link

#2508041

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Just like your other ticket, I'll need to see how this conditional block is set up in the admin area.

Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2508113

Hi Waqar, I've sent you the admin access for the other ticket, thank you so much

#2510933

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for waiting, while I performed some testing around this.

I was able to reproduce this behavior on my test website too. When a conditional block is used for an empty value check for a date type custom field, it always returns false.
(it uses the current date value instead of the empty date field value, in the evaluation)

I've shared these findings with the concerned team for further review and will keep you updated through this ticket.

For now, I've included the following custom script in the 'Custom JS' section of the view "Todos los tours", which hides the date container, when there is no value:


jQuery( document ).on( 'ready js_event_wpv_pagination_completed js_event_wpv_parametric_search_form_updated js_event_wpv_parametric_search_results_updated', function( event, data ) {
	jQuery('.tb-fields-and-text.tour-salida-grupo .salida-grupo_portada .salida-grupo_fecha strong').each(function () {
		var $this = $(this);
		if ($this.length) {
			var selText = $this.text();
			console.log(selText);
			if(!selText.trim()) {
				console.log('Empty!');
				$this.parents('.tb-fields-and-text.tour-salida-grupo').hide();
			}
		}
	});
});

#2511749

My issue is resolved now. Thank you!

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