Home › Toolset Professional Support › [Resolved] Conditional display based on at least one relationship result returned for 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 |
---|---|---|---|---|---|---|
- | 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 12 replies, has 2 voices.
Last updated by susanW-2 1 year, 9 months ago.
Assisted by: Minesh.
Tell us what you are trying to do?
I am trying to display content based on at least one relationship result returned for a view. For example, if I have a view that shows the custom content type of Projects that are connected (many to many) to the custom content type Departments, can I set that up to only display if the department has at least one project relationship connection?
Is there any documentation that you are following?
I'm following https://toolset.com/forums/topic/conditional-to-test-if-post-is-connected-via-relationship-or-similar-effect/, but the guidance seems to be outdated, as I cannot locate the settings referenced in this reply: https://toolset.com/forums/topic/conditional-to-test-if-post-is-connected-via-relationship-or-similar-effect/#post-1206219.
What is the link to your site?
Site is currently private.
Hello. Thank you for contacting the Toolset support.
Here is a sandbox site and you can auto-login to it using the following link:
- hidden link
Can you setup your post types and relationship and create a test where exactly you want to display conditionally and what.
Once you share all those information I will review the setup and guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I am happy to set up my content types in the test site - however, I'm not sure if this is a problem, because I'm just asking if this is something possible to create using toolset.
Yes - its possible but I would like to know what exactly the things you want to display conditionally if the department has at least one project relationship connection?
If the department has at least 1 department to project relationship, I would like to display the project post title with link.
Can you please share screenshot of your post relationship page from Toolset => Relationships?
And also, I would like to know where on what post you want to display the conditional thing?
As I understand on single department post you want to display all related projects and otherwise nothing - right?
If you can show me what you want to hide when there is no related post available that would help me to guide you in the right direction.
I have attached the screenshot of my relationships, as well as an example of my conditional. Currently, I have a custom 'Has projects' checkbox field on the department item entry, and the conditional display is built off of that. I'd like to have this display only if the department has at least one project related to it.
It seems to be correct to me. As I understand - you have a view that query the project post type and you want to only display the projects on department if the department has any projects. if that is correct.
Can you please share problem URL where you added the conditional display as well as admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
The query described in my earlier post is working , but it is clunky. I'm wondering if there's a way to set it up this way without using a query, by altering the view itself.
I'm not getting how its working or how its clunky. If you could send me problem URL and steps to see the issue then I can review that and after that I'll be able to guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Our dev team is working on granting admin access to the our site. In the meantime, I have created an example of what I am trying to do on hidden link. - view with digital research services to see desired behavior/display, and with research and instructional services to see undesired behavior/display. This is my content template for departments custom post type, which features a view displaying related projects. Ideally, I would like everything currently in the container block to only show if at least one result would be returned by this view. Can you help me understand how to set up that conditional?
Can you please check now: hidden link
I do not see the heading with the following post:
- hidden link
And I can see the heading with the following post:
- hidden link
What you should do is, try to add a conditional block and configure it to check with view's shotcodes and further select "number of items found in view" and compare it as shown with the following image:
=> hidden link
Then move the conditional block between view's output and view's loop section as shown with the following image:
=> hidden link
And add whatever block or text you want to display within the conditional block. I hope this will help.
My issue is resolved now. Thank you so much! Using the sandbox site was a great way for me to see the solution to my problem in detail. I had missed that there is an option in the conditional setup to select views shortcode and then only display based on the # of results returned by the view contained within that conditional. So helpful! Thanks again.