Get Theme details (Name, Regions, Libraries ...) | Drupal 8

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

Submitted by editor on Tue, 09/27/2016 - 10:36
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);

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.