pbFilters
A snippet for rendering filters based on data fields (e.g., brand, size, price, etc.).
Parameters
| Parameter | Default | Description |
|---|---|---|
classKey | modResource | The class of objects to filter |
filterFields | — | Comma-separated list of fields to filter by (e.g., brand,price,size) |
tplWrapper | @FILE chunks/filters/wrapper.tpl | Wrapper template for all filters |
tpl.wrapper.default | @INLINE <div class="pbfilter-group">{$items}</div> | Default wrapper template for a single filter group |
tpl.item.default | @FILE chunks/filters/checkbox.tpl | Default template for a single filter item (checkbox by default) |
Custom Templates for Fields
You can override templates for specific fields using the following parameters:
| Parameter | Description |
|---|---|
tpl.wrapper.{field} | Wrapper template for a specific filter group (e.g., tpl.wrapper.brand) |
tpl.item.{field} | Item template for a specific filter field (e.g., tpl.item.size) |
If a field-specific template is not provided, the default templates will be used (tpl.wrapper.default and tpl.item.default).
Usage Example
php
{'!pbFilters' | snippet: [
'fieldName' => 'products',
'filterFields' => 'price,category,brand,size,color',
// price — range input
'tpl.item.price' => '@FILE chunks/filters/price.tpl',
// brand — select
'tpl.wrapper.brand' => '@FILE chunks/filters/select.tpl',
'tpl.item.brand' => '@INLINE <option value="{$value}">{$name}</option>',
// size — radio buttons
'tpl.item.size' => '@FILE chunks/filters/radio.tpl',
]}Integration with pbResources (or similar snippet)
To make filters work correctly, the snippet that renders the result list should also include the same filterFields:
php
{'!pbResources' | snippet: [
'fieldName' => 'products',
'filterFields' => 'price,category,brand,color,size',
'tpl' => '@FILE chunks/product.tpl',
'toPlaceholder' => 'pls.products',
'limit' => 12,
'showPagination' => 1,
]}