Skip to content

Block

The Block class is used to create blocks within a resource/user, allowing you to organize fields into logical groups.

Available methods:

MethodDescription
chunk(string $chunk)Sets the chunk to which the block will be linked
title(string $title)Sets the block title.
description(string $description)Sets the block description.
fields(array $fields)Defines the list of fields within the block.
group(string $group)Adds a block to a group.
permissions(array $permissions)Controls where the element is shown based on conditions.
Permissions
RuleDescription
resourceComma-separated list of resource IDs. Block is shown only on these resources.
parentParent resource ID(s). Block is shown only for children of these parents.
templateTemplate ID(s). Block is shown only on resources with these templates.
userUser ID(s). Block is shown only for these users.
user_groupUser group ID(s). Block is shown only to users in these groups.

Example usage:

php
Block::make('Main') // name = Main, title = Main, chunk = main
    ->description('Basic resource data')
    ->fields([
        Field::make('title')->label('Title'),
        Field::make('content')->type('textarea')->label('Content'),
    ]);
php
Block::make('Hero') // name = Hero, title = Hero
    ->chunk('hero')
    ->fields([
        Field::make('title')->label('Title'),
        Field::make('content')->type('textarea')->label('Content'),
    ]);
php
Block::make('Hero') // name = Hero, title = Hero
    ->chunk('hero')
    ->description('Basic resource data')
    ->group('Home')
    ->permissions([
        'resource' => '6,7,8',
        'parent' => '1',
        'template' => '2',
        'user' => '1,2',
        'user_group' => '1,2'
    ])
    ->fields([
        Field::make('title')->label('Title'),
        Field::make('content')->type('textarea')->label('Content'),
    ]);

© PageBlocks 2019-present