Skip Navigation

[Resolved] Conditional output in nested views

This support ticket is created 2 years, 7 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)

This topic contains 5 replies, has 2 voices.

Last updated by Roberto Miguez 2 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#2324179

Hello,

CPTs: "Centers" and "Units" with a many to many relationship
Custom Taxonomy: "Specialty"
"Specialty" is a taxonomy for both "Centers" and "Units".

Some Centers have Units, but others don´t.

This is part of the template for "Center":

Center A

Specialty 1
-- Unit 1
-- Unit 2
-- Unit 3

Specialty 2
-- Unit 4
-- Unit 5

Specialty 3
--Unit 6

This part´s output is shown through this view ("Specialties in a Center"):

<wpv-loop>
[wpv-post-body view_template="loop-item-in-specialties-in-a-center"] <!-- Shows the Specialty -->
[wpv-view name="units-in-a-hospital-per-specialty"] <!-- Shows the Units that have that Specialty-->
</wpv-loop>

It filters by taxonomy term defined by the current post.

The view loops the specialties of the Center, and then the Units that belong to each specialty.

If there is a Hospital that has no Units, then its specialties are shown with nothing below.

What I want is to show this area only for Centers that have Units. If there are no Units, the Specialty should not be shown.

Is there a way to set that condition?

Thank you.

#2324255

Shane
Supporter

Languages: English (English )

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

Hi Roberto,

Thank you for getting in touch.

Unfortunately no there isn't a way to do this. The main issue here is because we are not able to evaluate a view in a conditional tag in order to display a specific text.

Perhaps this can be done using some amount of custom code but defaultly it isn't possible to do.

Thanks,
Shane

#2324315

Thank you, Shane.

#2324839

Just to add that I overcame this by adding a checkbox field to the Centers CPT named "Has Units".

Then I can use a conditional like "if Has Units is checked, show this".

It´s not the ideal solution but it works.

#2325085

Shane
Supporter

Languages: English (English )

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

Hi Roberto,

Thank you for sharing the update.

Happy that you were able to resolve the issue. If there are any further issues I will be more than happy to assist. If not then you can go ahead and closed here.

Thanks,
Shane

#2325915

My issue is resolved now. Thank you!