Skip to content

pbFilters ​

Renders a ready-made filter form for a constructor table. The fields come from the table definition, so the form follows the constructor instead of being written by hand.

[[!pbFilters? &table=`Products`]]

Parameters ​

ParameterDefaultDescription
tableRequired. Table name as it is called in the constructor.
namespaceNamespace of the component owning the table, when it is not pageblocks.
classpb-filterCSS classes on the <form>.
submitFilterCaption of the submit button.
resetResetCaption of the reset link, which points at ?.
toPlaceholderPut the output into a MODX placeholder and return nothing.
showLogPrint the reason for an empty form next to the output; manager-only.

Without table the snippet renders nothing and writes &table is required to the MODX log — with &showLog=`1` that line shows up on the page itself.

Which fields appear ​

Only the fields marked filterable in the constructor. That flag is per field, so the form is controlled from the same place as the table itself — adding a filter does not require touching the template.

Example ​

html
<aside class="filters">
    [[!pbFilters? &table=`Products`]]
</aside>

<div class="results">
    [[!pbList? &model=`PbProduct` &tpl=`productCard` &limit=`12`]]
</div>

From Fenom ​

php
{pb_filters(table='Products')}

Tables belonging to satellite components

pbShop and other satellites keep their tables in the same pb_tables, told apart by namespace. If a table is not found, pass its namespace explicitly.

© PageBlocks 2019-present