Drupal 8 Theming with Twig
上QQ阅读APP看书,第一时间看更新

Reviewing the new admin interface

Our local instance of Drupal 8 is similar to Drupal 7 when first viewing the site. You will note the default Bartik theme with the friendly Drupal drop logo and a tabbed main menu. It is here though where the similarities stop. Drupal 8 has been reworked from the ground up, including a brand new responsive layout and admin menu.

Exploring the admin menu

One of the nice new features of Drupal 8 is the rebuilt admin menu. Everything has been moved under the Manage menu item. The admin menu itself is responsive and will change from text and icon to icon only, as soon as the browser is resized to tablet screen size.

The admin menu can also be pinned to the left side of the window by clicking on the arrow icon to the right of the Help menu item.

The flexibility of the new admin menu enables the admin user to manage Drupal 8 websites from the browser or a tablet or a smartphone very easily.

Previewing the interface

Taking a closer look at the menu items contained in our admin menu, we begin to see some differences in how things are named and may wonder where to find once familiar settings and configurations. Let's quickly walk through these menu items now so that it is easier to find things as we progress later on in future chapters:

  • Content: This section displays any user-generated content, comments, and files with the ability to filter by Published status, Type, Title, and Language. The display for content is also now a view and can be customized with additional fields and filters as needed.
  • Structure: This section is to manage Block layout, Comment types, Contact forms, Content types, Display modes, Menus, Taxonomy, and Views. We will explore some of the changes and new functionality contained within this section later on in the book.
  • Appearance: This section is to enable, disable, and configure default themes as well as administrative themes.
  • Extend: Formerly known as Modules, this section is for listing, updating, and uninstalling core, custom, and contributed modules. New is the ability to search for modules using a filter. Various contributed modules have been moved into core, including Views and CKEditor.
  • Configuration: This section is designed to configure both core and contributed modules. Each area is grouped into functional sections and allows us to manage site information to file system to performance tuning.
  • People: This section allows us to manage users, permissions, and roles. The display for users is now a View as well and can be customized to add additional fields and filters as needed.
  • Reports: This section is designed to view available updates, recent log messages, field lists, status reports, top "access denied" errors, top "page not found" errors, top search phrases, and View plugins.
  • Help: This section is designed to obtain helpful information on functionality necessary to know in administering a Drupal 8 website. This includes a Getting Started section and help topics on items, such as Block, Views, User, and more.

Exploring Drupal 8 folder structure

There are several changes to Drupal 8 with regard to how files and folders are structured. Let's walk through the core, modules, sites, and themes folders and discuss some best practices for how each of these folders should be managed when creating a Drupal 8 website.

The core folder

One of the first things to point out is that the files and folder structure of Drupal 8 have changed from its predecessor Drupal 7. The first change is that everything that Drupal 8 needs to run is contained within the new core folder. No longer is there any confusion of having the modules and themes folders contained within a sites folder and having to ask "did I place my files in the correct location?".

The core folder consists of miscellaneous files needed by Drupal to bootstrap the content management system as well as the following folders:

  • assets: Various external libraries used by core (jquery, modernizr, backbone, and others)
  • config: It contains misc configuration for installation and database schema
  • includes: It contains files and folders related to the functionality of Drupal
  • lib: Drupal core classes
  • misc: Various JavaScript files and images used by core
  • modules: Drupal core modules and Twig templates
  • profiles: Installation profiles
  • scripts: Various CLI scripts
  • tests: Drupal core tests
  • themes: Drupal core themes
The modules folder

While a lot of functionality, which was generally contained in a contributed module, has been moved into the core instance of Drupal 8, you will still find yourself needing to extend Drupal. Previously, you would locate a contributed module, download it, and then extract its contents into your sites/all/modules folder so that Drupal could then use it.

Contributed and custom modules are now placed into the modules folder, which is no longer contained inside your sites folder.

Best practices are to create a few subdirectories inside the modules folder for contributed modules—the modules built by third parties that we will use to extend your project, such as contrib, and custom, for the modules that we create on a per project basis. We will also occasionally find ourselves with a features folder if we plan to use the Features module to break out functionality that needs to be managed in code for purposes of migrating it easily to development, staging, and production instances of our website.

The sites folder

We are all familiar with the sites folder in Drupal 7. However, in Drupal 8, the sites folder only contains our Drupal instance configuration and files.

The themes folder

Finally, we have the themes folder. So, why don't we see the default themes that Drupal generally ships with inside this folder? That is because Drupal's default themes now are contained within the core folder. Finally, we will actually use the themes folder to place our custom or contributed themes inside it for use by Drupal.

We will be exploring the themes folder in more detail in later chapters as we begin creating custom themes.