pbResources
Flat list of MODX resources. Use it when you need a simple list; for a paginated one use pbList.
[[!pbResources? &parent=`[[*id]]` &tpl=`chunk:resourceItem`]]Parameters
| Parameter | Default | Description |
|---|---|---|
ids | Comma-separated ids. Given ids, the output keeps the order you listed them in. | |
parent | Parent id, or several separated by commas. | |
template | Template id, or several separated by commas. | |
context | Context key, or several separated by commas. | |
visible | 0 | Only resources visible in menus. |
published | 1 | Only published. Pass 0 to include unpublished. |
where | Extra conditions as JSON: {"isfolder":1}. | |
sortby | menuindex | Field to sort by. Ignored when ids is given without it. |
sortdir | asc | asc or desc. |
limit | Rows to return; empty means no limit. | |
offset | 0 | Rows to skip. |
Plus the shared output parameters — tpl, tplWrapper, tplEmpty, outputSeparator — described in Intro.
Examples
Children of the current resource
[[!pbResources? &parent=`[[*id]]` &tpl=`chunk:resourceItem`]]Specific resources, in the given order
[[!pbResources? &ids=`12,7,3` &tpl=`chunk:resourceItem`]]Output order is 12, 7, 3 — not the order the database happens to return.
With a wrapper and an empty state
[[!pbResources?
&parent=`5`
&tpl=`chunk:resourceItem`
&tplWrapper=`chunk:resourceList`
&tplEmpty=`chunk:nothingFound`
&limit=`10`
]]tplWrapper receives the joined rows as output and their count as total:
php
<div class="list">
<h2>Found: {$total}</h2>
{$output}
</div>From Fenom
The same data without the snippet layer:
php
{foreach resources(['parent' => 5, 'limit' => 10]) as $item}
<a href="{$item->uri}">{$item->pagetitle}</a>
{/foreach}