Skip to content

Instantly share code, notes, and snippets.

View sachbearbeiter's full-sized avatar
❤️

Sachbearbeiter sachbearbeiter

❤️
View GitHub Profile
@sachbearbeiter
sachbearbeiter / theme.php
Created April 8, 2015 08:55
D8: Theming examples: Theme: Global theme variables - get path to the active theme
<?php
\Drupal::theme()->getActiveTheme()->getPath();
?>
<?php
// Load the currently logged in user.
global $user;
// Check if the user has the 'editor' role.
if (in_array('editor', $user->roles)) {
// do fancy stuff
}
?>
@sachbearbeiter
sachbearbeiter / html.tpl.php
Created February 10, 2019 16:21 — forked from pascalduez/html.tpl.php
Drupal 7 — Move $scripts at page bottom
<!DOCTYPE html>
<html<?php print $html_attributes; ?>>
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $head_scripts; ?>
</head>
<body<?php print $body_attributes;?>>
@sachbearbeiter
sachbearbeiter / Blocks.md
Created April 19, 2024 10:24 — forked from davidjguru/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');