
mFilter
Faceted filtering for MODX 3 with SEO URL support


Patterns define how filters are recognized in SEO URLs.
Patterns let you:
| Type | URL | Pattern |
|---|---|---|
| Standard | /catalog/vendor_apple/ | {key}_{value} |
| No key | /catalog/apple/ | Custom pattern |
| Range | /catalog/price_1000-5000/ | price_(\d+)-(\d+) |
| Multiple | /catalog/color_red,blue/ | {key}_{value}(,{value})* |
| Column | Description |
|---|---|
| Pattern | Regular expression |
| Filter key | Which filter it belongs to |
| Description | Notes |
| Active | On/off |
| Order | Application priority |
| Field | Description |
|---|---|
| Pattern | Regex for URL segment |
| Filter key | Key from the filter set |
| Description | What the pattern is for |
| Active | Whether to use it |
Uses PHP PCRE regex syntax.
# Single value
vendor_([a-z0-9-]+)
# Range
price_(\d+)-(\d+)
# Multiple values
color_([a-z0-9-]+(?:,[a-z0-9-]+)*){key}_([a-z0-9-]+)Matches: vendor_apple, color_red
{key}_(\d+)-(\d+)Matches: price_1000-5000, weight_100-500
{key}_([a-z0-9-]+(?:,[a-z0-9-]+)*)Matches: color_red,blue,green
Patterns are applied in Order (rank):
Pattern: price_(\d+)-(\d+)
Key: price
Description: Price rangeURL /catalog/price_10000-50000/ → price: {min: 10000, max: 50000}
Pattern: date_(\d{4})-(\d{2})-(\d{2})_to_(\d{4})-(\d{2})-(\d{2})
Key: date
Description: Date rangeURL /catalog/date_2024-01-01_to_2024-12-31/ → date range
Pattern: ^(apple|samsung|xiaomi)$
Key: vendor
Description: Vendors directlyURL /catalog/apple/ → vendor: apple
$mfilter = $modx->services->get('mfilter');
$urlRouter = $mfilter->getUrlRouter();
// Parse URL
$parsed = $urlRouter->parse('/catalog/vendor_apple/price_1000-5000/');
// [
// 'filters' => ['vendor' => ['apple'], 'price' => ['min' => 1000, 'max' => 5000]],
// 'tech' => ['sort' => 'price', 'page' => 1]
// ]Enable mfilter.debug to log:
key_value format works for most cases