Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Drupal - How to set a default theme programmatically

Looking at ThemeController::setDefaultTheme (the request handler for the /admin/appearance/default route), this should do the trick:

\Drupal::configFactory()
  ->getEditable('system.theme')
  ->set('default', 'machine_name')
  ->save();

Tags:

Theming

8

Installation Profile

Related

Drupal - "admin/content" filters not available anymore Drupal - Redirect after form submission Drupal - Building a search View that respects access control Drupal - Is Drupal Console aimed to replace Drush? Drupal - How do I implement hook_views_query_alter()? Drupal - What is the appropriate way to get items from an entityqueue? Drupal - How do I theme a link? Drupal - How do I print the SQL query of a view in front end? Drupal - Place a block inside a twig template Drupal - Delete a node after X weeks it was created Drupal - How can I programmatically change the active theme? Drupal - How do I get a module path?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy