nerdfisch: DevBits

Kleine, aber feine Code-Snippets, nützliche Tweaks und elegante Lösungsansätze aus dem Entwickler-Alltag

09.07.2026 | Holger Weischenberg

Hide HTML comments in Chrome and Firefox browser inspector

Image showing various settings options in a developer tools interface.

 

 

html
browser
debugging
frontend
22.06.2026 | Pascal Crott

Gin: Make use of the simple table

my_module.module
<?php

/**
 * Implements hook_theme_suggestions_HOOK_alter() for table.
 */
function hook_theme_suggestions_table_alter(array &$suggestions, array $variables): void {
  if (empty($variables['attributes']['class'])) {
    return;
  }

  if (is_array($variables['attributes']['class']) && in_array('ief-entity-table', $variables['attributes']['class'])) {
    $suggestions[] = 'table__simple';
  }
}
module
Gin backend theme
copy-paste
templates
22.06.2026 | Mathias Grab

How to enable Twig debug in Drupal

development.services.yml
parameters:
  twig.config:
    debug: true
    auto_reload: null
    cache: false
yml / yaml
twig
debug
11.06.2026 | Michael Ebert

Change the order of local tasks

my_module.module
function my_module_local_tasks_alter(&$local_tasks) {
  if (isset($local_tasks['entity.section_library_template.collection'])) {
    $local_tasks['entity.section_library_template.collection']['weight'] = 110;
  }
    
  if (isset($local_tasks['feeds.admin'])) {
    $local_tasks['feeds.admin']['weight'] = 120;
  }

}

php
routing
local task links
weights
11.06.2026 | Nikolas Kopp

List enabled view modes (view displays) for a bundle of an entity type

getBundlesWithViewmode.php
  private function getBundlesWithViewmode(string $entity_type, string $view_mode): array {
    $bundles = [];

    foreach (\Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type) as $bundle => $info) {
      $view_modes = \Drupal::service('entity_display.repository')->getViewModeOptionsByBundle($entity_type, $bundle);
      if (isset($view_modes[$view_mode])) {
        $bundles[] = $bundle;
      }
    }

    return $bundles;
  }
  
php
entities
view modes
bundles