Skip Navigation

[Resolved] Display default value when custom views generating blank value.

This support ticket is created 4 years, 9 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by deepS 4 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1301979
Screenshot_5.jpg

Hi,
I am making one job website. I have achieved with the support of your technical team to generate a view on the front end from related posts. Naturally, I have put some conditions for displaying the results like showing expired job lists (created through RFG) when the last date of the application expires.

Well, when the data meets the condition it displays on the front end, but there are certain occasions when that section remain vacant due to non-fulfillment of the conditions. Here I want to show the message like "No job expired recently".

Even I achieved it but it's repeating for all the RFGs. See the screenshot_5.

I have used following code in views:

[wpv-conditional if="( $(wpcf-last-date-of-application).item(@job-post-details.parent) lt 'TODAY()' )"]
<h4>[types field="post-name"][/types]</h4>
<p>No. of Vacancies: [types field="no-of-vacancies"][/types]</p>
[/wpv-conditional]
[wpv-conditional if="( $(wpcf-last-date-of-application).item(@job-post-details.parent) gte 'TODAY()' )"]
No job expired recently.
[/wpv-conditional]

I want this message to be shown once in the page where the view generates blank data. Please help.

#1302327

There's nothing built-in to Views that will display different information based on the results of other instances of the View on the same page. If the View results are shown together, you could probably use CSS to hide all but the first element. Add a unique classname to a span tag around the message:

[wpv-conditional if="( $(wpcf-last-date-of-application).item(@job-post-details.parent) gte 'TODAY()' )"]
<span class="no-results-found-your-view-slug">No job expired recently.</span>
[/wpv-conditional]

Then add CSS to the View's Loop editor CSS panel:

.no-results-found-your-view-slug {
  display:none;
}
.no-results-found-your-view-slug:first-of-type {
  display:block;
}

You should change "your-view-slug" to match the slug of this View.

#1302545
Screenshot_6.jpg

Hi Christian,
As always you give superb support to resolve my issues, I am very thankful. In fact, the view issues with the 'Job posts' on the 'Companies' (related) page were resolved by you. Here also your tricks worked fine except those instances where there are different 'Last dates of application'. You can see the page here: hidden link
I am attaching the Screenshot_6 for your better understanding.

See my objective is to show the information of the expired job post on different past dates or showing 'No Job expired' only once instead of the vacant space on the page when there is no data. Well, I took the approach that I think suitable (but alternative ways are welcome if it shows the result I want). Hope you understand my point.

Here I am generating results for the page using views: 'Expired Job Vacancy' and 'Expired Job in Company' and content 'Template for Companies'

If you wish I can give you access to my wp backend.

#1302929

Unfortunately I don't have a simple solution. Each View acts independently of other Views on the page, so there's no way for one View to easily know if another View on the page had results or not. It might be possible to achieve this with custom code, using the Views API. We offer the API get_view_query_results, which allows you to inspect the results of any View using PHP: https://toolset.com/documentation/programmer-reference/views-api/#get_view_query_results

If you need assistance with this API, I can help troubleshoot any PHP code that touches the API.

#1303007

Yah I understood your point. But the problem is I don't know how to fix the issue with API function. I'd be obliged to get your support. Thanks.

#1303153

But the problem is I don't know how to fix the issue with API function.
Okay I can help you troubleshoot problems in your own custom code. That does not mean I can write this code for you. You are asking for a feature that is not offered by Toolset, and supporters are not able to create new features for you. Please review our support policy: https://toolset.com/toolset-support-policy/

I can help you troubleshoot your code if it uses the APIs. If you need someone to write custom code for you, you can connect with independent developers in our contractors portal here: https://toolset.com/contractors
Or for smaller projects, you may be able to find assistance here: https://codeable.io/developers/toolset/

#1305635

Please keep the ticket open. I am working on it.

#1305931

Great, I'll stand by for your feedback.

#1308267

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.