Last active
August 31, 2016 20:30
-
-
Save waako/374689bdd10f133dbec7033e56ce8266 to your computer and use it in GitHub Desktop.
Get value of field from a node inside region
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_preprocess_HOOK() for region templates. | |
*/ | |
function themename_preprocess_region__region_name(&$variables) { | |
// Check if current page is a node. | |
if ($node = \Drupal::routeMatch()->getParameter('node')) { | |
// Check if node has the field site_section. | |
if ($node->hasField('field_site_section')) { | |
$variables['site_section'] = $node->get('field_site_section')->value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment