Core page builder blocks handle standard headings and grids, yet agencies deploying RISE CRM sites inevitably need custom pricing calculators, CRM-backed lead forms, or branded case-study strips. Writing raw HTML inside generic text blocks breaks editor safety and leads to inconsistent spacing.
MTBuilder lets developers register structured custom blocks and exportable layout templates using clean CodeIgniter 4 views and JSON field schemas.
Decide whether your custom block belongs inside your theme or an extension by reading Building a Custom Theme for PolyCMS on RISE CRM.
| Component Layer | File / Hook Location | Responsibility |
|---|---|---|
| Block Definition | block.json or PHP registry class | Declares slug, category, icon, and inspector field controls |
| Field Schema | JSON controls array | Exposes text, media, select, toggle, and repeater inputs |
| Server View | views/blocks/<slug>.php | Escapes attributes via esc() and outputs semantic HTML |
| Scoped Assets | assets/blocks/<slug>.(css|js) | Enqueues block styles only when the block renders on a page |
| Section Templates | Exported JSON presets | Packages multi-block layouts for 1-click reuse across pages |
Step 1: Register the Block Manifest and Field Schema
Every custom MTBuilder block starts with a deterministic slug, a sidebar group assignment, and a declarative controls schema. Keeping field schemas typed and minimal prevents editors from overriding brand typography while still giving them flexible content slots.
- Place standalone business blocks inside a dedicated extension following Building a Custom Plugin for PolyCMS on RISE CRM, or place visual theme blocks inside your active theme’s blocks/ directory.
- Define block metadata (slug, label, category, icon SVG) and register it on the PolyCMS MTBuilder registry hook during module boot.
- Declare inspector controls using standard types (text, textarea, richtext, media_id, url, select, repeater) with sensible default values.
- Verify the new block appears in the MTBuilder left drawer and renders live preview defaults on drop.
Step 2: Render Sanitized Views and Package Reusable Templates
Never trust raw user attributes in server templates: always escape strings with CodeIgniter’s esc() helper and validate URLs before rendering anchor tags. Once your custom blocks are verified, combine them into full-section presets so marketers launch new pages in minutes instead of rebuilding grids from scratch.
- Create views/blocks/<slug>.php and escape every attribute according to context (html, attr, or url).
- Load block-specific CSS or JS conditionally on page render so unused blocks add zero bytes to unrelated URLs.
- Assemble approved hero, pricing, and FAQ rows inside MTBuilder and click Save as Template to store a reusable JSON preset.
- Review global sidebar regions in Widgets and Sidebars in PolyCMS for RISE CRM to ensure block styles harmonize with widget containers.
Common Pitfalls & Quick Fixes
- Custom Block Missing From MTBuilder Drawer: Confirm your registration hook executes before the builder editor boots and validate JSON syntax in your field schema with no trailing commas.
- Editor Preview Unstyled Compared to Live Page: Enqueue your block stylesheet in both the frontend theme bundle and the MTBuilder editor iframe context.
- Repeater Subfields Lose Values on Save: Ensure every repeater item key uses lowercase alphanumeric identifiers and matches the exact property names expected by your render view.
Frequently Asked Questions
Should custom MTBuilder blocks live in a theme or a PolyCMS plugin?
Place blocks tied strictly to one visual design inside the active theme directory. For reusable business blocks such as CRM lead forms, pricing tables, or API data feeds that must survive theme switches, package them inside a separate PolyCMS plugin.
Can custom MTBuilder blocks query live RISE CRM data?
Yes. Server-rendered block views execute inside the CodeIgniter 4 runtime, allowing them to query approved public models such as knowledge base articles, service packages, or team profiles. Always enforce strict output escaping and cache expensive database queries for fast page loads.
How do I share MTBuilder page templates across multiple RISE CRM sites?
Use the MTBuilder Export Template action to download a portable JSON layout file containing your section structure and default block settings. Import that JSON file into another PolyCMS site via the Template Library as long as matching custom block slugs are registered.
Are custom blocks visible in the PolyCMS Headless REST API?
Yes. MTBuilder stores block types and sanitized attribute payloads in structured JSON, which the Headless API returns alongside pre-rendered HTML fragments. Decoupled frontends can either inject the server HTML directly or map specific block slugs to native frontend React or Vue components.

Leave a Reply