Skip to content

Instantly share code, notes, and snippets.

raphaellarrinaga / settings.php
Last active Dec 5, 2018
Drupal 8 development settings file
View settings.php
* @file
* Drupal site-specific configuration file.
* This file may have been set to read-only by the Drupal installation program.
* If you make changes to this file, be sure to protect it again after making
* your modifications. Failure to remove write permissions to this file is a
raphaellarrinaga /
Last active Mar 26, 2020
Bash & admin sys commands
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;