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);

Comments

moha (not verified)

Tue, 09/08/2020 - 23:11

Thanks for your good article
I have been looking for this for a long time
How can I have a list of all Drupal templates with details like name and image and ...

Add new comment

Plain text

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