Skip to content

Instantly share code, notes, and snippets.

@joelsteidl
joelsteidl / MYTHEME.theme
Created Nov 5, 2020
Forcing all menu links to use absolute links in Drupal 8/9
View MYTHEME.theme
<?php
/**
* Implements hook_preprocess_menu().
*
*/
function MYTHEME_preprocess_menu(&$variables) {
// Limit to specific menus for performance.
$menus = ['main', 'footer'];
if (isset($variables['menu_name']) && in_array($variables['menu_name'], $menus)) {
@joelsteidl
joelsteidl / Drupal - httpClient Example
Last active Aug 4, 2018
Guzzle is part of Drupal 8 as Drupal::httpClient();
View Drupal - httpClient Example
<?php
// See https://jobs.github.com/api for documentation.
$client = \Drupal::httpClient();
$params = [
'query' => [
'description' => 'laravel',
'full_time' => true,
]
];
@joelsteidl
joelsteidl / notify.module
Last active Aug 3, 2018
Drupal 8 - Send an SMS when a new node is created.
View notify.module
<?php
// Add Twilio by SDK with composer.
// CLI Command: composer require twilio/sdk.
use Twilio\Rest\Client;
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_ENTITY_TYPE_insert().