Skip to content

Instantly share code, notes, and snippets.

View ezeedub's full-sized avatar

Edward Zwart ezeedub

View GitHub Profile
@bdlangton
bdlangton / Blocks.md
Last active October 12, 2023 08:40
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');
@crittermike
crittermike / disable_aggregation.md
Last active February 14, 2022 12:17
Disabling CSS/JS aggregation via Drush in Drupal 7 and Drupal 8

Drupal 7

drush vset preprocess_css 0 --yes
drush vset preprocess_js 0 --yes

Drupal 8

@johnennewdeeson
johnennewdeeson / mymodule.install
Created September 2, 2015 10:21
Rebuild all content node access permissions in an update hook
/**
* Rebuild node access permissions.
* node_access_rebuild(TRUE) claims to be able to do this in batch mode but all it does is set a
* batch. There is no way to process the batch from within an update hook. You could do it using
* a separate drush command but if you only have access to run updb on your production env
* then you need to do all the processing from within the update hook. This gem allows complete
* safe permission rebuild, batched, from within a single update hook.
*/
function mymodule_update_7001(&$sandbox) {
_node_access_rebuild_batch_operation($sandbox);