Skip to content

Override DXPR Builder templates

DXPR Builder renders its elements in the browser, from templates compiled into the editor. There is no element template you can copy into a theme. The module does ship four Twig templates for its own pages, and you override those the normal Drupal way. This page lists them, explains why element markup cannot be overridden, and points to the routes the module supports instead.

Twig templates you can override

The templates live in the module's templates/ folder:

Template Used for Variables
dxpr-license-info.html.twig The usage summary on the User Licenses and Content items pages, and the License info block used_count, total_count, limit, block_label, total_label, used_label, more_info_link
page--dxpr-builder--media-library.html.twig The page wrapper of the Media Library dialog at /dxpr_builder/media-library the standard page variables
html--dxpr-builder--media-library.html.twig The <html> wrapper of the same dialog the standard html variables
page--people-list.html.twig A starting point for the People page (/admin/people) with a licence summary the standard page variables plus user_license

The first three work as they are. Drupal does not load page--people-list.html.twig from the module. DXPR Builder only adds the page__people_list suggestion and the user_license variable on the People page. To show the summary there, copy the file into your admin theme.

To override a template:

  1. Copy the file from modules/contrib/dxpr_builder/templates/ into the templates/ folder of the theme that renders it. The admin pages and the Media Library dialog use the admin theme. The License info block uses the theme of the region you placed it in.
  2. Edit the copy.
  3. Clear caches with drush cr.

Why element markup cannot be overridden

Each element's markup is a twig.js template in dxpr_builder/templates/, for example elements/alert/alert.twig.html. The build compiles these templates into dxpr_builder/dxpr_templates.js. The editor renders them in the browser and saves the resulting HTML into the field. Two things follow:

  • A changed template needs a rebuild of the editor. Sites that load the editor from the DXPR CDN cannot use a changed template at all.
  • Saved pages keep the HTML they were saved with. A new template only affects elements rendered after the change.

So the module offers no per-site override of element templates. Use one of the routes below.

Supported customisation routes

Goal Route
Reusable layouts for editors Page templates and User templates, both chosen in the builder
Change how elements look Custom CSS in the theme, aimed at your own classes or the az-* classes
Give editors named styles Utility classes from the theme's .info.yml, and custom styles for the text editor
Extra icon sets Icon libraries
New element types Creating custom elements

What's next?

Something wrong or missing on this page? Report it or edit the page.