Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX] Allow Modules to Declare Layout Templates as Dependencies #6593

Open
stpaultim opened this issue Jun 9, 2024 · 3 comments
Open

[DX] Allow Modules to Declare Layout Templates as Dependencies #6593

stpaultim opened this issue Jun 9, 2024 · 3 comments

Comments

@stpaultim
Copy link
Member

stpaultim commented Jun 9, 2024

Description of the need

I'm creating a recipe module and would like my recipe to require a specific layout template and automatically enable that layout template as the default layout template.

Apparently, modules can only list other modules as dependencies. If I am wrong about this, let me know.

Proposed solution

Allow modules to declare layout templates as dependencies

Alternatives that have been considered

Allow modules to include layout templates within the module. I am not sure if this is possible already and I think it would be a better idea to simply allow modules to create seperate layout template projects and require them as a dependency.

Additional information

There is a similar feature request for themes.
#5316 Allow themes to declare dependencies on modules and layout templates

Official documentation for the .info file in layouts describes dependencies as:

An array of other modules that your module requires. If these modules are not present, your module cannot be enabled. If these modules are present but not enabled, the administrator will be prompted with a list of additional modules to enable and may choose to enable the required modules as well, or cancel at that point.
https://docs.backdropcms.org/creating-modules

Draft of feature description for Press Release (1 paragraph at most)

Backdrop now includes the ability for a module to declare a dependency on a specific layout template.

@klonos
Copy link
Member

klonos commented Jun 10, 2024

Yeah, I think that any type of project should be able to declare dependency on any other type of project. So that:

  • modules can depend on themes and/or layout templates
  • themes can depend on modules and/or layout templates
  • layout templates can depend on modules and/or themes

If the code where each of that happens is different, then it does make sense to have different issues for these. But if the code is the same, as I am suspecting (the installer module basically), then we might wanna consider consolidating all these into a single request.

@klonos klonos changed the title Allow Modules to Declare Layout Templates as Dependencies [DX] Allow Modules to Declare Layout Templates as Dependencies Jun 10, 2024
@olafgrabienski
Copy link

olafgrabienski commented Jun 10, 2024

I'm creating a recipe module and would like my recipe to

  • require a specific layout template
  • automatically enable that layout template
  • as the default layout template

(I've broken up the first sentence to emphasize how I understand it.)

While I agree with the first and the second feature, I'm skeptical about the third. It might work for new sites but not for existing ones. Existing sites are already using the default layout, and changing this to another template could change its appearance pretty much.

@klonos
Copy link
Member

klonos commented Jun 10, 2024

Yup, downloading and enabling layout templates should be relatively easy to achieve (actually, templates are always "enabled" - but you can hide them from the setting page in admin/structure/layouts/settings). Creating a new layout and using a template for it should also be easy and harmless. However setting the template as the default, or replacing the template of any existing layout should be done with caution. There can be a confirmation step in the installer that could provide the option to do the replacement, but there should be a warning to state that things are likely to break.

So if the module is creating a new layout, and that new layout requires a specific template to work as designed, then that should be OK I guess. This assumes that the template that is required will be used only for layouts provided by that module though. Anything beyond that would need custom logic in order to present confirmation dialogs etc. etc.

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

No branches or pull requests

3 participants