Skip to content
  1. Extras
  2. PageBuilder
  3. Frontend output
  4. Snippets

PageBuilder snippets

The package ships output snippets and (in Pro) form handlers. Namespace for chunks and sections: pagebuilder.

SnippetPurpose
PageBuilderHTML of published sections for current or given resource
PageBuilderResourceSections from another resource (resource_id required)
PageBuilderSitemapXML sitemap for pages with published sections
PageBuilderUtmSessionUTM from query string into session for section visibility rules
PageBuilderUtmUrlUTM from control panel registry appended to arbitrary URL
PageBuilderTableRowsResource table rows (JSON or chunk)

Pro. Do not call these from a template. The section chunk calls PageBuilderFetchIt:

SnippetPurpose
PageBuilderQuizHandler for quiz section
PageBuilderContactFormHandler for contact_form section
PageBuilderFormBuilderHandler for form_builder section
PageBuilderFetchItRenders the form through Fenom. The chunk passes the handler in snippet

Order on a typical page

  1. PageBuilderUtmSession in shared layout if UTM section rules apply (once per request, before section render).
  2. PageBuilder in template or resource content field.
  3. PageBuilderTableRows separately if a table is output outside data_table section.

For a block from another page (hero from home, FAQ from landing) use PageBuilderResource.

Quiz, lead form, and form builder: add the quiz, contact_form, or form_builder section and install FetchIt. The chunk calls PageBuilderFetchIt, not the handler directly. Direct template calls are not needed.

MODX / Fenom correspondence

PurposeMODXFenom
Page sections[[!PageBuilder]]{'!PageBuilder' | snippet}
Filter sections[[!PageBuilder? &section_types=hero,cta]]{'!PageBuilder' | snippet : ['section_types' => 'hero,cta']}
Another resource[[!PageBuilderResource? &resource_id=42]]{'!PageBuilderResource' | snippet : ['resource_id' => 42]}
JSON for SEO[[!PageBuilder? &return_values=1]]{'!PageBuilder' | snippet : ['return_values' => 1]}
Sitemap[[!PageBuilderSitemap]]{'!PageBuilderSitemap' | snippet}
UTM to session[[!PageBuilderUtmSession]]{'!PageBuilderUtmSession' | snippet}
URL with UTM[[!PageBuilderUtmUrl? &url=/contacts/]]{'!PageBuilderUtmUrl' | snippet : ['url' => '/contacts/']}
Table rows[[!PageBuilderTableRows? &table_key=prices]]{'!PageBuilderTableRows' | snippet : ['table_key' => 'prices']}

Caching

Call PageBuilder and PageBuilderResource uncached ([[!...]] or {'!...' | snippet}). Otherwise MODX may serve HTML without a fresh publish.

PageBuilderUtmSession is also uncached: the session is filled in the same HTTP request as the UTM link visit.

See also