Get the FREE Ultimate OpenClaw Setup Guide →

building-blocktypes

npx machina-cli add skill MacareuxDigital/concretecms-skills/building-blocktypes --openclaw
Files (1)
SKILL.md
1.3 KB

Building Block Types

Block types are the fundamental units of content in Concrete CMS. They allow users to add different types of content (text, images, forms, etc.) to pages.

Basic Workflow for Block Type Development

  1. Define the Block Type Directory:
    • If in a package: packages/your_package/blocks/block_handle/
    • If in application: application/blocks/block_handle/
  2. Create the Controller:
    • Create controller.php in the block directory.
  3. Create the View:
    • Create view.php for the public output.
  4. Create Add/Edit Forms:
    • Create add.php and edit.php for the dashboard interface.
  5. Define Database Schema:
    • Create db.xml (Doctrine XML format) to define the block's data table.
    • Refer to the working-with-database skill for the XML format.
  6. Register the Block Type:
    • Install via Dashboard or programmatically in a package install() method.

Reference Documentation

Source

git clone https://github.com/MacareuxDigital/concretecms-skills/blob/main/building-blocktypes/SKILL.mdView on GitHub

Overview

Block types are the fundamental units of content in Concrete CMS, letting editors add text, images, forms, and other content to pages. This skill covers creating and modifying custom block types, including directory structure, controllers, views, add/edit forms, and database schemas, plus how to register and install them.

How This Skill Works

Create the block type under a package or application directory, then build controller.php and view.php for output, add.php and edit.php for the dashboard UI, and define the data model in db.xml using Doctrine XML. Finally, register the block type so it can be installed via the Dashboard or programmatically in the package install() method.

When to Use It

  • You need a custom content block (e.g., testimonials, image gallery) that editors can place on pages.
  • You want to modify how a block type collects data by updating its add/edit forms.
  • You’re packaging a custom block type for reuse across sites via a package.
  • You must define the block's data schema using Doctrine XML in db.xml.
  • You want to install or register a new block type through the Dashboard or a package install() method.

Quick Start

  1. Step 1: Create the block directory under packages/your_package/blocks/block_handle/ or application/blocks/block_handle/.
  2. Step 2: Add controller.php and view.php to define output and behavior.
  3. Step 3: Create add.php, edit.php, and db.xml, then install the block type via the Dashboard or package install() method.

Best Practices

  • Organize the block type under the appropriate directory: packages/your_package/blocks/block_handle/ or application/blocks/block_handle/.
  • Keep a clear block_handle and match file names: controller.php, view.php, add.php, edit.php, db.xml.
  • Define the data model in db.xml using Doctrine XML format per the guidelines.
  • Test installation and rendering in a staging site before production.
  • Document dependencies and references (Form Widgets, Pagerfanta) in your block's docs.

Example Use Cases

  • Testimonial block that displays client quotes with rotation
  • Image gallery block with thumbnails and lightbox
  • Newsletter signup form block integrated into a page
  • Product features block with icons and toggles
  • CTA block customized per page context

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers