pbBlocks
Snippet for displaying blocks.
Parameters
Parameter | Default | Description |
---|---|---|
modelType | modDocument | Document model |
classKey | pbBlockValue | Table class |
context_key | current resource | By default, the current resource context is used. |
resource_id | current resource | By default, the ID of the current resource is used. |
tpl | Chunk for blocks. By default, it is used from the block itself. | |
sortby | menuindex | Sort field |
sortdir | ASC | Sort order |
limit | 20 | Number of records displayed. 0 - means without limits. |
offset | 0 | Skipping values from the start |
fileElements | 0 | Use file chunks |
outputSeparator | \n | Output format of values. Possible values: data, json |
where | [] | Array of additional parameters for filtering results. |
return | chunk | Output format of values. Possible values: chunk, data or array, json |
Examples
For blocks, it's sufficient to call as follows:
php
{'!pbBlocks'|snippet}
If file chunks are used:
php
{'!pbBlocks'|snippet: [
'fileElements' => 1
]}
Display a single block with id = 1:
php
{'!pbBlocks'|snippet: [
'where' => [
'id' => 1
]
]}
Use conditions for displaying blocks:
php
{'!pbBlocks'|snippet: [
'where' => [
'model_type' => 'modDocument',
'model_id' => $_modx->resource->id,
'context_key' => $_modx->resource->context_key,
'published' => 1,
'deleted' => 0,
]
]}