Skip Navigation

[Resolved] Split: Query filter with in a view doesn’t work properly if there is no related post – display view conditinoally

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 0 voices.

Last updated by cassianS 1 month ago.

Assisted by: Minesh.

Author
Posts
#2800087

Hi Minesh. Thank you! It is working properly now! May I ask what did you do so I could use it in future development?
Also, I am trying to use the view with a shortcode in conditional output. The idea is to check is there are no doctor posts connected to report request post, so I could display a data conditionally.
However, it doesn't work.
Here is example
[wpv-conditional if="( "[wpv-view name='display-doctors-first-name-related-to-report-request' relatedreportrequest="[wpv-post-id item='@report-request-report-order-estimation.parent']"]" eq '' )"]
YEY
[/wpv-conditional]

I tried to put a shortcode view in PHP snippet shortcode but it doesn't work either (I get an error).
add_shortcode('doctors-first-name-related-to-report-request', function(){
return wpv_do_shortcode('[wpv-view name="display-doctors-first-name-related-to-report-request" relatedreportrequest="[wpv-post-id item='@report-request-report-order-estimation.parent']"]');
});

Do you think it is possible at all to use such view in conditional output?

#2800088

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I'm not sure why you want to use view's with conditional output.

Can you please share problem URL and where exactly you want to display conditional output and why?

#2800175

Hi Minesh.
Here is a URL of estimate that you had a chance to look at in another ticket: hidden link
Currently, as it should be the Doctor name is not getting displayed since there is no connected Doctor post. However in such cases I would like to display a Health Organization name instead which post would normally be connected if there is no doctor post.
That's why I was going to check whether doctor post is connected, and if not - display health organization info instead

#2800222

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I dont think you need conditional statement here.

I've created the following content template:
=> hidden link

[wpv-post-title item="@health-organization-and-report-request.parent"]

And then added the above content template to "[no-items-found]' section of your following view:
=> hidden link

[wpv-no-items-found][wpv-post-body view_template="get-grand-parent-organization" item="@report-request-report-order-estimation.parent"]
[/wpv-no-items-found]

That means if no items found it will take the parent that is report request and again display parenet of report request that is:

[wpv-post-title item="@health-organization-and-report-request.parent"]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/displaying-fields-of-grandparents/

#2800274

Fantastic workaround. That does the trick. Thank you!