Introduce an XB `PageTemplate` config entity

Created on 3 October 2024, 3 months ago

Overview

This is one of the config entity types XB needs โ€” see ๐ŸŒฑ [META] Configuration management: define needed config entity types Active .

For version 0.2, XB needs to be able to modify the page template (aka page.html.twig).

(See ๐ŸŒฑ Milestone 0.2.0: Experience Builder-rendered nodes Active .)

Product requirement 19. Modify the page template (i.e. global sections) states:

As a builder, I want to modify the page template (i.e. page.html.twig). When I modify the page template, I can place components globally to global regions like navigation, header, footer, etc.

Designs + UX still needed. This is merely laying the technical groundwork inferred from that product requirement, and clarified by talking to @lauriii and @effulgentsia.

There are two distinct needs:

  1. Short-term/for existing sites and themes: ability to use Experience Builder to populate a theme's existing regions (which are essentially "slots" in the page.html.twig template).
  2. Long-term: ability to not use a theme's page.html.twig, and just craft that from scratch

Proposed resolution

๐Ÿ‘ทโ€โ™€๏ธ Details TBD. This issue summary will be updated. ๐Ÿ‘ทโ€โ™€๏ธ

Certainties:

  • >=1 new config entity type(s)
  • โ€ฆ that contain >=1 component trees, for which XB already has a working, and thoroughly validated config schema type: type: experience_builder.component_tree
  • โ€ฆ which allows reliable use of config management ( ๐ŸŒฑ [META] Configuration management: define needed config entity types Active ): these new config entities will declare config dependencies on the XB components that they use, etc.

User interface changes

None.

๐Ÿ“Œ Task
Status

Active

Version

0.0

Component

Config management

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • Needs documentation

    A documentation change is requested elsewhere. For Drupal core (and possibly other projects), once the change has been committed, this status should be recorded in a change record node.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @wim leers
  • Pipeline finished with Failed
    3 months ago
    #299967
  • Pipeline finished with Failed
    3 months ago
    #299969
  • ๐Ÿ‡ธ๐Ÿ‡ชSweden johnwebdev

    I have a question that Iโ€™ve been thinking about around this, maybe a bit early to answer

    Letโ€™s say I have a header region, and I place a Hero component in that region. The Hero component an background image (Media entity)

    How will that work? Letโ€™s say I build the page template locally and then push the config entity to production, there is no guarantee that the media with that ID exists so the default will be broken image when you create a page.

    Thinking loudlyโ€ฆ Should page templates e.g be allowed to save โ€œincompleteโ€ components, or do we need some placeholder feature generic, or specifically for media?

  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland lauriii Finland
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    This is progressing nicely. An incomplete PageTemplate config entity now fails as expected:

    1) Drupal\Tests\experience_builder\Kernel\Config\PageTemplateValidationTest::testEntityIsValid
    Failed asserting that two arrays are identical.
    --- Expected
    +++ Actual
    @@ @@
    -Array &0 []
    +Array &0 [
    +    'component_trees' => Array &1 [
    +        0 => 'Configuration for the region "<em class="placeholder">sidebar_first</em>" (<em class="placeholder">sidebar_first</em>) is missing.',
    +        1 => 'Configuration for the region "<em class="placeholder">sidebar_second</em>" (<em class="placeholder">sidebar_second</em>) is missing.',
    +        2 => 'Configuration for the region "<em class="placeholder">content</em>" (<em class="placeholder">content</em>) is missing.',
    +        3 => 'Configuration for the region "<em class="placeholder">header</em>" (<em class="placeholder">header</em>) is missing.',
    +        4 => 'Configuration for the region "<em class="placeholder">primary_menu</em>" (<em class="placeholder">primary_menu</em>) is missing.',
    +        5 => 'Configuration for the region "<em class="placeholder">secondary_menu</em>" (<em class="placeholder">secondary_menu</em>) is missing.',
    +        6 => 'Configuration for the region "<em class="placeholder">footer</em>" (<em class="placeholder">footer</em>) is missing.',
    +        7 => 'Configuration for the region "<em class="placeholder">highlighted</em>" (<em class="placeholder">highlighted</em>) is missing.',
    +        8 => 'Configuration for the region "<em class="placeholder">help</em>" (<em class="placeholder">help</em>) is missing.',
    +        9 => 'Configuration for the region "<em class="placeholder">page_top</em>" (<em class="placeholder">page_top</em>) is missing.',
    +        10 => 'Configuration for the region "<em class="placeholder">page_bottom</em>" (<em class="placeholder">page_bottom</em>) is missing.',
    +        11 => 'Configuration for the region "<em class="placeholder">breadcrumb</em>" (<em class="placeholder">breadcrumb</em>) is missing.',
    +    ],
    +]
    

    (Also crediting Lauri & Alex.)

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    How will that work? Letโ€™s say I build the page template locally and then push the config entity to production, there is no guarantee that the media with that ID exists so the default will be broken image when you create a page.

    The way this works with similar things now is you would have to do this:

    1. Create the media entity on production
    2. Sync the production database locally
    3. Set up the layout (or whatever config entity referencing the content entity).
    4. Deploy the config and everything works

    This works but is of course very clunky. Feels like a separate issue since it's more of a general problem with config entities that reference config entities rather than XB specific, although agreed it's going to be a common thing people want to do.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #3: @catch is right in #7 and is also right that this is out of scope here, but merits its own issue. For now, let's discuss this on the meta, because this is a challenge affecting multiple of XB's config entity types. See prior discussion at #3444424-4: [META] Configuration management: define needed config entity types โ†’ from >4 months ago, where I link to a PoC that we built >5 months ago that shows a viable way to fix that.

    Let's not discuss that further here ๐Ÿ™

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Will continue on Monday, but this is ready for an initial high-level review. ๐Ÿ‘

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Continuingโ€ฆ

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • First commit to issue fork.
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    A few questions but mostly nits, I think the overall approach is sound.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    @lauriii A review from @longwave surfaced two important questions, and I answered both by adding explicit "warning, future stuff" docs for both. Can you confirm the accuracy of these 2 small paragraphs? ๐Ÿ™

  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland lauriii Finland

    #15: That looks good ๐Ÿ‘ Those are limitations I'm aware of for the current state of XB.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Thanks @lauriii! Incorporated your suggested refinement too ๐Ÿ‘

    All feedback from @longwave has now been addressed, back to him for review.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    I did a (fairly quick/cursory) review of this and couldn't see any obvious problems, just one question in the MR.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Good question/suggestion, @catch! Responded :)

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    The HTTP API follow-up exists: ๐Ÿ“Œ HTTP API to read+write PageTemplate and Pattern config entities Active .

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Merged in upstream and did a trivial search-and-replace to compensate for ๐Ÿ“Œ Replace plus with dot in component config entity IDs Active having landed.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    FYI: ๐Ÿ“Œ HTTP API to read+write PageTemplate and Pattern config entities Active is making good progress and will allow a (client-side) UI to be built, allowing to reuse significant pieces of the existing UX :)

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Follow-up created per @lauriii's feedback: ๐Ÿ“Œ [later phase] [PP-1] Gracefully handle deleted regions in PageTemplate config entities" Postponed .

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    Again only another round of tiny nits, I still think this is a solid base for the desired functionality here.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    Thanks, this looks great now, and unblocks future work. Let's ship it!

  • Pipeline finished with Skipped
    2 months ago
    #312331
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024