PageBlocks
Snippet for displaying blocks or tables.
Parameters
Parameter | Default | Description |
---|---|---|
ModelType | Document | Document model |
classKey | pbBlockValue | Table class. Possible values: pbBlockValue, pbTableValue |
tpl | Chunk for blocks. By default, it is used from the block itself. | |
sortby | menuindex | Sort field |
sortdir | asc | Sort order |
limit | 0 | Number of records displayed. 0 - means without limits. |
offset | 0 | Skipping values from the start |
return | data | Output format of values. Possible values: data, json |
fileElements | 0 | Use file chunks |
id | ID of blocks or table. If specified, the where parameter is ignored. | |
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. |
collection_id | 0 | ID of the collection. Used for tables. |
where | [] | Array of additional parameters for filtering results. |
Examples
For blocks, it's sufficient to call as follows:
php
{'!PageBlocks'|snippet}
If file chunks are used:
php
{'!PageBlocks'|snippet: [
'fileElements' => 1
]}
Display a single block with id = 1:
php
{'!PageBlocks'|snippet: [
'id' => 1
]}
Use conditions for displaying blocks:
php
{'!PageBlocks'|snippet: [
'where' => [
'model_type' => 'Document', // MODX\Revolution\modDocument
'model_id' => $_modx->resource->id,
'context_key' => $_modx->resource->context_key,
'published' => 1,
'deleted' => 0,
]
]}
Retrieve tables
php
{'!PageBlocks'|snippet: [
'classKey' => 'pbTableValue',
'collection_id' => 1,
'tpl' => 'name_chunk'
]}