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

[D8][DX] Allow themes to declare dependencies on modules and layout templates #5316

Open
klonos opened this issue Oct 20, 2021 · 4 comments
Open

Comments

@klonos
Copy link
Member

klonos commented Oct 20, 2021

This is the respective issue for https://www.drupal.org/project/drupal/issues/474684 (change record), and part of the #5317 meta-issue.

Parsing .info files for dependency information is already implemented on the modules administration page. Adding support for the same dependencies in theme.info files, and implementing the same behavior on the admin/appearance page, would allow designers building heavily customized themes to make safer assumptions about their target sites.

A theme might require the existence of imagecache to auto-generate variations of a header image. This would be a nice compromise between systems like Wordpress and Joomla!, which give themes much greater control over the functionality of the site, and Drupal's module-centric approach.

Proposed solution

  • Allow themes to add the dependencies to .info files
  • Show these dependencies on admin/appearance, and make it impossible to install without the requirements via UI or command line
  • Make it possible to install dependent modules and layout templates when installing a theme (either manually, or via the Project Browser/Installer)
  • Validation is added to prevent installing themes that depend on uninstalled modules, and prevent uninstalling modules that are depended upon by installed themes. This is implemented at a level that prevents these installs/uninstalls from occurring programatically or via cli (Drush/Drupal Console).

User interface changes

  • Themes listed in admin/appearance will list the modules/layouts they depend on and the ability to install/enable that theme will not be available unless those module/layout dependencies are met.
  • The module descriptions found at admin/modules and admin/module/uninstall will include themes in their "Required by" description.

API changes

Themes will be able to define modules dependencies in their info.yml via the dependencies key.

@stpaultim
Copy link
Member

stpaultim commented Jul 4, 2022

The suggestion that we MIGHT (just speculation right now) move the color module out of core someday (2.x) reminds me why it would be nice if themes could declare dependencies. If this were available now, the Opera theme would almost certainly take advantage of it.

#5667

@laryn
Copy link
Contributor

laryn commented Mar 10, 2024

While working on Gin, I'm running into an issue where we've defined some CSS/JS-related "libraries" within Gin (perhaps misusing hook_library_info() since Gin is not a module) but they aren't available outside of Gin. It could be nice to make Gin dependent on a module that could declare these libraries properly (e.g. Tonic perhaps).

@docwilmot
Copy link
Contributor

they aren't available outside of Gin

Those seem to be quite specific to the theme though. And I believe in either case they are still accessible by calling backdrop_add_library('gin', 'library') from any code.

@laryn
Copy link
Contributor

laryn commented Mar 10, 2024

They don't seem to be working from testing I'm doing in Tonic, which I assumed was because they were declared in a theme, not a module.

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

4 participants