Skip to content

Instantly share code, notes, and snippets.


Raphael Larrinaga raphaellarrinaga

View GitHub Profile
raphaellarrinaga /
Last active Jul 1, 2020
[Drupal 7 php/config cheatsheet] #tags: drupal7, php, cheatsheet, config

Drupal 7 PHP cheatsheet

Get the NID of the current node

Assuming your code is running for a node page, the methods I see used most often in core/contrib modules are either using menu_get_object() or arg():

if ($node = menu_get_object()) {
  // Get the nid
  $nid = $node->nid;
raphaellarrinaga /
Last active Jul 16, 2020
[GIT cheatsheet] #tags: git, cheatsheet
raphaellarrinaga /
Last active Sep 16, 2020
[Drupal install & config process from scratch] #tags: drupal, drupal8, config

// Create .lando.yml. lando init --source cwd --webroot web --name drupal9 --recipe drupal8 --option php=7.3

Drupal installation & update with phing and composer template

I Create a git repo

II Download composer template

Dll from and see the doc to install with phing in it

raphaellarrinaga /
Last active Feb 25, 2021
[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();
raphaellarrinaga /
Last active Apr 7, 2021
[Drupal 8 Twig cheatsheet] #tags: drupal8, twig, cheatsheet

Drupal 8 Twig cheatsheet

Getting Drupal 8 field values in Twig

Image path: {{ file_url(content.field_name['#items'].entity.uri.value) }}

Image title text: {{ node.field_name.title }}

Entity Reference path: {{ content.field_tags[0]['#url'] }}