Skip to content

Instantly share code, notes, and snippets.

View ku-enza's full-sized avatar

Yemoko - Mabika Ntumba ku-enza

  • Kuenza
  • Belgium
View GitHub Profile
@davidjguru
davidjguru / Blocks.md
Created November 12, 2020 17:47 — forked from bdlangton/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@StevenGFX
StevenGFX / twig-tweak.md
Last active March 11, 2025 13:31
Twig Tweak Cheat Sheet
@thamas
thamas / THEMENAME.theme
Last active June 9, 2023 11:57
Display taxonomy term in Drupal Twig template translated
<?php
/**
* Implemets hook_preprocess_node().
*
* Create variable from translated taxonomy term name.
* Code by @tikaszvince.
*/
function THEMENAME_preprocess_node(&$variables) {
/** @var Drupal\node\Entity\Node $node */
@cesarmiquel
cesarmiquel / drupal-8-cheatsheet.md
Last active December 6, 2025 04:14
Drupal 8/9/10 Cheatsheet

Drupal 8/9/10 Cheatsheet

[Update 2024] - Take a look at Drupal at your fingertips. Lot's of great stuff there.

Files, Images and Media

// Load file object
$file = File::load($fid);
@ValeriiVasyliev
ValeriiVasyliev / drupal8-change-view-field-value.md
Created August 19, 2017 08:41
Drupal 8. Change View Field Value

Method 1

/**
 * Implements hook_views_pre_render().
 */
function hook_views_pre_render(&$view) {
  if ($view->name == 'myview') {
    foreach ($view->result as &$row) {
 $row-&gt;field_myfield[0]['rendered']['#markup'] = $row-&gt;field_myfield[0]['rendered']['#markup'] ? t('Yes') : t('No');
name: Modal Form Example
type: module
description: 'Modal Form Example module'
package: Example
version: VERSION
core: 8.x
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm