Uber Filter - Advanced

Connect a site search to Uber Filter

If your site has a regular concrete5 search page, the Uber Filter Connect Search block can be placed on the same page as the core search results block to direct the search, complete with any search parameters, to a page with Uber List and Uber Filters.

Linking into a pre-selected Uber Filter

Place the Uber Filter Query Parameters block on the page and it will dynamically generate a URL that matches the current filter settings. This URL can then be used to link to the page with the filter settings pre-selected.

You can either leave the Uber Filter Query Parameters block visible to everyone, so they can share filtered URLs, or use block permissions so only you can see it.

Use in Stacks and Global Areas

Uber Filter works out what search data to load into a browser based on the filter blocks placed on a page. When an Uber Filter block is in a stack or global area, that information will not be directly available. To communicate which search data to include with a page, you can add an Uber Filter Require Fields/Columns block to a page. This has no visible output, but will ensure specified search data is included.

Filter Data Cache

Rather than work out filter data each time a page is loaded, filter data is assembled and cached using the same cache settings as the list cache within the associated Uber List. Through the list cache settings, you have control over how this is shared between users. If you know there is no sensitive data, you can make the cache global to all users.

Extent of Filter Data

Filter data loaded into a visitors web browser is deliberately limited to the items actually in a list and, for each item, to the only the columns/fields specified for filtering. 

In situations where there are many lists which (between them) use nearly all-available columns/fields, it may be preferable to simply include all the columns/fields in the filter data prepared for loading into browsers rather than work out which to use and when.

Similarly, when it is already known a list will include nearly all items in a search index, it may be preferable to simply include all the items in the filter data prepared for loading into browsers rather than work out which to use and when.

Overriding the optimisation of list rows or columns can be set through configuration constants. Simply set these constants to true in config/site.php

UBER_FILER_POPULATE_ALL_PAGES_SEARCH_COLUMNS
UBER_FILER_POPULATE_ALL_FILES_SEARCH_COLUMNS
UBER_FILER_POPULATE_ALL_USERS_SEARCH_COLUMNS
UBER_FILER_POPULATE_ALL_PAGES_SEARCH_ROWS
UBER_FILER_POPULATE_ALL_FILES_SEARCH_ROWS
UBER_FILER_POPULATE_ALL_USERS_SEARCH_ROWS

Take care when using these override constants that you are not including any information a user should not see. Some critical security data, such as user passwords, are always excluded. However, if you store other sensitive information that is limited to specific visitors, you shouldn’t include that information in filter data available to other users.

Manually setting Checkbox and Select filter options

In many cases, Uber Filter will automatically populate Checkbox and Select filter options. However, sometimes you will only want to show a few of the possible options. In the edit dialog simply un-check Automatic labels and you can then define individual values and labels to match against.

Reducing Checkbox and Select filter options

When Checkbox and Select filter options are automatically generated, rather than specifying options you can also reduce the options actually shown with the Prefix, Postfix, Contains setting. Enter some text and choose one of Prefix, Postfix or Contains and only matching options will be shown. 

This is a case invariant text match. Prefix or Postfix are further delineated by any non alphanumeric character in the option text. Contains works through simple containment.

Prefix and Postfix will also remove the prefix or postfix text from the label shown with the filter.

A typical use would be to sub-divide the options in a select attribute with a prefix of A_ and B_, then only using those with prefix A_ in some filters and those with prefix B_ in other filters.

Optimising User and File filter data

Sometimes you want to filter a list of files by Fileset, but you also have some behind-the-scenes Filesets you don't want visitors to know about. Similarly, perhaps you want to filter Users by User Group, but keep some User Groups out of the list.

In addition to simply defining the options you want using one of the mechanisms above, for Filesets and User Groups you can also manage the automated settings by listing Filesets or User Groups to be globally excluded in a comma separated list with the config/site.php constants:

UBER_FILTER_EXCLUDE_FILESETS
UBER_FILTER_EXCLUDE_GROUPS

How filters and options combine

When you have multiple Uber Filter widget blocks, the filters always combine by an AND relationship. Only list items that meet all the filter widget settings will be shown.

However, within a filter that allows multiple options to be shown such as a checkbox or multiple select filter, you can choose whether multiple options combine through AND or OR by selecting the Logical relationship for multiple in the block edit dialog.

For example, with a checkbox filter on tags, perhaps you want only pages that have all of the tags to be shown, so the filter widget block would be saved with AND selected.

On the other hand, if you created a single select attribute for region with values North, South, East, West and Central, then any one listed item can only be in one region. In this case, a checkbox filter would make more sense as an OR relationship.

Null and empty values

Where the index data for an item is null or empty, filter widgets provide an option of how that item can be interpreted.

  • Always include  - always included in a filtered list
  • Always exclude - always excluded from the filtered list
  • Equivalent to empty string - which is also equivalent to a numerical zero or boolean false.
  • Equivalent to first - treat it as having the same value as the first filter option
  • Equivalent to last - treat it as having the same value as the last filter option
  • Equivalent to middle - treat it as having the same value as the middle filter option

Connecting Uber Filter blocks to an Uber List

Uber Filter widget blocks will try and automatically associate with an Uber List. When there is only one Uber List on a page, that is pretty straight forward, so you can leave the block edit field id of associated Uber List empty.

When you have more than one Uber List on a page, you may need to specify the name of the Uber List, so Uber Filter knows which filter blocks work with which lists.

Where filter data comes from

Filter data for Pages is based on the core PageSearchIndex joined with some other core tables, so any attributes you want to filter on need to be included in that index. You should also run the jobs that re-index the PageSearchIndex after page content has been edited

Filter data for Users is based on UserSearchIndexAttributes joined with some other core tables. User attributes and properties are automatically included in that index and updated when the attributes are changed.

Filter data for Files is based on FileSearchIndexAttributes joined with some other core tables. File attributes and properties are automatically included in that index and updated when the attributes are changed.

Filtering lists other than Pages, Files and Users

The filter data classes are managed through a plugin mechanism, so a plugin class can be created for other types of filter data. 

Magic Data Forms already includes a Forms filter data plugin that can be used to extend Uber Filter to filter lists generated from form results, or through that from anything a Magic Data Forms interface is available for, such as listing and filtering data from a CSV file.

I also anticipate a filter data plugin for Magic Data Commerce.

Filter data plugins are not difficult to develop, but do require some PHP and SQL programming skill.

 

Please see the Filter Widget Documentation for details of each of the Uber Filter blocks.

Last updated: over a year ago