Intro
Default Parameters
| Parameter | Default | Description |
|---|---|---|
modelClass | modDocument | Class of the model. Options: modDocument, modUser, pbMenu. |
modelType | modDocument | Type of the model. |
modelID | current resource | By default, uses the ID of the current MODX resource. |
context | current resource | By default, uses the context of the current MODX resource. |
resourceId | resource ID | |
userId | user ID | |
parent | List of parents, separated by commas, to search for results | |
resources | List of resources, separated by commas, to display in the results. | |
showHidden | 1 | Whether to show resources hidden from menus. |
showUnpublished | 0 | Whether to show unpublished resources. |
join | [] | Array of join parameters to include additional tables. |
where | [] | Array of additional filtering conditions. |
fields | Comma-separated list of resource fields to include | |
exclude | Comma-separated list of fields to exclude from output | |
sortby | menuindex | Field to sort by |
sortdir | ASC | Sorting direction |
limit | 20 | Number of results to display. 0 means no limit |
offset | 0 | Number of items to skip from the start |
outputSeparator | \n | Separator used between output items |
toPlaceholder | Outputs the result to the specified placeholder | |
return | chunk | Return format. Options: chunk, data, array, or json. |
cache | 0 | Enable snippet result caching |
cacheTime | 3600 | Cache lifetime in seconds |
Template Parameters
| Parameter | Description |
|---|---|
fileElements | Use chunk files instead of database chunks. Default: 0. |
tpl / tplItem | Chunk name used to render individual results. |
tplCurrent | Chunk used only for the current resource ID or the one specified in currentID. |
tplParent | Wrapper chunk for child elements, used when the tree parameter is enabled. |
tplWrapper | Wrapper chunk for all output results. |
tpl.item.default | Default chunk for rendering a result parameter when it is an array. |
tpl.wrapper.default | Default wrapper chunk for a result parameter when it is an array. |
tpl.item.key | Chunk used for a specific result parameter named key, if it is an array. |
tpl.wrapper.key | Wrapper chunk for a specific result parameter named key, if it is an array. |
Pagination
| Parameter | Default | Description |
|---|---|---|
showPagination | 0 | Enable pagination. |
page | 1 | Current page number. |
pageVar | page | URL variable name used for page number. |
pageLink | ?{pageVar}={page} | URL template for generating pagination links. |
sortVar | sort | URL variable name used for sorting. |
sortLink | ?{sortVar}={sort} | URL template for generating sort links. |
sortNames | Custom sorting values, e.g., expensive==price-desc,cheap==price-asc. | |
filterLink | ?{name}={value} | URL template for generating filter links. |
filterSeparator | ; | Separator for filters in the URL. |
updateUrl | 1 | Whether to update the browser URL on sort, pagination or filter change. |
plsTotal | pls.total | Placeholder name for total number of results. |
plsPagination | pls.pagination | Placeholder name for pagination HTML. |
clsPagination | pagination justify-content-center | Classes for the pagination wrapper ($classes in tplPaginationWrapper). |
clsPaginationItem | page-item | Classes for pagination items ($itemClasses in tplPaginationItem). |
clsPaginationItemActive | active | Class for the active pagination item ($itemClassActive). |
clsPaginationLink | page-link | Classes for the pagination link ($linkClasses). |
clsPaginationLinkActive | Class for the active pagination link ($linkClassActive). | |
plsLoadmore | pls.loadmore | Placeholder for the "Load More" button. |
clsLoadmore | btn btn-lg btn-outline-secondary w-100 | Classes for the "Load More" button. |
targetItems | pb-items | ID of the element containing the list of results. |
targetPagination | pb-pagination | ID of the pagination container element. |
targetFilter | pb-filters | ID of the element containing the filter controls. |
targetTotal | pb-total | ID of the element displaying the total number of items found. |
Pagination Templates
| Parameter | Description |
|---|---|
tplPaginationWrapper | @INLINE <ul class="{$classes}" pb-pagination>{$prev}{$items}{$next}</ul> |
tplPaginationItem | @INLINE <li class="{$itemClasses}{if $is_current && $itemClassActive} {$itemClassActive}{/if}"{if $is_current} aria-current="page"{/if}><a href="{$link}" class="{$linkClasses}{if $is_current && $linkClassActive} {$linkClassActive}{/if}" data-page="{$num}">{$page}</a></li> |
tplPaginationPrev | @INLINE <li class="{$itemClasses}{if $is_current} disabled{/if}"><a href="{$link}" class="{$linkClasses}{if $is_current && $linkClassActive} {$linkClassActive}{/if}" data-page="{$num}">{"pb.pagination.prev" | lexicon}</a></li>\ |
tplPaginationNext | @INLINE <li class="{$itemClasses}{if $is_current} disabled{/if}"><a href="{$link}" class="{$linkClasses}{if $is_current && $linkClassActive} {$linkClassActive}{/if}" data-page="{$num}">{"pb.pagination.next" | lexicon}</a></li>\ |
tplLoadmore | @INLINE <button type="button" class="{$classes}" pb-loadmore>{"pb.btn.loadmore" | lexicon}</button>\ |