product_filter

On category pages, generates a filter based on product results.

Example

[%product_filter type:'category' limit:'100' autohide:'0' filter_parent_content:'1'%]
    [%param header%]
        Filter By Category
    [%/param%]
    [%param *body%]
        [%if [@selected@]%]
            <a href="[@remove_url@]" rel="nofollow">[@name@] [@total@]</a>
        [%else%]
            <a href="[@url@]">[@name@] [@total@]</a>
        [%/if%]
    [%/param%]
[%/product_filter%]

Please Note: If the limit is not set it will default to 100.

Usage

Maropost Commerce Cloud supports a number of different product filter types, and placing the product_filter tag on a category page in Maropost Commerce Cloud will display a filter list based on both the type of product filter you define, and the products that belong to that category / page. The system allows for filters to stack, so when a user applies a filter, the filter will be default refresh and show refined options based on the new product list. Filters can also be cleared in the same way, so by default our system uses logic in the body to determine whether [@selected@] is true to show either the url to apply the filter or remove this filter.

Specifics / Variations Filter

The variations filter looks at the specifics on an item and generates the filter based on that, so this is the primary tool for creating custom filters.

[%product_filter type:'variations' autohide:'0'%]
    [%param *header%]
        [%IF [@activecount@] > 0%]
            <a href="[@remove_url@]">Clear</a>
        [%/if%]
        Filter By [@filter_name@]
    [%/param%]
    [%param *body%]
        [%if [@selected@]%]
            <a href="[@remove_single_url@]" rel="nofollow">[@name@] [@total@]</a>
        [%else%]
            <a href="[@url@]">[@name@] [@total@]</a>
        [%/if%]
    [%/PARAM%]
[%/product_filter%]

Brands filter

The brands filter will generate a list of brands for the products available on the selected category.

[%product_filter type:'brand' limit:'50' autohide:'0'%]
    [%param header%]
        Filter By Brand
    [%/param%]
    [%param *body%]
        [%if [@selected@]%]
            <a href="[@remove_url@]" rel="nofollow">[@brand@] [@total@]</a>
        [%else%]
            <a href="[@url@]">[@brand@] [@total@]</a>
        [%/if%]
    [%/param%]
    [%param more%]
        <a href="[%url type:'page' id:'brands'/%]">Show all brands</a>
    [%/param%]
[%/product_filter%]

Product category filter

The category filter will show a list a filter based on categories the products are assigned to. Note that in Maropost Commerce Cloud, products can be assigned to multiple categories - and doing so means they will appear in this list, even if the categories are not descendants of the category currently selected. If you require a list of sub categories directly related to the category you are on instead, use a content menu.

[%product_filter type:'category' autohide:'0' filter_parent_content:'1'%]
    [%param header%]
        Filter By Category
    [%/param%]
    [%param *body%]
        [%if [@selected@]%]
            <a href="[@remove_url@]" rel="nofollow">[@name@] [@total@]</a>
        [%else%]
            <a href="[@url@]">[@name@] [@total@]</a>
        [%/if%]
    [%/param%]
[%/product_filter%]

Price filter

Just as with the other categories, the price filter will look at the products called to determine the price range, then divide break points based on the limit parameter. A popular use of this filter is to introduce a slider plugin, we have our own sample for you over at the tips & tricks or you can build your own with the below code.

[%product_filter type:'price' limit:'6'%]
    [%param header%]
        Filter By Price Range
    [%/param%]
    [%param *body%]
        [%if [@selected@]%]
            <a href="[@remove_url@]" rel="nofollow">[@name@] [@total@]</a>
        [%else%]
            [%if [@min@] == 0 and [@max@] > 0%]
                <a href="[@url@]">[%format type:'currency' dp:'0'%][@max@][%/format%] or below</a>
            [%elseif [@min@] > 0 and [@max@] > 0%]
                <a href="[@url@]">[%format type:'currency' dp:'0'%][@min@][%/format%] to [%format type:'currency' dp:'0'%][@max@][%/format%]</a>
            [%elseif [@max@] == 0%]
                <a href="[@url@]">[%format type:'currency' dp:'0'%][@min@][%/format%] or above</a>
            [%/if%]
        [%/if%]
    [%/param%]
[%/product_filter%]

A2Z filter

The A2Z filter will automatically index the results to produce an alphabetical filter.

[%product_filter type:'a2z' autohide:'0' ignorefilter:'1'%]
    [%param header%]
        Filter by A to Z
    [%/param%]
    [%param *body%]
        [%if [@selected@]%]
            <a href="[@remove_url@]">[@id@]</a>
        [%else%]
            <a href="[@url@]">[@id@]</a>
        [%/if%]
    [%/param%]
[%/product_filter%]

product_filter Parameters

Name Options Description
content_type:'' String Limits the filter to a specific content type
limit:'' Integer Limits the results of the filter
offset:'' Integer Starts generating the list from the integer specified
compatlist:'' String Only works with the type `content` & forces the filter to read a specific compat list ID.
paramfilter:'' `1`/`0` Without set filter_category to CURRENT CATEGORY (if not on home page)
filter_category:'' String Not compatible with `category_id`. Used to identify a specific category to generate a filter from. By default will use the current category
filter_content:'' String Identify a specific content type to generate a filter from. By default will use the current content type
filter_category_type:'' Content Type ID Filter by Content Type ID/Code
filter_variations:'' Variation ID Seperate by `,`, targets specific variations to filter
filter_instock:'' `1`/`0` When true, only applies filter to products in stock
ignore_current:'' `1`/`0` Ignore current filter set on the page when calculating results
show_child_products:'' `1`/`0` Apply filter to include child products
variation_specific:'' Specific ID Only works with the type `variations`, select the variation specific to filter
autohide:'' `1`/`0` If the filter has been applied, hide that filter
header HTML & b@se tags Renders a single usable space above the body
body* HTML & b@se tags Runs an array for each option in the tag
footer HTML & b@se tags Renders a single usable space below the body
ifempty:'' HTML & b@se tags If the filter parameters produce no results, this block is printed in place of the `header`, `body` & `footer`
ignorefilter:'' `brand`, `compat`, `category`, `author`, `content`, `variations`, `keywords`, `instock`, `price`, `dimension`, `length`, `width`, `height`, `misc#`, `filter#` Ignore specified filter type
sortorder:'' `desc`/`asce` Descending or ascending order, by default it is ascending
sortoption:'' `sortorder` Display the specifics based on the value in the Sort Order field in each specific (descending order).
hide_single_option:'' `1`/`0` When true, if there is only one result, hide filter
filter_parent_content:'' `1`/`0` Works with type content and type category, when true will enable a number of params related to the parent content of the filter results.
filter_parent_content_id:'' String Provided `filter_parent_content` is true, filter results will only print if they have the content ID specified as their parent. If `filter_parent_content_id` is ommitted but `filter_parent_content` is enabled the current page will be used as the parent ID.
parent_body:'' HTML & B@se tags Provided `filter_parent_content` is true, provides a code block to print data related to the parent content page of the filter results.
type:'' `brand`, `compat`, `category`, `author`, `content`, `variations`, `keywords`, `instock`, `price`, `dimension`, `length`, `width`, `height`, `misc#`, `filter#` Defines the type of product_filter that will be generated.
For type filter, the # should reference which custom product field with filter functionality it is (available options are misc14, misc15, misc 17, misc 18). e.g. `type:'filter1'` will create a filter with the content of custom product field misc14. Due to the way Maropost Commerce Cloud's database is structured, using filter values of `filter1`, `filter2` (etc) corresponds with the `misc14`, `misc15` (etc) fields.
autohide:'' `1`/`0` A boolean that when true will hide the filter once it has been applied

product_filter data tags

Name Description
`[@filter_name@]` The name of the specific type (eg: Colour, Size etc)
`[@name@]` The name of the filter value
`[@url@]` URL to perform filter
`[@remove_url@]` URL to remove all filters
`[@remove_single_url@]` URL to remove each single filter
`[@selected@]` If the filter is currently selected (1 = yes)
`[@related@]` If the filter is currently related (1 = yes)
`[@total@]` The total number of items that fall under a filter
`[@max@]` Maximum price for price filter
`[@min@]` Mininum price for price filter

Was this article useful?

Be notified when this page is updated. Optional.