Jump to content

DatabaseFilters.php to Include Number Filtering


Rogefeller

Recommended Posts

As a part of the Pages CMS module, you can add filtering on custom fields. This filtering (applications/cms/widgets/DatabaseFilters.php) as setup through the admin panel is limited to select box strings and booleans only. You cannot do anything with numbers and comparison operators (<=, >=, <, >, etc).

Is there a way to have the form filter accept a number for filtering?

For example, all records have a custom field called "review score". The proposed change would allow the user to enter 8 on the form and the filter would return all records with a value greater than or equal to 8.

Seems like a basic request but I am struggling to follow the search function down the rabbit hole to figure out how the "advanced_search_submitted" query string is generated and how to add this new logic.

Link to comment
Share on other sites

8 hours ago, Rogefeller said:

For example, all records have a custom field called "review score". The proposed change would allow the user to enter 8 on the form and the filter would return all records with a value greater than or equal to 8.

For a score field, you could use the select box field type. That would allow filtering. 

For a number field, I doubt you can tweak the query string, since filtering simply isn’t supported in this case. Using select or radio, I guess you could tweak the template to create custom buttons, so hitting “8” would retrieve all entries having a score of 8, 9 and 10 for example. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...