Call to template json file broken if site is in sub-directory

Created on 5 April 2024, 8 months ago
Updated 29 August 2024, 3 months ago

Problem/Motivation

When a website is not at the root of a domain and is instead nested in a subdirectory the custom template.json file specified in the configuration does not look in the correct place. The base URL of the site is ignored and the module attempts to call the file from the root. Because of the validateConfigurationForm checking the user provided path with DRUPAL_ROOT prepended, the subdirectory can also not be added within the configuration form.

Steps to reproduce

  1. Have a site running out of subdirectory. This could be in a multisite or a standalone site. For example the root of the site is: example.com/site1/
  2. Place a template.json file within the site somewhere. Example: themes/custom/theme1/ckeditor5_template.json This file is now accessible at https://example.com/site1/themes/custom/theme1/ckeditor5_template.json
  3. Edit a text format and configure the Template plugin settings. ex admin/config/content/formats/manage/full_html Set the Template Path to /themes/custom/minst/templates/ckeditor5_template.json The file exists and is validated and configuration is saved.
  4. Create a new page with a CKEditor enabled field. Editor fails to load with a message that the template file is not found. The module attempts to call the file at https://example.com/themes/custom/theme1/ckeditor5_template.json and fails to find the file

Proposed resolution

One possible solution could be to modify the configuration form to take the absolute path to the template.json. In my testing this does work for both sites in subdirectories and at the root but because the full site URL is now stored in configuration, this may now require using config_split with this setup if working with multiple environments. A better solution might be needed.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mrdrewkeller

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