5-Minute Quickstart
This walkthrough creates a feature_banner block blueprint and renders it cleanly on a ProcessWire page.
-
Create
site/blocks/feature_banner.yamltitle: Feature Bannerdescription: Highlighted callout banner with primary action link.icon: speakerphonecategory: Marketingrole: elementblockMode: singleallowedParents: [row]presettable: truedynamic: trueadvanced: trueallowWidth: truecolSpan: 12tabs:content:label: Contentfields:heading:type: text_languagelabel: Headingrequired: truesummary:type: textarea_languagelabel: Summary'@fieldset:content_link': ~settings:label: Settingsfields:tone:type: selectlabel: Visual Tonedefault: defaultcolSpan: 6options:default: Default Surfacebrand: Primary Brandinverted: Inverted Dark -
Expose
blocksfromsite/classes/DefaultPage.php(for React / Inertia)<?phpdeclare(strict_types=1);namespace ProcessWire;use Totoglu\Inertia\InteractWithInertia;class DefaultPage extends Page{use InteractWithInertia;/*** @return array<string, mixed>*/public function inertiaWithData(): array{$blocks = Blocks::instance($this);return ['blocks' => $blocks !== null ? $blocks->forPage($this) : null,];}} -
Render the page blocks
import { BlockRenderer } from '../../blocks/BlockRenderer';import type { BlockPageComposition } from '../../blocks/types';export default function Show({ blocks }: { blocks?: BlockPageComposition | null }) {return <BlockRenderer composition={blocks} />;}Place your component at
site/templates/assets/js/blocks/FeatureBannerBlock.tsx.BlockRendererauto-discovers./*Block.tsxfiles and mapsPascalCaseBlock.tsxtosnake_caseblock handles.<?phpdeclare(strict_types=1);namespace ProcessWire;/** @var Page $page */$blocks = Blocks::instance($page);$bodyHtml = $blocks !== null ? $blocks->renderPage($page) : '';// Output deduplicated per-block assets in <head> and before </body>$headAssets = $blocks !== null ? $blocks->assets()->renderHead() : '';$footerAssets = $blocks !== null ? $blocks->assets()->renderFooter() : '';Place your PHP view at
site/templates/blocks/feature_banner.php. -
Validate your blueprints with
blocks:doctorTerminal window php vendor/bin/wire blocks:doctor --json