ContentTemplate status should be used to determine if it should be used.

Created on 26 August 2025, 2 days ago

Overview

Right now if a Content exists for a view mode and the bundle has a Component Tree field the content template will take effect.

This will be problem in 🌱 [META] Content templates Active as soon as the UI adds a new ContentTemplate but before it is published it will take effect

Proposed resolution

In `\Drupal\experience_builder\EntityHandlers\ContentTemplateAwareViewBuilder::buildComponents` after the component is loaded it should only be used if the status is true.
So something like

$template = ContentTemplate::loadForEntity($entity, $view_mode);
      if ($template && $template->status()) {
        $displays[$bundle] = $template;
      }

\Drupal\Tests\experience_builder\Kernel\NodeTemplatesTest::testOptContentTypeIntoXb should be updated to test a with the status of the template first false, it should not take effect and then once set to true it should take effect.

Bonus
Additionally it would be great if even though ApiLayoutController won't work with ContentTemplate entities until πŸ“Œ Refactor ApiLayoutController into 2 sub-class to support Content Templates Active in this issue we can still update \Drupal\experience_builder\Controller\ApiAutoSaveController::post to set the status to true on publish. \Drupal\Tests\experience_builder\Kernel\ApiAutoSaveControllerTest::testPost will need to be updated to assert that a ContentTemplate actually has it's status updated.We can't use `ApiLayoutController` in this test but we can still add a ContentTemplate entity using \Drupal\experience_builder\AutoSave\AutoSaveManager::saveEntity

User interface changes

None

πŸ“Œ Task
Status

Active

Version

1.0

Component

Page builder

Created by

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

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024