Create HTTP Endpoint for View modes/content templates

Created on 12 August 2025, 1 day ago

Overview

The UI will need to show the view modes of all entity types are the opt-ed into XB templating

Proposed resolution

Provide an HTTP API endpoint that will return list of all XB template enabled bundles and their view mode
Until will make the UI to opt-in bundles lets have this hardcode to assume all node types are enabled.
For each mode we should have metadata
Proposed format

$view_modes = [
      'node' => [
        'page' => [
          'full' => [
            // Whether template has auto-save changes. This can be tru even if
            // existing_template is false since we auto-save templates before
            // first publishing without creating a new saved template.
            'auto-save-changes' => TRUE,
            // Where the there is an existing template saved.
            'existing_template' => TRUE,
            // The ID does require an exisitng template because it is based on
            // entity props that can't be changed.
            'template_id' => 'node.page.full',
            // do we need this or can the client just make it?
            'layout_url' => '/xb/api/v0/layout-template/node/page/full/{entity_id',
          ]
        ]
      ]
    ];

We could also flatten it more

$view_modes = [
          'node.page.full' => [
            'entity_type' => 'node',
            'bundle' => 'page',
            'view_mode' => 'full',
            // Whether template has auto-save changes. This can be tru even if
            // existing_template is false since we auto-save templates before
            // first publishing without creating a new saved template.
            'auto-save-changes' => TRUE,
            // Where the there is an existing template saved.
            'existing_template' => TRUE,
            // The ID does require an exisitng template because it is based on
            // entity props that can't be changed.
            'template_id' => 'node.page.full',
            // do we need this or can the client just make it?
            'layout_url' => '/xb/api/v0/layout-template/node/page/full/{entity_id',
      ]
    ];

Probably just depends on what is prefered by the UI

User interface changes

πŸ“Œ Task
Status

Active

Version

1.0

Component

Internal HTTP API

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

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

Comments & Activities

  • Issue created by @tedbow
  • πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA
  • πŸ‡ΊπŸ‡ΈUnited States hooroomoo

    My preference would be the first way (not flat). And yes the frontend can construct the 'layout_url' => '/xb/api/v0/layout-template/node/page/full/ given the response.

    $view_modes = [
          'node' => [
            'page' => [
              'full' => [
                // Whether template has auto-save changes. This can be tru even if
                // existing_template is false since we auto-save templates before
                // first publishing without creating a new saved template.
                'auto-save-changes' => TRUE,
                // Where the there is an existing template saved.
                'existing_template' => TRUE,
                // The ID does require an exisitng template because it is based on
                // entity props that can't be changed.
                'template_id' => 'node.page.full',
              ]
              'teaser' => [
                'auto-save-changes' => FALSE,
                'existing_template' => FALSE,
                'template_id' => 'node.teaser.full',
              ]
            ]
            'article' => [
              'full' => [
                'auto-save-changes' => FALSE,
                'existing_template' => TRUE,
                'template_id' => 'node.article.page',
              ]
              'teaser' => [
                'auto-save-changes' => TRUE,
                'existing_template' => TRUE,
                'template_id' => 'node.article.teaser',
              ]
            ]
          ],
        ];
  • πŸ‡¬πŸ‡§United Kingdom f.mazeikis Brighton
  • πŸ‡³πŸ‡±Netherlands balintbrews Amsterdam, NL

    The issue summary already talks about nodes only, but I just wanted to reinforce that at this stage we're only targeting node bundles, no other entity types are in scope.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    The issue summary already talks about nodes only, but I just wanted to reinforce that at this stage we're only targeting node bundles, no other entity types are in scope.

    FYI this is enforced since https://git.drupalcode.org/project/experience_builder/-/commit/843e7b0b1...

Production build 0.71.5 2024