Theming

  • Get active theme in Drupal 8

    if you want to get actual active theme name (administration theme included), use:  $activeTheme = \Drupal::service('theme.manager')->getActiveTheme(); if you want your default front end theme, use: $defaultThemeName = \Drupal::config('system.theme')->get('default');  
  • drupal + bootstrap

    Drupal 8 module: Bootstrap 4 Modal

    Are you using Drupal 8 Bootstrap 4 Theme (Barrio) and you want to use Drupal Ajax Dialog? Chances are you might have to do some extra coding just to make that Drupal core modal dialog make it look and feel like a bootstrap modal. Bootstrap 4 Modal module adds new type of dialog that you can use. Example of Drupal core ajax modal dialog: <a class="use-ajax" data-dialog-options="{&quot;width&quot;:400}" data-dialog-type="modal" href="/node/1"> First node displayed in core modal dialog. </a> This link will load drupal node id 1 by ajax on drupal core modal dialog with 400px width   Example of Bootstrap 4 Modal dialog: <a class="use-ajax" data-dialog-options="{&quot;dialogClasses&quot;:&quot;modal-dialog-centered&quot;,&quot;dialogShowHeader&quot;:false}" data-dialog-type="bootstrap4_modal" href="/node/1"> First node displayed in bootstrap 4 modal dialog. </a> This link will load drupal node id 1 by ajax on drupal core modal dialog with modal dialog vertically centered and no modal header.  
  • Drupal 8 Layout Builder + Display Suite Drag & Drop Fix - Display suite

    Layout Builder + Display Suite - Drag & Drop Issue By default, Display Suite layouts are using it's own region attributes like below: {{ title_suffix.contextual_links }} <{{ outer_wrapper }}{{ attributes.addClass('row', 'clearfix') }}> <{{ top_wrapper }}{{ top_attributes.addClass('col-12', 'region-top') }}> {{ top }} </{{ top_wrapper }}> </div> This takes out classes that the layout builder used for the drag & drop feature. The fix is to simply use the region attributes from layout builder like: {{ title_suffix.contextual_links }} <{{ outer_wrapper }}{{ attributes.addClass('row', 'clearfix') }}> <{{ top_wrapper }}{{ region_attributes.top.addClass('col-12', 'region-top') }}> {{ top }} </{{ top_wrapper }}> </div>   Layout Builder + Display Suite - Custom Classes Missing After Layout Region Attribute Fix Although the drag & drop issues was fixed with the above code, it introduces another issue when you want to use the custom classes. I noticed that the regions that used the default layout builder region attributes are not loading the custom classes. To fix it, we should combine the classes from both layout builder region attributes and display suite region attributes. Simply add the rendered class to the region attributes like: {{ title_suffix.contextual_links }} <{{ outer_wrapper }}{{ attributes.addClass('row', 'clearfix') }}> <{{ top_wrapper }}{{ region_attributes.top.addClass('col-12', 'region-top', top_attributes.class|render) }}> {{ top }} </{{ top_wrapper }}> </div>