Filtering lists/tables

  • Views Views: 52,019
  • Last updated Last updated:

Navigation

  • Filters can be applied to a Fabrik table via the following means:
    Regardless of which method is used the filters are stored in the session (which means that their results are 'sticky' and will be applied each time the table is viewed

    Filtering via the URL​


    NOTE - when using complex query string filters, like specifying 'group_to_previous' or 'join', this will often not play well with existing element filters on the list. So when using complex URL filtering, you should remove any element filtering (typically by copying your list and removing any element filters from the copy) to avoid unpredictable conflicts. This is because we simply have no way of knowing how the boolean logic of your initial query string filters should interact with the element filters.

    Simple filtering​

    The simplest way to filter is to append "&tablename___elmentname=value" to the URL.
    "&tablename___elmentname1=value1"&tablename___elmentname2=value2"

    Note: In order to use an element name in a URL filter, that element must have a filter enabled.

    Dates​

    URL date filters accept times that can be converted using PHP's strtotime function (see http://php.net/strtotime)

    If you want to match upcoming records for the next 2 weeks you can do this:
    Code:
    ?tablename___time_date[value][]=now&tablename___time_date[value][]=%2B2 week&tablename___time_date[condition]=BETWEEN
    Note the "%2B" in the second date value is the url encoded version of '+'

    If you want to match the records from last week you can do this:
    Code:
    ?tablename___time_date[value][]=-1 week&tablename___time_date[value][]=now&tablename___time_date[condition]=BETWEEN

    Using predefined date periods (analogue to pre-filters)
    Code:
    ?tablename___time_date[condition]=thismonth
    No ...[value] needed.

    Possible 'conditions':
    • thisyear
    • earlierthisyear
    • laterthisyear
    • yesterday
    • today
    • tomorrow
    • thismonth
    • lastmonth
    • nextmonth
    • nextweek1 (Next week Monday)
    • birthday (Day and month)

    Multiple values for the same element​

    If you want to filter on a series of values for the same element do this:
    Code:
    ?&tablename___elementname[value][]=64&tablename___elementname[value][]=126&tablename___elementname[value][]=127&tablename___elementname[join]=OR
    If you want to filter on a value 'foo' in either element 'A' or 'B' then do this:
    Code:
    ?tablename___A[value]=foo&tablename___A[join]=OR&tablename___B[value]=foo&tablename___B[join]=OR

    Available 'conditions'
    • EQUALS
    • BETWEEN
    • BEGINS WITH
    • CONTAINS
    • ENDS WITH
    • IN
    • not_in
    • >
    • <
    • <>
    • IS NULL (only use ...[condition], don't set a ...[value])

    Grouping multiple sub queries​

    Say we want to create this where statement:
    Code:

    WHERE (tablename___user_town = 'La Rochelle' OR tablename___user_town = 'Paris') AND (tablename___user_age = 20 OR tablename___user_age = 30)
    we would need to create a URL filter :
    Code:

    http://site.com/mypage?
    tablename___user_town[value][]=La Rochlle
    &tablename___user_town[value][]=Paris
    &tablename___user_town[join]=AND
    &tablename___user_town[join]=OR
    &tablename___user_town[grouped_to_previous][]=0
    &tablename___user_town[grouped_to_previous][]=1
    &tablename___user_age[value][]=20
    &tablename___user_age[value][]=30
    &tablename___user_age[join]=AND
    &tablename___user_age[join]=OR
    &tablename___user_age[grouped_to_previous]=0

    Grouping sub queries - Another example
    Say we want to create this where statement:
    Code:

    WHERE (tablename___player_a_id = 100 OR tablename___player_b_id = 100 OR tablename___player_x_id = 100 OR tablename___player_y_id = 100) AND yr = 2016
    we would need to create a URL filter:
    Code:

    http://site.com/mypage?index.php?option=com_fabrik&view=list&listid=36&&resetfilters=1&
    tablename___player_a_id[value][]=100&tablename___player_a_id[join][]=OR&
    tablename___player_b_id[value][]=100&tablename______player_b_id[join][]=OR&
    tablename___player_b_id[grouped_to_previous][]=1&tablename___player_x_id[value][]=100&tablename___player_x_id[join][]=OR&
    tablename___player_x_id[grouped_to_previous][]=1&tablename___player_y_id[value][]=100&tablename___player_y_id[join][]=OR&
    tablename___player_y_id[grouped_to_previous][]=1&yr[value][]=2016

    Using IN, not_in​


    If you need to test for a list of different possible values, you can use the IN condition with a comma separated list:
    Code:

    &tablename___whatever[condition]=IN
    &tablename___whatever[value]=1,2,3


    URL filtering Across All Fields​

    There are two variables you can use to filter data across all of the table's fields:

    Fabrik 2.x:
    • fabrik_table_filter_all - This defines the value to search for
    • search-mode-advanced - If your table has its 'advanced search mode' turned on, then Fabrik will use boolean full text matchingThis has the additional option to specify how to search the data:
      • all - search for all the words
      • any - search for any of the words
      • exact - search for the exact phrase
      • none - search for all records which don't contain the value
    e.g. to find all records which don't contain '666' then add this to your table's url:
    Code:
    ?fabrik_table_filter_all=666&search-mode-advanced=none

    Fabrik 3.x:
    • fabrik_list_filter_all_X_com_fabrik_X (X is the list ID)
    e.g to find all records which contain 'abc' then add this to your list's url:
    Code:
    &fabrik_list_filter_all_22_com_fabrik_22=abc

    Querystrings to clear and/or reset filters​

    In addition you can pass in variables via the querystring to clear and/or reset filters:
    • clearfilters=1 will clear the previous filters and not apply any other filters except prefilters (has the same behaviour as the 'clear' button)
    • resetfilters=1 will clear previous filters and apply any current querystring filters and prefilters
    • clearorder=1 will clear any ordering that has been applied to the table view.

    Querystrings to display parts of a list (overriding pagination)​

    You can override the list's pagination settings with (X = your-list-id)
    • limitstartX=7 will display the list starting with record no. 7
    • limitX=100 will display 100 records
    Useful in case of e.g. PDF creation (create a custom PDF link with limitstartX=0&limitX=100 to get your PDF with up to 100 records).

    Element Filters​

    For each element you have the option to add a filter to the List view, allowing your users to filter the table data. For information about the individual element filter settings see here.

    Clearing Element Filters
    You can clear the filters by pressing the 'clear' button at the top of the List. This will remove all the users filters from their session, but will still apply the table's prefilters.

    Ordering list data via the querystring​


    For ordering data via the querystring please see sorting list data
Back
Top