To get list of themes on a Drupal site programmatically, please use following code:
$modulesList = \Drupal::service('extension.list.theme')->reset()->getList();
if (! empty($modulesList)) {
echo "<strong>Themes List:</strong>";
echo "<br/>";
foreach ($modulesList as $moduleName => $moduleObj) {
echo "<br/>";
echo '<strong>Machine Name: </strong>' . $moduleName;
echo "<br/>";
echo '<strong>Humand Readable Name: </strong>' . $moduleObj->info['name'];
echo "<br/>";
echo '<strong>Description: </strong>' . $moduleObj->info['description'];
echo "<br/>";
echo '<strong>Package: </strong>' . $moduleObj->info['package'];
echo "<br/>";
echo "-----------------------------------------------------------------";
}
}
if (! empty($modulesList)) {
echo "<strong>Themes List:</strong>";
echo "<br/>";
foreach ($modulesList as $moduleName => $moduleObj) {
echo "<br/>";
echo '<strong>Machine Name: </strong>' . $moduleName;
echo "<br/>";
echo '<strong>Humand Readable Name: </strong>' . $moduleObj->info['name'];
echo "<br/>";
echo '<strong>Description: </strong>' . $moduleObj->info['description'];
echo "<br/>";
echo '<strong>Package: </strong>' . $moduleObj->info['package'];
echo "<br/>";
echo "-----------------------------------------------------------------";
}
}
Output:
Themes List:
Machine Name: bartik
Humand Readable Name: Bartik
Description: A flexible, recolorable theme with many regions and a responsive, mobile-first layout.
Package: Core
-----------------------------------------------------------------
Machine Name: claro
Humand Readable Name: Claro
Description: A clean, accessible, and powerful Drupal administration theme.
Package: Core
-----------------------------------------------------------------
Machine Name: classy
Humand Readable Name: Classy
Description: A base theme with sensible default CSS classes added. Learn how to use Classy as a base theme in the Drupal 8 Theming Guide.
Package: Core
-----------------------------------------------------------------
Machine Name: seven
Humand Readable Name: Seven
Description: The default administration theme for Drupal 8 was designed with clean lines, simple blocks, and sans-serif font to emphasize the tools and tasks at hand.
Package: Core
-----------------------------------------------------------------
Machine Name: stable
Humand Readable Name: Stable
Description: A default base theme using Drupal 8.0.0's core markup and CSS.
Package: Core
-----------------------------------------------------------------
Machine Name: bartik
Humand Readable Name: Bartik
Description: A flexible, recolorable theme with many regions and a responsive, mobile-first layout.
Package: Core
-----------------------------------------------------------------
Machine Name: claro
Humand Readable Name: Claro
Description: A clean, accessible, and powerful Drupal administration theme.
Package: Core
-----------------------------------------------------------------
Machine Name: classy
Humand Readable Name: Classy
Description: A base theme with sensible default CSS classes added. Learn how to use Classy as a base theme in the Drupal 8 Theming Guide.
Package: Core
-----------------------------------------------------------------
Machine Name: seven
Humand Readable Name: Seven
Description: The default administration theme for Drupal 8 was designed with clean lines, simple blocks, and sans-serif font to emphasize the tools and tasks at hand.
Package: Core
-----------------------------------------------------------------
Machine Name: stable
Humand Readable Name: Stable
Description: A default base theme using Drupal 8.0.0's core markup and CSS.
Package: Core
-----------------------------------------------------------------
No comments:
Post a Comment