Skip to content

Instantly share code, notes, and snippets.

View jimconte's full-sized avatar
🏠
Working from home

Jim Conte jimconte

🏠
Working from home
View GitHub Profile
@jimconte
jimconte / TaxonomyTermRenderedEntityBlock.php
Last active October 20, 2021 00:08
A custom Drupal Block for rendering a Taxonomy Term in a configurable view mode.
<?php
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides a block for rendering Taxonomy Terms in a view mode
*
* @Block(
@jimconte
jimconte / seed_derivatives.drush.inc
Last active December 5, 2023 13:23 — forked from typhonius/seed_derivatives.drush.inc
This script can generate image derivatives for Drupal for warming up the filesystem prior to going live. Image derivative generation puts an amount of load on the servers so it images have been migrated from another server with no derivatives, it may be useful to pre-generate using this script.
<?php
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\Condition;
use Drupal\image\Entity\ImageStyle;
use Drupal\file\Entity\File;
/**
* ================================================================
* Implements hook_drush_command().
* ----------------------------------------------------------------
@jimconte
jimconte / ThemeNegotiator.php
Last active May 10, 2022 11:24
A sample class implementation of Drupal 8's ThemeNegotiatorInterface from https://jimconte.com/blog/web/dynamic-theme-switching-in-drupal-8
<?php
/**
* @file
* Contains \Drupal\jcmodule\Theme\ThemeNegotiator
*/
namespace Drupal\jcmodule\Theme;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Theme\ThemeNegotiatorInterface;