Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By Mschudders on
Hello guys,
In Drupal 8 I am trying to install a theme programmatically.
I try to do this via a custom module and my ***.info.yml file looks like:
name: Setup site
type: module
core: 8.x
dependencies:
- ctools
themes:
- adminimal_theme
But when I install this module, my theme doesn't get installed.
What am I missing here ?
It works perfectly for modules (ctools in this example.)
Kind regards
Michael
Comments
See also this StackOverflow
See also this StackOverflow question.
The goal for a theme is to be module independent - and this also goes the other way around. Modules can't have dependencies on themes and themes can't have dependencies on modules.
Maybe try working with an install profile?
Hopefully this will change
Hopefully this will change and themes can have dependancies (as they should be able to have) https://www.drupal.org/node/474684
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
You can use ***.install file
You can use ***.install file with this:
And to set as default:
And to set as default:
\Drupal::service('theme_handler')->setDefault('mytheme');
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
If you get this exception
If you get this exception
RuntimeException: Recursive router rebuild detected. in Drupal\Core\Routing\RouteBuilder->rebuild() (line 121 of core/lib/Drupal/Core/Routing/RouteBuilder.php)
you might want to consider moving the code to hook_modules_installed(). Like this: