On May 4, 2020 . By CodimTh Category: Web Drupal Code snippet that can be used to get status code of a page in Drupal 8. $status = \Drupal::requestStack()->getCurrentRequest()->attributes->get('exception'); if ($status && $status->getStatusCode() == 404){ // TODO: WRITE YOUR CODE HERE } Tags : Drupal 8 Snippets Previous PostForce form element to use specific template in Drupal 8Next PostPass custom variables to twig file in Drupal 8 Comments Add new comment Your name Subject Comment About text formats Restricted HTML Leave this field blank
Comments