Skip to content

pbBlocks

Snippet for displaying blocks.

Parameters

ParameterDefaultDescription
blockNameList of blocks separated by commas

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: [
    'id' => 1
]}

Displaying blocks from another resource

php
{'!pbBlocks'|snippet: [
    'resourceId' => 7
]}

or

php
{'!pbBlocks'|snippet: [
    'modelId' => 7
]}

Displaying user blocks

php
{'!pbBlocks'|snippet: [
    'userId' => $modx->user->id
]}

or

php
{'!pbBlocks'|snippet: [
    'modelType' => 'modUser',
    'modelId' => $modx->user->id
]}

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,
    ]
]}

Displaying specific blocks from multiple resources

php
{'!pbBlocks'|snippet: [
    'modelId' => '5,6,7,8',
    'blockName' => 'Hero,About'
]}

or

php
{'!pbBlocks'|snippet: [
    'parent' => 0,
    'blockName' => 'Hero,About'
]}

© PageBlocks 2019-present