pbList
Universal lister with built-in pagination. Point it at a model, give it a chunk, get a paginated list — without writing a controller for it.
[[!pbList? &model=`PbResource` &parent=`[[*id]]` &tpl=`chunk:myItem` &limit=`10`]]Parameters
| Parameter | Default | Description |
|---|---|---|
model | PbResource | Model short name, resolved under PageBlocks\App\Models\. An unknown name is logged and renders nothing. |
tpl | Required. Chunk for one row, receives item. Prefix with chunk: for a MODX chunk. | |
parent | Shorthand for "owned by resource N" (model_id = N). | |
parent_type | modDocument | Morph class of the owner, when it is not a resource. |
where | Conditions as JSON: {"template":4} or [["price",">=","100"]]. | |
scopes | published | Eloquent scopes, comma-separated. Pass an empty value to disable. |
orderBy / sortby | menuindex | "menuindex", "menuindex desc" or JSON {"price":"desc"}. |
limit | 10 | Rows per page. |
class | d-flex flex-column gap-3 | CSS classes of the wrapper. |
loadmore | Render a "load more" button instead of relying on page links. | |
loadmoreLabel | Показать ещё | Button caption. |
What it renders
<div class="d-flex flex-column gap-3" id="pb-items"
data-pb-key="pblist_a1b2…" data-pb-total="137" data-pb-last-page="14">
<!-- rows rendered through tpl -->
</div>
<div class="pb-pagination mt-4" pb-pagination>
<!-- numbered links -->
</div>data-pb-key is a hash of the resolved query, cached server-side. Pagination sends that one key back over AJAX, so the browser never sees — and cannot tamper with — the conditions. Without JavaScript the numbered links still work: they carry ?page=N and re-run the snippet server-side.
Examples
Children of the current resource
[[!pbList? &parent=`[[*id]]` &tpl=`chunk:childItem` &limit=`20`]]Another model, filtered and sorted
[[!pbList?
&model=`PbVacancy`
&tpl=`chunk:vacancyCard`
&where=`{"city_id":7}`
&orderBy=`{"published_at":"desc"}`
&limit=`12`
]]"Load more" instead of page numbers
[[!pbList? &parent=`[[*id]]` &tpl=`chunk:childItem` &loadmore=`1` &limit=`9`]]From a Fenom template
Named parameters, Smarty style — space separated, no parentheses and no commas:
{pbList model='PbResource' parent=$modx->resource->id tpl='childItem' limit=10}Here a bare tpl means the file chunk core/App/elements/chunks/childItem.tpl.
A chunk that does not exist renders as nothing
Missing templates are not an error — they produce an empty string and a DEBUG line in the MODX log. An empty list with a non-zero data-pb-total usually means a typo in tpl.