Views - Minimum "Page Size"?

By: Lola F | Asked: 12/26/2022
ForumsCategory: General questionsViews - Minimum "Page Size"?
Lola F asked 1 year ago
I would like to filter my view to display at least 6 entries. When the filtered results are less than 6, it is possible to default to "no entries" message?
Victor Font replied 1 year ago

That's a good question and the answer is I don't know. In the all the years I've been volunteering n Formidable Community Support channels, I don't ever remember seeing a question like yours asked. This is a first for me, but this is how I would try it solve the puzzle:

1. navigate to the Formidable Forms Knowledge base and click the "Extend Formidable Forms" tile.
2. Click on Formidable Hooks - for Developers
3. Click on Display Data

This is a list of documented hooks related to displaying data on your site. There are hooks to change aspects of the SQL query before the query runs. Any query that runs for a view, whether it is a Formidable generated query or custom query, must return an array of entry ids so the view can be generated. I do not know of a hook that will allow you to intercept the results of the query before the view is generated so you can count the returned entries, clear the array, and let Formidable do the rest.

Before the view is generated, you may able to use the frm_where_filter. The entire Formidable query is passed to this filter. You can actually substitute you own query. You could modify the where clause with an impossible condition which would force a return of no entries, but to do this you would have to count the number of returned entries with your own custom SQL before you could feed Formidable an impossible condition.

With this understanding, there are other hooks where it may be possible to achieve your desired after the query runs. These filters are frm_before_display_content, frm_after_display_content, frm_display_entry_content, and frm_display_entries_content.

I don't know when these hooks fire in the content display cycle or if you can use them at all without going through a significant reverse engineering process, which I can't help you with as a community volunteer. Please let know how you solve this requirement. If you find a solution, I'm sure other users will be able to benefit from it.

2 Answers
Rob LeVineRob LeVine answered 1 year ago
I have two other possible solutions: 1. Use jQuery to, once the page is ready, count the number of rows in the table, and if it's less than 5, hide the table and throw up a message.  It's easier than it sounds. 2. Instead of using the standard before content, after content, and content boxes, replace them with a shortcode that will call a PHP program to generate the HTML for the table.  In that program, you can count the rows and display the error message. Let me know if you need any more info.
Bobby Clapp answered 1 year ago

I would probably use this to have alternative messaging based on a count:

https://formidableforms.com/knowledgebase/compare-two-values-for-display/#kb-compare-a-statistic

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right