Skip Navigation

[Resolved] Conditional data from two views

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)

This topic contains 7 replies, has 2 voices.

Last updated by TomW5440 4 months, 1 week ago.

Assigned support staff: Shane.

Author
Posts
#2425715

Tell us what you are trying to do?
I need to get conditional data from two views. I understand that views cannot be nested so I'm looking for a work around.

I have two relevant CPT's Agents and properties

I have a my account page which displays user info, agent info and property info.

I have two views on the page, the first (search for agents matching logged in user) I use conditional based on 'Number of items found in views' = 0 to display create agent button.

In the second view (search for properties matching logged in user), I want to use another conditional so 'Number of items found in views' =0 to display create property button. The problem is I need this button to only show if an agent has been created first. I can't add a conditional in the property view that relates to the agent view so I need to a way to work around this?

Thank you!

#2425773

Shane
Supporter

Languages: English (English )

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

Hi Tom,

Thank you for getting in touch.

I'm not sure I understand fully the display condition of the Create property button. Is it that when there is an agent you want to display the create property button ?

If such is the case the view itself should already meet that condition for you. For instance if you're displaying the agents with the view then within the [wpv-items-found] shortcode you can add the create agent button as this section will only display if there are agents.

Thanks,
Shane

#2426073

Hi Shane,

Sorry I didn't explain correctly.

So for the property button to show if these conditions must be met -
Number of items found in property views' = 0
Number of items found in agent views' > 0

#2426579

Shane
Supporter

Languages: English (English )

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

Hi Tom,

Let me see if I understand clearly now.

So you're able to do the Add Property button successfully based on the Number of items found in property views' = 0 condition.

However the issue is with the Number of items found in agent views' > 0 condition?

Is the Agent view a part of the property view search ? Perhaps sending me an example will help a bit. I'm thinking that you can add the button in the Agent view within the wpv-items-found shortcode because the contents of this shortcode will only display when the view returns at least 1 result.

Thanks,
Shane

#2427853
shane.png

Hi Shane,
Yeah that's correct. So I've got 2 views, one for agent and one for property but I need to access conditions from both but they cannot be nested (view in a view)? I want to have the create new property button appear in the property view before the loop content. The create new agent button isn't an issue because the conditional for that button only applies to agent view whereas the property button condition applies to both agent and property view.
Show property button if
Number of items found in property views' = 0 condition AND agent views' > 0 condition.
I hope this makes sense. Thank you!

#2427885

Shane
Supporter

Languages: English (English )

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

Hi Tom,

The views can be nested but if you want to nest the view, you'll need to make use of the classic view setup.

With Block views you won't be able to insert the views into each other.

Thanks,
Shane

#2427897

Oh right I didn't know that. Is it possible to use shortcode in an html block?

#2427921

My issue is resolved now. Thank you!