Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Get Theme details (Name, Regions, Libraries ...)

By editor , 27 September, 2016
Question

How to get theme details programmatically ?
How to get the current theme ?
How to get all regions of the system ?
How to get the all the regions available in the current theme ?
How to get the libraries list of the current theme ?
How to get the base themes list of the current theme ?

Get current theme.

$theme = \Drupal::theme()->getActiveTheme();

Theme name:

$theme_name = \Drupal::theme()->getActiveTheme()->getName();

Theme regions list:

$theme_regions = \Drupal::theme()->getActiveTheme()->getRegions();

Theme libraries list.

$theme_libraries = \Drupal::theme()->getActiveTheme()->getLibraries();

Theme base themes list.

$theme_basethemes = \Drupal::theme()->getActiveTheme()->getBaseThemes();

System regions list.

$theme_name = \Drupal::theme()->getActiveTheme()->getName();
$system_regions_list = system_region_list($theme_name);

Visible system regions list.
$theme_name = \Drupal::theme()->getActiveTheme()->getName();
$system_regions_list = system_region_list($theme_name, $show = REGIONS_VISIBLE);

Tags

  • Drupal 8
  • Code
  • Theming
Preprocess a Field, Change Theming of a field

Comments

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer