Skip to content

Replace click-to-field parser swap with author-placed markers - #56

Open
muzzwood wants to merge 1 commit into
masterfrom
click-to-field-fenom-compat
Open

muzzwood wants to merge 1 commit into
masterfrom
click-to-field-fenom-compat

Conversation

@muzzwood

@muzzwood muzzwood commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

This PR just concerns the experimental "Click to field" feature.

We're no longer swapping out the active parser. This means that some fields need to be manually marked in your template/markup.

Core fields and TVs are now marked in the template (breaking change). Without the parser swap, MagicPreview can't find core fields like the page title or TVs by itself. You now mark them with a new snippet, mpField, placed inside the element that shows the field:

<h1 [[mpField? &name=`pagetitle`]]>[[*pagetitle]]</h1>

With Fenom:

<h1 {'pagetitle' | mpField}>{$_modx->resource.pagetitle}</h1>

The snippet outputs nothing except inside the preview panel, so it's safe to leave in live templates. Sites that relied on core fields and TVs being clickable automatically will need to add it. The setting's description in the manager explains this.

ContentBlocks still works automatically for most fields. Each field is wrapped in an invisible element that makes it clickable. A field template can use the new [[+mpClickToFieldAttributes]] placeholder to put the click target on its own element instead of getting the extra wrapper:

<h2 [[+mpClickToFieldAttributes]]>[[+value]]</h2>
  • Where it works: templates typed into the field's settings, and @FILE and @PDO_FILE template files, including Fenom ones.

  • @PDO_FILE fields: @PDO_FILE templates, the usual way to write ContentBlocks templates in Fenom, aren't wrapped automatically. Add the placeholder to make them clickable:

    <{$level} [[+mpClickToFieldAttributes]] class="headline">{$value}</{$level}>
    

Only the preview panel has click targets. Previews in a new window, and a draft's "View" link, now show a clean page. There's no editor beside them to scroll to anyway.

@muzzwood muzzwood linked an issue Sep 4, 2026 that may be closed by this pull request
MagicPreview no longer replaces the MODX parser during a preview, so Fenom
and other custom parsers render correctly. Core fields and TVs are marked
with the new mpField snippet; ContentBlocks fields keep an automatic
wrapper, or use the [[+mpClickToFieldAttributes]] placeholder in inline,
@file and @PDO_FILE templates. Markers only appear in the preview panel,
are never stored in drafts or cached, and drafts saved by 1.7.x are
cleaned on first read.
@muzzwood
muzzwood force-pushed the click-to-field-fenom-compat branch from f30f972 to 3c87046 Compare September 19, 2026 05:23
@muzzwood
muzzwood marked this pull request as ready for review September 19, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

click to field and fenom breaks output

1 participant