I'm attempting to get the content type in my page preprocess function...but apparently I'm missing something. What am I doing wrong here? I'm attempting to get the $node variables first - then test from there.
function mytheme_preprocess_page(&$variables) {
$node = \Drupal::routeMatch()->getParameter('node');
switch ($node->getType()) {
case "client":
$variables['attributes']['class'][] = 'clientpage';
break;
case "something_else":
// ...
break;
}
}
$node->getType()
you should check for the correct objectif ($node instanceof NodeInterface) ...