Error theme drupal

Errors is a simple module that allows you to theme the 403 and 404 pages. Although this is a simple module, you’ll require some basic understanding of HTML/PHP and how to override some theme files.

There is no UI with this module, just use your Theme to theme your templates the way you like it, this provides maximum flexibility.

Installation and configuration
Once you install this module, go to admin/settings/error-reporting and set the following paths:

— 403 : «error/403»
— 404 : «error/404»

To theme both pages you can create the following files in your theme:

— error-403.tpl.php
— error-404.tpl.php

You can also use preprocess to create your own variables:

function mytheme_preprocess_error_403(&$variables) {
  $variables['some_text'] = "Sorry, you don't have access to this page";
  $path = drupal_get_path("theme", "mytheme");
  $variables['image'] = theme("image", $path . "/images/someimage.png");

function mytheme_preprocess_error_404(&$variables) {
  $variables['some_text'] = "Sorry, the page you're requesting does not exist.";

Project information

  • Module categories: Content, Utility
  • Created by lelizondo on 16 September 2011, updated 27 November 2014
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.


  • View all releases

Всем привет. Ставлю на сайт zircon После установки сайт не работает, в админ-панели появляются следующие ошибки: в настройках оформления:
Notice: Undefined property: stdClass::$prefix в функции system_theme_settings() (строка 547 в файле /home/tAtMlZAr2286/
Notice: Undefined index: nucleus в функции system_theme_settings() (строка 575 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции system_theme_settings() (строка 575 в файле /home/tAtMlZAr2286/

На главной в админ-панели:
Notice: Undefined index: nucleus в функции drupal_theme_initialize() (строка 98 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции drupal_alter() (строка 1080 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции drupal_alter() (строка 1080 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции phptemplate_init() (строка 12 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции drupal_alter() (строка 1080 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции drupal_alter() (строка 1080 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции drupal_alter() (строка 1080 в файле /home/tAtMlZAr2286/
Notice: Trying to get property of non-object в функции drupal_alter() (строка 1080 в файле /home/tAtMlZAr2286/

В чем причина?
P.S. ссылки на сайт удалил.

  • Есть вопрос
  • Решение проблем

In the web development world, developers often come across situations where site owners complain about the simplicity of HTTP error pages (Access Denied, Page Not Found, etc) that are shown to end users, especially when business competitors are being very creative in the development and design of the HTTP error pages. Take a look at these 404 pages for an idea of how beautiful they can look. Also check out this HTTP 404 page from Google.

This is true for Drupal as well, as Drupal’s error pages are very simple and to the point. However, Drupal addresses the end-user’s requirements quite well, allowing site builders and developers to customize these error pages out of the box. Along with that, it also provides ways to alter these pages.

Let’s get into the core of customizing these pages.

The Basics

We really need to focus on the word ‘Page’ in the term ‘HTTP error page’. Because an HTTP error page is always a ‘page’. Period!

In Drupal, It can be a Node page, View Page Display, Panel page, Custom Route (URL), etc.

Out Of The Box

Drupal creates some custom Routes (URLs) in the system.routing.yml file

  path: '/system/401'
    _controller: 'DrupalsystemControllerHttp4xxController:on401'
    _title: 'Unauthorized'
    _access: 'TRUE'

  path: '/system/403'
    _controller: 'DrupalsystemControllerHttp4xxController:on403'
    _title: 'Access denied'
    _access: 'TRUE'

  path: '/system/404'
    _controller: 'DrupalsystemControllerHttp4xxController:on404'
    _title: 'Page not found'
    _access: 'TRUE'

The above routes create error markups which are rendered whenever a user tries to access pages on the site which either don’t exist or are not authorized to be accessed by users.

class Http4xxController extends ControllerBase {

   * The default 401 content.
   * @return array
   *   A render array containing the message to display for 401 pages.
  public function on401() {
    return [
      '#markup' => $this->t('Please log in to access this page.'),

   * The default 403 content.
   * @return array
   *   A render array containing the message to display for 403 pages.
  public function on403() {
    return [
      '#markup' => $this->t('You are not authorized to access this page.'),

   * The default 404 content.
   * @return array
   *   A render array containing the message to display for 404 pages.
  public function on404() {
    return [
      '#markup' => $this->t('The requested page could not be found.'),


So this is how Drupal creates ‘Page Not Found’ and ‘Access Denied’ errors out-of-the-box.

Customizing Error Messages

What Drupal provides out-of-the-box is quite simple, and this is the reason it also offers ways by which you can alter error pages and show your creativity.

In this post, we will see two methods by which we can change the error messages/pages:

Method 1: The Drupal Configuration method

First of all, we need to create a page. To do that, follow the steps below:

  • Log in to your Drupal site as administrator.
  • Create a content type called ‘error pages’. (Optional: You can use an existing one as well).
  • Create a node page with ‘error pages’ content type. This node page will act as our error page. (Remember the idea of error messages being basically a page?)
  • Add the content and style it as per your requirements.

Now, we need to use the node page as our error page. To do that, follow the steps below:

  • Log in to your Drupal site as administrator.
  • Go to url ‘/admin/config/system/site-information’.
  • Under the Error Pages section of the above URL, mention your new node page URL.


That’s it, you just configured the error pages via the Drupal UI, where the content of error pages will be determined by how you have configured your Node Content.

Method 2: The Programmatic Method

Apart from configuring the error pages from the Drupal UI, we can use ‘hook_theme_suggestions_HOOK_alter()’ and suggest TWIG templates to Drupal against the error pages. Let’s see how we can do that:

  1. Implement a ‘hook_theme_suggestions_HOOK_alter()’ in your theme file.
  2. This hook will catch error messages and tell Drupal to use a TWIG against this error page.
  3. Place the error-specific TWIG file in your theme’s template directory.

I am listing two ways/functions below by which we can suggest error-specific TWIG templates to Drupal. (If you know of more ways to catch these errors, do share your thoughts in the comments.)

Function 1:

 * Implements hook_theme_suggestions_HOOK_alter().
function THEMENAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {

  $route_name = Drupal::routeMatch()->getRouteName();
  switch ($route_name) {
    case 'system.401':
      // Unauthorized Access.
      $error = 401;

    case 'system.403':
      // Access Denied.
      $error = 403;

    case 'system.404':
      // Page Not Found.
      $error = 404;
  if (isset($error)) {
    $suggestions[] = 'page__' . $error;

Function 2:

 * Implements hook_theme_suggestions_HOOK_alter().
function THEMENAME_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  // Get Request Object.
  $request = Drupal::request();

  // If there is HTTP Exception..
  if ($exception = $request->attributes->get('exception')) {
    // Get the status code.
    $status_code = $exception->getStatusCode();
    if (in_array($status_code, array(401, 403, 404))) {
      $suggestions[] = 'page__' . $status_code;

The next step after adding one of the above functions to your code is to add the TWIG templates to your theme and format the HTML in it.

So this is how Drupal allows us to configure HTTP error pages via configuration and code. And the smart move for you will be to not wait any more and jump into revamping your HTTP error pages, showing your competitors how creative you can be.

День добрый

У меня есть готовый проект. Залил базу, закинул файлы сайта, все ок, сайт открылся. Но стоило мне зайти в админку по пути адрес_сайта/user тема пропала, то есть уже на этапе авторизации я увидел только html разметку без стилей. Тоже самое с сайтом. Мало того, что не видит тему, он еще и отображает теперь только Главная, название сайта и «выход», вобщем голый хедер. Если зайти в структуру — блоки, сначала показывал сообщение, что такой-то блок отключен т.к. ему задан неверный регион или область, потом пропало, но все блоки отключенные висят.
Структура каталогов для сайта такая «корневая папка/sites/папка_сайта/themes/имя_моей_темы»

Этой темы в админке нет, хотя когда я зашел первый раз в Блоки, то увидел вкладку с названием моей темы(как раз на ней все блоки отключены), но после включения и отключения стандартных тем, она исчезла.

Вопрос. Почему сначала тема была видна, но после авторизации пропала? Как правильно подключить эту тему к сайту, чтобы она была в админке и корректно отображалась?

Перед заливкой сайта все таблицы с кэшем в базе почистил.
В отчетах нет никаких ошибок, кроме того, что требуется обновление некоторых пунктов.

This error occurs when you add custom javascript to your theme. Add the following dependencies to your theme.libraries.yaml file to fix it. 

    js/MYJS.js: {}
      css/MYCSS.css: {}
    - core/jquery
    - core/drupal

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!

Create an account to follow your favorite communities and start taking part in conversations.


I am a beginer to drupal 8 theming, I was trying to add a custom theme, but it is not showing up in the apperance section

I have already cleared the cache and enabled debugging

Here is a screenshot of my drupal 8 apperance tab

r/drupal - Drupal 8 custom theme not showing up

Here is the screenshot of my file

r/drupal - Drupal 8 custom theme not showing up

Drupal custom theme info.yml file

Pls help.


level 1

Please note:

The name should start with an alphabetic character, can contain numbers and underscores, but not hyphens, spaces or punctuation. The name will be used by Drupal in forming various functions in PHP and therefore it has the same limitations. (this is still valid in D8, not sure why they haven’t included it in the D8 documentation)

Try again to replace all the hyphen with an underscore in the folder but also the filename, I think you forgot to change it at one point.

level 1

Try replacing all of the hyphens with underscores,

Each individual theme is contained in a directory named after the theme itself. For example fluffiness/. The name must be all lowercase, start with a letter, and uses an underscore (_) instead of spaces.

level 2

And does that include renaming the file folder too?

level 2

Underscore for some reason crashes the whole website, I tried that before unfortunately

About Community

Subreddit Icon

The place for news, articles, and discussion regarding Drupal and Backdrop, one of the top open source (GPL) CMS platforms powering millions of websites and applications, built, used, and supported by a diverse community of people worldwide.

More Info: and


No products in the cart.


It’s happened to all of us who use Drupal. We’ve installed a new theme or module and our beautiful homepage now looks like this:


Here are ways you can try to solve this problem and get your site back online.

These solutions are a good place to start but none of them will work for everyone. The right solution for your site will depend on which version of Drupal you’re using, what modules and themes you have installed and which part of the site is broken.

Solution 1: Disable via the admin

You can try to visit the admin area directly by using URLs. For example, you could try to add /admin/ to your site’s URL.

If this works, you can disable the theme or module directly from the admin area. However, this won’t work if you aren’t logged into the site,

Solution 2: Disable the files

You can disable themes and modules via FTP. This process works best with modules. With themes, it works only with Drupal 6. With D6, by breaking the Danland folder, Drupal should ignore the theme and revert back to Bartik. This will allow you to login again.

In this example, the Danland theme has thrown an error and I need to disable it. Here’s the process:

  • Login to the Drupal site via FTP.
  • Browse to the /site/all/themes/ folder. This is the normal Drupal folder for installed themes, but you can also get a hint on where your problem is by looking at the error message on your site:


  • Rename the themes folder. In this case, you can rename the /danland/ folder to /danland-error/

Solution 3: Re-upload the files

If Solution 2 doesn’t work for you, what you can do next is this:

  • Leave the broken copy of your theme or module in the re-named folder.
  • Go to and download a fresh copy of the theme or module that is broken.
  • Upload the fresh copy of the theme or module to replace the one that you just disabled.

Note: this will only work for themes and modules that are available on, not for custom ones.

Solution 4: Disable via settings.php

This only work for themes:

  • Go to the settings.php file for your site. This is often located in your /sites/default/ folder.
  • Open the file and look for the line which says: # $conf[‘theme_default’] = ‘garland’;
  • Remove the # from this line.
  • Save the file.

That should make Garland into your site’s default theme. You’ll be able to login to your site again and disable the broken theme.

Solution 5: Disable via the database

  • Login to your Drupal database. In this example, I got access to the database by using PHPMyAdmin from the hosting company.
  • Look for the system table in the database.


  • Search through the system table to find the theme or module:


  • You can disable the theme or module from here, by changing the status field from a 1 to a 0.


Please note

  • If your error message isn’t showing a path to the /sites/, you may not have a problem with a theme or module but with another part of your site.
  • If your site simply shows you a blank page, you may need to either try and roll back the latest changes to your site, or
  • Please tell me you didn’t forget the golden rule of running a site: BACKUP! BACKUP! BACKUP! BACKUP! BACKUP! Check to see if a backup of your site is available.

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve’s work straddles the line between teaching and web development.


You have already reported this

Понравилась статья? Поделить с друзьями:
  • Error the username or password you entered is incorrect lost your password перевести
  • Error the user you are trying to reach
  • Error the user is banned from this guild
  • Error the update operation document must contain atomic operators
  • Error the update attempt