Skip to content

Instantly share code, notes, and snippets.

@jasonjflaherty
jasonjflaherty / drupal_8_php_cheat.md
Created February 25, 2021 15:56 — forked from raphaellarrinaga/drupal_8_php_cheat.md
[Drupal 8 php/config cheatsheet] #tags: drupal8, php, config, cheatsheet

Drupal 8 PHP cheatsheet

Get current node id

$node = \Drupal::routeMatch()->getParameter('node');
if ($node instanceof \Drupal\node\NodeInterface) {
  $nid = $node->id();
}
@jasonjflaherty
jasonjflaherty / Drupal 8 Include Library with Custom Module
Last active August 25, 2020 22:59
Drupal 8 Include Library with Custom Module
/* add to MODULE_NAME.info.yml */
libraries:
- module_name/mncss
/* add to MODULE_NAME.libraries.yaml */
mncss:
version: "1.x"
css:
theme:
css/styleforms.css: {}
@jasonjflaherty
jasonjflaherty / index.html
Created April 17, 2019 19:25
USWDS Hero Tablet, Mobile and Desktop Grid Review
<section class="usa-hero">
<div class="grid-container">
<div class="grid-row">
<div class="usa-hero__callout rd-hero__callout desktop:grid-col-4 desktop:grid-offset-8 tablet:grid-col-6 tablet:grid-offset-6 grid-col-12 grid-offset-none">
<h1 class="text-base-darker usa-hero__heading"><span class="text-green">Seven</span> Research
Stations and <span class="text-green">81</span> Experimental Forests and Ranges.</h1>
<a class="usa-button usa-button--secondary" href="javascript:void(0)"><small>Learn more about
what we do</small> </a>
</div>
</div>
@jasonjflaherty
jasonjflaherty / jquery-phonetic-name-for-glossary.js
Created December 11, 2018 19:07
Dragon Natural Speaking doesn't work with glossary letters unless they have a phonetic base. Adding the attribute name with the phonetic spelling of the letter helps this.
if(jQuery("#YOURID").length > 0){
jQuery("#YOURID a").each(function(i) {
console.log(this.text()); //show all the letters.
var letter = jQuery(this).text();
if(letter == "a"){
jQuery(this).attr("name","aye");
}
if(letter == "b"){
jQuery(this).attr("name","bee");
}