Skip to content
  1. Extras
  2. PageBuilder
  3. Editor and manager
  4. Manager and events

Manager and events ​

Control panel ​

PageBuilder control panel

Manager component: Components → PageBuilder (namespace pagebuilder, controller index).

In the control panel:

  • Section types (permission pagebuilder_manage_types): UI types, hide and restore built-in JSON types
  • Basket (Pro, flag basket): global basket for deleted sections and table rows
  • Collections tab settings when pagebuilder_collections_* are enabled

The control panel has no list of resources with sections and no link into the resource Sections tab. The editor on the resource form and in the control panel uses one Vue bundle via VueTools. Manager API entry:

assets/components/pagebuilder/connector.php

Data model ​

Main page record: table pb_pages (prefix modx_pb_).

FieldPurpose
resource_idLink to modResource
draft_jsonSection document draft
published_jsonPublished version
revisionDraft revision number (optimistic locking)
published_revisionLast publish revision
publishedon / publishedbyPublish time and user
editedon / editedbyLast draft change

PageBuilder does not overwrite modResource.content.

Page basket stores deleted sections in document.trash. When a draft save has non-empty trashedSectionIds, pbOnBeforeTrash and pbOnAfterTrash fire. The package plugin on pbOnAfterSave writes those sections to pb_basket_items. Another plugin on pbOnAfterSave can read record.draft.trash. Global restore and permanent delete use Pro connector actions (mgr/basket/*).

Resource table data lives in separate pb_* tables (Tables tab).

PageBuilder Pro ​

The pagebuilderpro component adds shared blocks, section journal, catalog examples, breakpoint fields, 27 advanced field types, global basket in the control panel, and Agent API.

Details: PageBuilder Pro. Storefront sections require miniShop3.

Events ​

On install and upgrade the component registers 23 pbOn* events in MODX. The twenty-first is still pbOnAfterMediaCrop. The next two are pbOnBeforeTableGetList and pbOnTableRowSave. Subscribe a plugin under System → Events or use the static plugin from the package.

Registration on boot ​

EventData
pbOnRegisterSectionDefinitionsregistry: SectionRegistry, add custom types
pbOnRegisterFeatureProvidersregistry: FeatureProviderRegistry

Page lifecycle ​

EventWhenData
pbOnBeforeSaveBefore the draft is storedresourceId, document, documentBag, revision, userId, mode=draft, changes
pbOnAfterSaveAfter the draft is storedresourceId, record, userId, mode=draft, changes
pbOnBeforePublishBefore publishresourceId, document, revision, userId
pbOnAfterPublishAfter publishresourceId, record, userId
pbOnBeforeUnpublishBefore unpublishresourceId, record, revision, userId
pbOnAfterUnpublishAfter unpublishresourceId, record, userId
pbOnBeforeTrashBefore trash, only when sections were removedresourceId, sectionIds, document, userId
pbOnAfterTrashAfter the draft save, same idsresourceId, sectionIds, record, userId

documentBag is a PageDocumentBag. A listener replaces the document before saveDraft. changes is the DocumentChangeSet array: addedSectionIds, removedSectionIds, trashedSectionIds, restoredSectionIds, updatedSectionIds, enabledSectionIds, disabledSectionIds. Trash events run inside the same saveDraft. There is no separate trash action.

Copy ​

EventData
pbOnBeforeCopySectionssourceResourceId, targetResourceId, userId
pbOnAfterCopySections+ record

Library (Pro, runtime) ​

Manual registration

The installer does not create pbOnLibraryItemSave. Add the event under System → Events if you need a plugin.

EventWhenData
pbOnLibraryItemSaveAfter a Library item is storedid, name, item

Catalog and fields ​

EventData
pbOnBeforeGetListresourceContext
pbOnAfterGetListresourceContext, items, result (FieldValuesBag, key items)
pbOnFieldValuesCatalog: resourceContext, fieldValues. In mgr/field/options: field, fieldValues
pbOnCheckSectionRequirementrequirement, result (FieldValuesBag, key satisfied)
pbOnCheckSectionVisibilitysection, conditions, result (FieldValuesBag, key visible)

Resource table data ​

EventData
pbOnBeforeTableGetListtable, query, and criteria by reference. The row query reads search, filters, page, limit, and criteria pairs other than table_id
pbOnTableRowSavetable, data by reference, row_id

Frontend render ​

EventData
pbOnBeforeRenderDocumentresourceId, document, pipeline, options
pbOnBeforeRenderSectionresourceId, pipeline with one section, index, options
pbOnGetValuesresourceId, document, values (SectionValuesBag). The snippet when return_values=1, and Public API when include contains values

Crop ​

EventWhenData
pbOnAfterMediaCropAfter the crop file is stored, before the manager responsesourceUrl, sourcePath, path, geometry, result (MediaCropResult)

A plugin appends $result->variants. They land in the image field crops. Example: image field.

Example section registration in a plugin:

php
<?php

use PageBuilder\Section\SectionDefinition;

switch ($modx->event->name) {
    case 'pbOnRegisterSectionDefinitions':
        /** @var \PageBuilder\Section\SectionRegistry $registry */
        $registry = $modx->event->params['registry'];
        $path = $modx->getOption('core_path') . 'components/mypackage/sections/custom.json';
        $payload = json_decode((string) file_get_contents($path), true);
        if (!is_array($payload)) {
            break;
        }
        $payload['source'] = 'code';
        $payload['readOnly'] = true;
        $registry->register(SectionDefinition::fromArray($payload));
        break;
}

Custom JSON definitions must match built-in section schema: fields, chunk, category.

Save, publish, and frontend output ​

The editor writes the draft via connector. Publish copies the snapshot to published_json. The site snippet reads only the published version.