Built-in page builder widgets cover headings, buttons, and multi-column grids, but Perfex CRM storefronts and service portals quickly demand custom ROI calculators, PolyStore product carousels, or CRM lead-capture strips. Pasting raw HTML into generic text widgets breaks editor guardrails and introduces fragile inline styles.
MTBuilder in PolyCMS for Perfex CRM lets developers register custom blocks with typed inspector controls, escaped PHP templates, and exportable JSON section presets.
New to the visual editor architecture? Review MTBuilder – Visual Drag-and-Drop Page & Landing Page Builder before registering custom components.
| Extension Layer | Responsibility | Perfex CRM / PolyCMS Standard |
|---|---|---|
| Block Manifest | Registers slug, label, category, and icon | Registered via PolyCMS module hook or theme registry |
| Inspector Field Schema | Defines editable text, media, select, and repeater fields | Typed JSON schema mapped to MTBuilder sidebar inputs |
| Server Render View | Outputs clean semantic HTML without inline CSS | PHP view escaping attributes via html_escape() |
| Scoped Assets | Loads block styles and scripts on demand | Enqueued conditionally only when the block renders on page |
| Section Templates | Packages multi-block hero, pricing, or FAQ layouts | Exportable JSON layout presets reusable across landing pages |
1. Define the Block Manifest and Typed Field Schema
Every custom MTBuilder block starts with a deterministic slug, human-readable category, vector icon, and an inspector field schema. Separating content data from HTML markup keeps non-technical editors from accidentally breaking responsive grid wrappers. When your custom block pulls live catalog items or variant pricing, align URL structures with E-Commerce SEO & GEO in Perfex CRM: PolyStore Variant URLs, Sitemaps & Schema.
- Guard all standalone PHP view files with Perfex’s
defined('BASEPATH') or exit('No direct script access allowed');check. - Declare sensible default values for every schema field so newly dropped blocks preview cleanly in the canvas.
- Use explicit media-picker fields tied to MTMedia rather than asking editors to paste raw image URLs.
2. Render Escaped Views, Scoped Assets, and JSON Templates
On the frontend, MTBuilder passes sanitized block attributes into your PHP render template. Escape every dynamic string and URL strictly, enqueue CSS/JS conditionally so unused blocks add zero Core Web Vitals weight, and feed interactive blocks dynamically using endpoints documented in the PolyCMS REST API Guide. Once a multi-block section looks sharp, export it as an MTBuilder JSON template for 1-click deployment across new landing pages.
- Namespace custom CSS selectors under a block-specific class (such as
.mtb-pricing-matrix) to avoid theme collisions. - Set explicit
widthandheightattributes on rendered images inside block templates to prevent Cumulative Layout Shift (CLS). - Export tested section combinations as reusable JSON templates with clean placeholder copy and zero hardcoded localhost URLs.
Common Pitfalls and Quick Fixes
- Custom block breaks canvas drag-and-drop preview: Avoid printing unclosed HTML tags or inline
<script>blocks inside editor preview mode; initialize JS cleanly onDOMContentLoadedand canvas update hooks. - Block CSS overrides Perfex portal header or sidebar styles: Scope every rule to your unique block wrapper class and remove generic element selectors like
h2orbutton. - Imported JSON template drops images on staging sites: Replace absolute domain image paths inside exported JSON presets with relative media IDs or theme fallback assets.
Frequently Asked Questions
Where should custom MTBuilder blocks live in PolyCMS for Perfex CRM?
Place brand-specific layout blocks inside your active PolyCMS child theme so visual styles stay coupled with the design system, or package cross-site blocks such as Perfex CRM lead forms and PolyStore widgets inside an installable PolyCMS extension module for clean portability across client deployments.
Do custom MTBuilder blocks slow down pages that do not use them?
No, provided you register block stylesheets and scripts through conditional asset hooks. MTBuilder inspects the active page’s block tree before rendering the frontend and enqueues CSS or JavaScript assets only for custom blocks actually present on that URL, preserving fast LCP and INP scores.
Can custom blocks query live Perfex CRM or PolyStore data securely?
Yes. Server-rendered block templates can call authorized PolyCMS models or cached read helpers to display active PolyStore products, categories, or service tiers, while public lead-capture blocks submit through Perfex CSRF-protected endpoints or scoped REST API routes with strict server-side input validation.
How do reusable MTBuilder section templates differ from custom blocks?
A custom block introduces a new schema-driven component with its own PHP template and inspector fields, whereas a section template is an exported JSON composition of existing core and custom blocks that editors insert in one click to standardize hero banners, pricing tables, or FAQs.

Leave a Reply