Skip to content

Instantly share code, notes, and snippets.

@kalevitan
kalevitan / Blocks.md
Created May 14, 2020 14:39 — 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');
@kalevitan
kalevitan / showhidecontent.html
Created October 18, 2017 20:26
Show/Hide Content with jQuery
[...]
<style>
.content { display: none; }
.content.active { display: block; }
.nav-menu > li.active a { font-weight: bold; }
</style>
<div class="container">
<nav class="nav>
@kalevitan
kalevitan / forecast.php
Created June 6, 2016 20:10
An example of using a PHP wrapper with the Dark Sky Forecast API.
<?php
// Add your API key provided by Dark Sky.
/////////////////////////////////////////
$api = '<YOUR_API_KEY>';
// Add a location (e.g. Asheville, NC).
///////////////////////////////////////
$location = '35.5938,-82.5579';