
mFilter
Faceted filtering for MODX 3 with SEO URL support


SEO templates generate unique metadata for filter pages.
For each filter combination you can set:
| Column | Description |
|---|---|
| Name | Template identifier |
| Title | Title tag template |
| H1 | Heading template |
| Conditions | When to apply |
| Active | On/off |
| Order | Priority |
| Field | Description |
|---|---|
| Name | For identification in admin |
| Title | <title> template |
| H1 | <h1> template |
| Description | Meta description template |
| Text | SEO text for the page |
| Conditions | JSON with application rules |
| Active | Whether to use the template |
| Order | Priority (lower = higher) |
Conditions define when a template is used:
{
"filters": {
"vendor": ["apple"],
"color": ["*"]
},
"resources": [5, 10]
}| Condition | Description |
|---|---|
["value1", "value2"] | Exact value match |
["*"] | Any value for that filter |
[] or missing | Filter not selected |
{
"filters": {
"vendor": ["apple"]
}
}{
"filters": {
"vendor": ["apple"],
"color": ["*"]
}
}{
"filters": {
"vendor": ["*"]
},
"resources": [5]
}| Placeholder | Description |
|---|---|
{$filters.vendor} | Selected vendor |
{$filters.color} | Selected color |
{$filters.price.min} | Min price |
{$filters.price.max} | Max price |
| Placeholder | Description |
|---|---|
{$resource.pagetitle} | Page title |
{$resource.longtitle} | Long title |
{$resource.description} | Description |
{$resource.id} | Resource ID |
| Placeholder | Description |
|---|---|
{$total} | Found items count |
{$page} | Current page |
| Placeholder | Description |
|---|---|
| `{$filters.vendor | genitive}` |
| `{$filters.vendor | dative}` |
| `{$filters.vendor | accusative}` |
| `{$filters.vendor | instrumental}` |
| `{$filters.vendor | prepositional}` |
| `{$filters.vendor | plural}` |
Conditions:
{"filters": {"vendor": ["*"]}}Title:
{$filters.vendor} — buy | {$resource.pagetitle}H1:
{$filters.vendor}Description:
Buy {$filters.vendor|accusative} online. {$total} items in stock. Delivery.Conditions:
{"filters": {"vendor": ["*"], "color": ["*"]}}Title:
{$filters.vendor} {$filters.color} — buy | {$resource.pagetitle}H1:
{$filters.vendor} {$filters.color|nominative}Conditions:
{"filters": {"price": ["*"]}}Title:
{$resource.pagetitle} from {$filters.price.min} to {$filters.price.max}Conditions:
{"filters": {"vendor": ["apple"]}}Title:
Apple products — buyText:
<p>Full range of Apple products: iPhone, iPad, MacBook and accessories.</p>
<p>Official reseller with manufacturer warranty.</p>Suggested order:
Add noindex: true to conditions:
{
"filters": {
"vendor": ["*"],
"color": ["*"],
"size": ["*"]
},
"noindex": true
}By default canonical points to the page without filters. You can override in the template.
$mfilter = $modx->services->get('mfilter');
$seoBuilder = $mfilter->getSeoBuilder();
$seoData = $seoBuilder->build($resourceId, $filters);
// [
// 'title' => 'Apple — buy',
// 'h1' => 'Apple',
// 'description' => 'Buy Apple online...',
// 'text' => '<p>SEO text...</p>',
// 'canonical' => '/catalog/',
// 'noindex' => false
// ]{if $mfilter.seo.title}
<title>{$mfilter.seo.title}</title>
{/if}
{if $mfilter.seo.h1}
<h1>{$mfilter.seo.h1}</h1>
{/if}
{if $mfilter.seo.description}
<meta name="description" content="{$mfilter.seo.description}">
{/if}
{if $mfilter.seo.noindex}
<meta name="robots" content="noindex, follow">
{/if}
{if $mfilter.seo.text}
<div class="seo-text">{$mfilter.seo.text}</div>
{/if}