Skip to content

Conversation

@cweiske
Copy link
Contributor

@cweiske cweiske commented Feb 10, 2025

This patch adds support for loading templates from multiple directories by specifying comma-separated paths in each of the mask extension configuration options: backend, backend_layouts_folder, content, content_elements_folder, layouts, layouts_backend, partials, partials_backend, preview.

config/system/settings.php:

'EXTENSIONS' => [
    'mask' => [
        'backend' => 'EXT:myext1/Resources/Private/Templates/Backend/Mask,EXT:myext2/Resources/Private/Templates/Backend/Mask',
        'backend_layouts_folder' => 'EXT:myext1/Configuration/Mask/BackendLayouts,EXT:myext2/Configuration/Mask/BackendLayouts2',
        [...]

Use case

We have multiple site packages, one for each root page in the TYPO3 instance.
Each site has own content elements.

Mask currently does not support loading content elements from multiple sources.

Possible solutions

In #487, a custom json loader was suggested, which would solve the multiple-paths problem for backend_layouts_folder and content_elements_folder.
Defining additional frontend rendering paths (content, layout, partials) is possible with TypoScript.

The remaining problem are backend previews and content element icons: backend, layouts_backend, partials_backend and preview - those cannot be adjusted to support multiple paths without modifying mask itself.

Solution

The patches here add support for loading templates from multiple directories by specifying comma-separated paths in each of the mask extension configuration options.

The first commit modifies the json-split-loader, the second adds comma-separated path support for all the other extension configuration options.

Even if the loader can be overridden and some additional paths can be definined with TypoScript, I think it is sensible to add support for multiple paths to all configuration options instead of only those that cannot be changed externally.

I've extended the unit tests for all modified code parts that already had tests.


Related to #487.

@cweiske cweiske force-pushed the json-split-multiple-paths branch from 19488e0 to 48e73ec Compare February 10, 2025 10:07
@nhovratov
Copy link
Collaborator

@cweiske Wow, cool. I will have a look when I have a quiet minute. How does this work when saving elements? Where are they saved, if you have multiple paths?

@cweiske
Copy link
Contributor Author

cweiske commented Feb 10, 2025

How does this work when saving elements? Where are they saved, if you have multiple paths?

The first folder is used: daf1356#diff-88f27f4c106366588303ce7281dcf9e3aea68ad34a208c40cee3ff2d71de4300

$absolutePath = $this->validateFolderPaths($table)[0];

@nitori
Copy link
Contributor

nitori commented Feb 10, 2025

So, what if you edit an element that is not located in that location? is it even possible to edit those?

@cweiske
Copy link
Contributor Author

cweiske commented Feb 11, 2025

So, what if you edit an element that is not located in that location? is it even possible to edit those?

Good point. Currently it will write a new file at the first directory, even if the file already exists in the second dir.
I'll check if I can change this, so that it always modifies an existing file in the second or third dir.

.. for the extension configuration options "backend_layouts_folder"
and "content_elements_folder".
backend, content, layouts, layouts_backend,
partials, partials_backend, preview
@cweiske cweiske force-pushed the json-split-multiple-paths branch from 48e73ec to 291b4fe Compare February 11, 2025 08:23
@cweiske
Copy link
Contributor Author

cweiske commented Feb 11, 2025

I've updated the split loader to overwrite existing files when they exist.
When new files are to be created, they get written into the first directory.

@cweiske
Copy link
Contributor Author

cweiske commented Feb 25, 2025

Now that mask has been deprecated with commit 2869a47, is there a future for this patch?

@nhovratov
Copy link
Collaborator

@cweiske I am not working actively on Mask anymore and I don't have resources to review your patch. Are you using this feature for yourself?

@cweiske
Copy link
Contributor Author

cweiske commented Feb 26, 2025

Yes, I built it because we need and use it in a project.
The project using it will be finished in 2-3 months, so we can also wait if we find issues.

@nhovratov
Copy link
Collaborator

@cweiske Ok, we can maybe think of adding this feature after it has been tested thoroughly in your project. But then you are responsible for any bugs/fixes which may come up.

@cweiske
Copy link
Contributor Author

cweiske commented Jun 20, 2025

We've been using this patch on production for several months now and found no issues.

@nhovratov
Copy link
Collaborator

We've been using this patch on production for several months now and found no issues.

As Mask is now deprecated, I would prefer not to merge a new feature. I think it is feasible to maintain a branch with this feature. Mask won't receive many patches, and if, then only small bugfixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants