Saturday, October 20, 2018

How to add missing node id in Drupal 8

Add Missing Node id in drupal 8 :- 




By default node id will not be there in the drupal 8. to enable this you have to add this code in your .theme file ->

   function THEMENAME_preprocess_html(&$variables) {  
    // Add node id to the body class.  
    $node = \Drupal::routeMatch()->getParameter('node');  
    if($node) {  
     $variables['attributes']['class'][] = 'node-' . $node->id();  
    }  
   }  

No comments:
Write comments