pbResources
A snippet for fetching and displaying MODX resources.
Parameters
| Parameter | Default | Description |
|---|---|---|
includeBlocks | 0 | Attach PageBlocks to each resource. Adds a blocks field to the result. |
blockName | Comma-separated list of block names. If not specified, all blocks will be included. | |
includeTables | 0 | Attach data tables to each resource. Each table is added to the result as a separate field, using the table field name. |
tableName | Comma-separated list of table names. If not specified, all tables will be included. | |
includeFiles | 0 | Attach file galleries to each resource. Each gallery is added as a separate field, using the field name of the gallery-type block. |
fileName | Comma-separated list of gallery names. If not specified, all galleries will be included. |
Examples
Display child resources
php
{'!pbResources'|snippet: [
'tpl' => 'tplResource',
]}Display child resources from specific parents, excluding resources with IDs 9 and 11
php
{'!pbResources'|snippet: [
'parent' => '6,7',
'resources' => '-9,-11',
'tpl' => 'tplResource',
]}Attach blocks, tables, and galleries to each resource
php
{'!pbResources'|snippet: [
'tpl' => 'tplResource',
'includeBlocks' => 1,
'blockName' => 'Hero,About', // Attach only specific blocks
'includeTables' => 1,
'tableName' => 'sizes,seo_list as list', // Rename `seo_list` to `list` in result
'includeFiles' => 1,
'fileName' => 'gallery'
]}
seo_listis the name of the table, but you can rename it in the result usingas, e.g.seo_list as listwill return it under thelistkey.
Add pagination
html
<div id="pb-items">
{'!pbResources'|snippet: [
'tpl' => 'tplResource',
'limit' => 12,
'showPagination' => 1,
]}
</div>
<div id="pb-loadmore" class="d-flex js-center">
{'pls.loadmore'|placeholder}
</div>
<hr>
<nav id="pb-pagination" aria-label="Page navigation">
{'pls.pagination'|placeholder}
</nav>