Created
January 30, 2015 10:18
-
-
Save sachbearbeiter/0213ea70dd1d258fdafc to your computer and use it in GitHub Desktop.
D8: Get the current user ID in theme file and set a variable via MYTHEME_preprocess_page to use it in page.html.twig.
This file contains 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
{# isAdmin? #} | |
{% if UserID == '1' %} | |
{{ kint() }} | |
{% endif %} |
This file contains 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
/** | |
* Implements hook_preprocess_HOOK() for page templates. | |
*/ | |
function MYTHEME_preprocess_page(&$variables) { | |
$UserID = $variables['user']->id(); | |
$variables['UserID'] = $UserID; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment