-
-
Notifications
You must be signed in to change notification settings - Fork 28
Block object
Each block in the Blocks collection is a Block object, which has a set of methods you can use in your template or custom block snippets.
Returns an object of all attributes that are stored in the block. Each attribute is a Kirby content field and has access to all of Kirby's field methods.
<?= $block->attrs()->caption()->upper() ?>
Returns a Kirby field object with the main content stored in the block.
<?= $block->content()->kirbytext() ?>
Checks if there's a next block
Checks if there's a previous block
Renders the Block
Returns the unique block ID. This can be used to create hashed links to each block for example.
Returns the index of the block. The index starts at 0 for the first block.
Checks if the current block is the first block
Checks if the current block is the last block
Checks if the current block has the given index
Returns the parent Kirby instance
Returns the next block if available.
Returns a Blocks
collection of all next blocks
Returns the parent Site
, Page
, User
or File
object
Returns the previous block if available
Returns a Blocks
collection with all previous blocks
Returns the Blocks
collection with all siblings
Converts the block to a simple array, which is used for the panel API and also stored in the final JSON from the editor.
Returns the block type. This also refers to the loaded snippet in /site/snippets/editor
A block plugin can load a custom block class for its type. This adds additional possibilities to change the behaviour and API response of a Block
object.