Creating Blocks
Introduction
Adding blocks should stem from your child theme and be included in your seeds so that the original theme structure can be restored if needed. Follow the Seeding Themes documentation to seed your alterations to the blocks. You can edit the blueprints directly in the app/blueprints folder, but it's not recommended if you plan on updating the theme.
From this point forward, it is assumed that you are creating blueprints in your seeds folder and seeding it from there.
Adding Your block to The Builder
Adding your block to the builder and columns group
builder and columns groupTo add your block to the builder group, you'll first need to create your own mixin content blocks within the seeds/blueprints/content/mixins/builder/ folder.
The following assumes you created a custom_block folder inside the above folder. This folder should contain the following files
custom_block_column.yaml
custom_block_column.yamlUsed for the Section builder column blocks
uuid: #Your Unique UUID
handle: Content\CustomBlockColumn
type: mixin
name: Custom Block Column
fields:
column_header:
type: mixin
label: Column Header
source: Content\ColumnHeader
common_fields:
type: mixin
source: Content\CustomBlockCommonFields
hr_1:
type: ruler
column_options:
type: mixin
source: Content\ColumnOptionscustom_block_common.yaml
custom_block_common.yamlCommon fields used within the Section & Column Blocks
custom_block.yaml
custom_block.yamlUsed for to create a Top Level Section block
Once you've created your custom block blueprint files, you'll need to add them to the Section and Column areas which are in the builder.yaml and section.yaml blueprint files respectfully
builder.yaml
builder.yamlsection.yaml
section.yamlOnce done, you should see your block within the builder after you run:
Displaying Block Content
Awesome, your block is in the builder. Now it's time to render it's content. You'll need to create some partials under builder/sections and builder/columns to prep the content for rendering.
builder/sections/custom_block.htm
builder/sections/custom_block.htmThe snippet above includes all the extra Advanced Tab content to get you started.
Next up, creating the column block
builder/columns/custom_block.htm
builder/columns/custom_block.htmThe columns block doesn't depend on any content inside of it, so you can initialize it without any extra content
Adding the blocks to the pages
Now that you've created the blocks, time to reference them in their respective sections
builder/items.htm
builder/items.htmbuilder/sections/section.htm
builder/sections/section.htmThat's it! You've successfully created a custom block. It's a good idea to use folders to organize all your custom blocks.
Last updated