[later phase] ApiPreviewController must use the previewed route's controller, and override canonical content entity routes' received entity object

Created on 4 December 2024, 15 days ago

Overview

@lauriii observed this:

It looks like the XB preview is now showing global regions but the actual main content is slightly different between the real site and XB. Is there still an additional step needed to render the node content using the display mode? FWIW, if this is difficult to do, it would be fine to handle this in a follow-up issue.

XB:

Actual page:

#3489302-26: Preview entire page not just content area

Root cause analysis by @Wim Leers:

That's because this MR is not rendering the main content block \Drupal\system\Plugin\Block\SystemMainBlock. This MR pretends the component tree for the current Node or Page is the main content, and then lets that "main content" be decorated by blocks — i.e. it still uses BlockPageVariant.

This is good enough for the Page entity introduced by 🌱 [Research] Landing page integration Active , because \Drupal\experience_builder\Entity\PageViewBuilder::alterBuild() only renders the component tree.

#3489302-28: Preview entire page not just content area

Updating ApiPreviewController like that was out of scope in 📌 Preview entire page not just content area Active , this issue is the place to do that.

Proposed resolution

Proposal by @Wim Leers

For Node (and other content entities, and actually when editing the PageTemplate and looking at an arbitrary route), we need to reuse the original route (for editing a content entity that'd be its $content_entity->toUrl('canonical') route/link template) but replace/override/intercept the route parameter with one that reflects the values in the XB UI of the XB field (the component tree) and all other fields.

  • For content entities being edited through XB that means calling the controller with an EntityInterface object with all field values dynamically overridden compared to the saved (published) values. (For Node: \Drupal\node\Controller\NodeViewController::view() with a NodeInterface object.)
  • For arbitrary routes viewed in XB (to edit the regions for the active theme's PageTemplate — see 📌 Add support for global regions Active ), we don't need to do anything: it'd just be pass-through.

#3489302-28: Preview entire page not just content area

User interface changes

  • When editing a Page content entity in the XB UI: zero visual changes
  • When editing a Node content entity in the XB UI: the preview in the XB UI (first screenshot in #3489302-26: Preview entire page not just content area ) looks exactly like the actual page (second screenshot in that same comment). IOW: the entire node.html.twig template shows up, including the author, "submitted by PERSON on DATE", the comments list and comment form.
📌 Task
Status

Postponed

Version

0.0

Component

Page builder

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024