nerdfisch: DevBits

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

30.04.2026 | Mathias Grab

How to get a list of all available contexts by context providers

get_all_available_contexts.php
<?php

$all_available_contexts = \Drupal::service('context.repository')->getAvailableContexts();
php
contexts
services
23.04.2026 | Lothar Ferreira Neumann

Sort render array by custom weight property

sort_by_weight.php
// ...

$build['content_1'] = [
    '#markup' => "content 1",
    '#custom_weight_property' => 10,
];

$build['content_2'] = [
    '#markup' => "content 2",
    '#custom_weight_property' => 5,
];

usort($build, function ($a, $b) {
    return SortArray::sortByKeyInt($a, $b, '#custom_weight_property');
});

The output looks like this:

content 2
content 1

Just a hint:

The custom weight system controls the display order of elements, where lower weight values appear earlier, as shown in the example: content_2 (with weight 5) is rendered before content_1 (with weight 10).
 

php
render arrays
23.04.2026 | Lothar Ferreira Neumann

Add custom text to gin_login with Form Decorator

We will use the form_decorator module to alter the output of the gin_login module to look something like this:
 

An example what the result looks like when using gin_login_text.

 

This DevBit provides a step-by-step tutorial how to get there. 

twig
php
yml / yaml
guides
Gin Login
13.04.2026 | Pascal Crott

Restore AJAX functionality when using Slick Slider and Layout Builder

Uses new Drupal "once" Library without using JQuery (see: https://www.drupal.org/node/3158256).

content-carousel.js
          slick.on('breakpoint', function (e, _) {
            if (settings.isLayoutBuilder) {
              once.remove('ajax', '.use-ajax', _.$slideTrack[0]);
              Drupal.ajax.bindAjaxLinks(_.$slideTrack[0]);
            }
          });
js
ajax
slick slider
layout builder
once
13.04.2026 | Marc Hitscherich

Chrome: Bypass NET::ERR_CERT_INVALID

Issue:

If a website has an invalid SSL certificate there might be no way to bypass the validation warning and access the actual website. Especially in Chrome sometimes the button beneath the error message to explicitly bypass the certificate warning is not available.

Solution:

To access a website despite an invalid certificate in Chrome, place the cursor somewhere on the browser window and try typing »thisisunsafe«.

Chrome
Black magic
browser