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
| Parameter | Default | Description |
|---|---|---|
table | Required. Table name as it is called in the constructor. | |
namespace | Namespace of the component owning the table, when it is not pageblocks. | |
class | pb-filter | CSS classes on the <form>. |
submit | Filter | Caption of the submit button. |
reset | Reset | Caption of the reset link, which points at ?. |
toPlaceholder | Put the output into a MODX placeholder and return nothing. | |
showLog | Print 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.