Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidjguru/b687a7321f39763b59696c79672a5f3e to your computer and use it in GitHub Desktop.
Save davidjguru/b687a7321f39763b59696c79672a5f3e to your computer and use it in GitHub Desktop.
List of top ten most frequent operations developing with Drupal.

1. Getting config values from the system

1.1 Getting config values from a hook

$slogan = \Drupal::config('system.site')->get('slogan');

1.2 Getting config values from a preprocess function of a template file

e.g. => mytheme_preprocess_node(&$variables))

$variables['slogan'] = \Drupal::config('system.site')->get('slogan');

1.3 Accesing variable from a template file

e.g. => template file node.html.twig

{{ slogan }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment