Skip Navigation

[Gelöst] Conditional shortcode checking if view inside has posts

This support ticket is created vor 6 Jahren, 3 Monaten. 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.

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)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Shane vor 6 Jahren, 3 Monaten.

Assistiert von: Shane.

Author
Artikel
#1088364

Hi there

On this page versteckter Link in the tabs below I use conditonal shortcodes to check, if there is content inside and don't display the tab if there isnt.

That looks like this:

	[wpv-conditional if="( NOT(empty($(cv-awards))) )"]
			[fusion_tab title="CV & Awards" icon=""]
			<div class="ifb-inner-tab"><p>[types field='cv-awards'][/types]</p></div>
		[/fusion_tab]<br />
	[/wpv-conditional]

Now I would like to make the same thing with a view. In the last tab, there is a view that currently has no results on the post linked above. Therefore it should not display the tab at all.

Can I use wpv-conditional to check the outcome of a view or is there another attempt? The view is showing posts that are in a relationship with this post, so that could also be a way to identify if there is something to display or not.

Thanks!

Best,
Marcial

#1088602

Shane
Supporter

Sprachen: Englisch (English )

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

Hi Marcial,

Thank you for contacting our support forum.

What you are checking here is a WYSIWYG field correct?

Please let me know.
Thanks,
Shane

#1088659

Hi Shane

In the example I check a single line text field. But now I would like to adapt that to a view.

Does that answer your question?

Thanks

#1088660

Shane
Supporter

Sprachen: Englisch (English )

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

Hi Marcial,

Actually no it doesn't 🙁

What I do know is that if some content is empty, you dont want the tab to be displayed correct? However if a view is in the editor but the view returns No results found then you still don't want the tab to be displayed.

The problem here is that it's not possible to do this because you wouldn't be able to evaluate the view itself in the conditional code.

Thanks,
Shane

#1089231

Hi Shane

Okay, I see. Is there any workaround to achieve that or a little hack, like checking for fields in the view I load? I was just thinking that in the view there are several fields loaded. If the view is empty, obviously also the fields aren't there and therefore empty.

Best,
Marcial

#1089504

Shane
Supporter

Sprachen: Englisch (English )

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

Hi Marcial,

Any checking would need to be done in the view itself.

Its because we are not able to check outside the view for anything within it because the view is loaded whether or not the data is available or not if you understand where i'm getting at.

Will there be a case where the view will return empty? You could make the custom fields required so that the view will always return some result.

Thanks,
Shane