Node object doesn't exist when not logged in

by Paul Canning   Last Updated January 12, 2018 16:07 PM

I am trying to use the preprocess_page hook to add some twig variables.

All worked fine, until I logged out. When I'm logged out, the hooks $variables does not contain a node object.

Sample code:

function MYTHEME_preprocess_page(&$variables) {
  $variables['hero_image'] = '';

  if (!empty($variables['node'])) {
    $node = $variables['node']; // if logged in, this is set, logged out, it's not
    // other code here...
  }

}
Tags : 8 theming hooks


Answers 1


Maybe you should check the anonymous user permisions www.yourwebsite.com/admin/people/permissions/anonymous

Mohammed ATIFI
Mohammed ATIFI
January 12, 2018 15:42 PM

Related Questions





A template choice decision source code

Updated March 07, 2017 19:07 PM