Skip to content

Intro

Default Parameters

ParameterDefaultDescription
modelClassmodDocumentClass of the model. Options: modDocument, modUser, pbMenu.
modelTypemodDocumentType of the model.
modelIDcurrent resourceBy default, uses the ID of the current MODX resource.
contextcurrent resourceBy default, uses the context of the current MODX resource.
resourceIdresource ID
userIduser ID
parentList of parents, separated by commas, to search for results
resourcesList of resources, separated by commas, to display in the results.
showHidden1Whether to show resources hidden from menus.
showUnpublished0Whether to show unpublished resources.
join[]Array of join parameters to include additional tables.
where[]Array of additional filtering conditions.
fieldsComma-separated list of resource fields to include
excludeComma-separated list of fields to exclude from output
sortbymenuindexField to sort by
sortdirASCSorting direction
limit20Number of results to display. 0 means no limit
offset0Number of items to skip from the start
outputSeparator\nSeparator used between output items
toPlaceholderOutputs the result to the specified placeholder
returnchunkReturn format. Options: chunk, data, array, or json.
cache0Enable snippet result caching
cacheTime3600Cache lifetime in seconds

Template Parameters

ParameterDescription
fileElementsUse chunk files instead of database chunks. Default: 0.
tpl / tplItemChunk name used to render individual results.
tplCurrentChunk used only for the current resource ID or the one specified in currentID.
tplParentWrapper chunk for child elements, used when the tree parameter is enabled.
tplWrapperWrapper chunk for all output results.
tpl.item.defaultDefault chunk for rendering a result parameter when it is an array.
tpl.wrapper.defaultDefault wrapper chunk for a result parameter when it is an array.
tpl.item.keyChunk used for a specific result parameter named key, if it is an array.
tpl.wrapper.keyWrapper chunk for a specific result parameter named key, if it is an array.

Pagination

ParameterDefaultDescription
showPagination0Enable pagination.
page1Current page number.
pageVarpageURL variable name used for page number.
pageLink?{pageVar}={page}URL template for generating pagination links.
sortVarsortURL variable name used for sorting.
sortLink?{sortVar}={sort}URL template for generating sort links.
sortNamesCustom 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.
updateUrl1Whether to update the browser URL on sort, pagination or filter change.
plsTotalpls.totalPlaceholder name for total number of results.
plsPaginationpls.paginationPlaceholder name for pagination HTML.
clsPaginationpagination justify-content-centerClasses for the pagination wrapper ($classes in tplPaginationWrapper).
clsPaginationItempage-itemClasses for pagination items ($itemClasses in tplPaginationItem).
clsPaginationItemActiveactiveClass for the active pagination item ($itemClassActive).
clsPaginationLinkpage-linkClasses for the pagination link ($linkClasses).
clsPaginationLinkActiveClass for the active pagination link ($linkClassActive).
plsLoadmorepls.loadmorePlaceholder for the "Load More" button.
clsLoadmorebtn btn-lg btn-outline-secondary w-100Classes for the "Load More" button.
targetItemspb-itemsID of the element containing the list of results.
targetPaginationpb-paginationID of the pagination container element.
targetFilterpb-filtersID of the element containing the filter controls.
targetTotalpb-totalID of the element displaying the total number of items found.

Pagination Templates

ParameterDescription
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>\

© PageBlocks 2019-present