ContentBlocks ContentBlocks 2.x Developer Architecture
Depending on your goals, you will touch different parts of ContentBlocks.
Table of Contents
Client-side structure
assets/components/contentblocks/js/
core/ ContentBlocks.js, Elements/, Collections/, Utilities/
inputs/ One file per input type (extends ContentBlocks.Input)
plugins/ One file per plugin (extends ContentBlocks.Plugin)
Key classes
- ContentBlocks — main initializer
- Canvas, Layout, Column, Block — UI element hierarchy
- Input — base class for input types
- ContentBlocks.Store — reactive data store
- ContentBlocks.Dispatcher — event system
See Canvas Structure.
Configuration
Block, layout, and canvas definitions are JSON files loaded from config directories. Templates are resolved at render time. See Blocks and Templating.
Server-side content building
Building pages programmatically? See Building Content in PHP for a set of fluid PHP interfaces that turns code into canvases.
Please don’t manually build JSON or write directly to the database anymore.
Server-side rendering
RenderService orchestrates template resolution and parsing. See Parser and Rendering and Data Flow.
Database
Generally, the database is abstracted away, and you would not touch it directly in a normal integration. Using the provided PHP API instead ensures backwards (and forwards) compatibility with core and other extensions.
| Table | Purpose |
|---|---|
cbCanvas |
Canvas per principal (principal_type, principal_id, principal_field) |
cbCanvasLayout |
Layout instances (layout_key, position, title, data, publishing fields) |
cbCanvasBlock |
Block instances (block_key, column_key, position, parent_block, repeater_key, data) |
Legacy v1 tables (cbField, cbLayout, cbTemplate, etc.) are deprecated. See Database and Legacy Tables.