Drupal 8 – Freeform Taxonomy


While many of us may not be able to define the word “taxonomy,” the reality is that we use taxonomy on a daily basis as a means for categorizing “things” in our lives. If you open the doors to your kitchen pantry, you might find an orderly assemblage of food items: all of your spices on the top shelf, canned food on the second shelf, pastas and other boxed foods on the third shelf, and cereal boxes on the fourth. Categorizing your food items and putting things away in an orderly fashion so that you can easily find food items when you need them to prepare a meal is in its simplest form the use of taxonomy. Without this “kitchen taxonomy system,” you may have everything you need to make dinner jammed randomly in the pantry, but finding it may be a challenge, leading to frustration and a phone call to the local pizza delivery restaurant when you’re not able to find the ingredients you need to make a meal.

In Drupal, taxonomy is divided into two general capabilities: tagging and structured taxonomy. Both are powerful solutions and can be used simultaneously on your site. Tagging is a simplified yet powerful use of the taxonomy system, enabling content authors to enter keywords that describe the content in a text field on the content editing form. As an example of tagging content, an author who writes an article about alternative energy could use keywords, or tags, such as “solar,” “wind,” and “geothermal” to categorize the article. The keywords created by the author are typically displayed as hyperlinks at the end of the article and can be used by site visitors to locate other content tagged with the same keywords. All Drupal developers are aware of the power of taxonomy.

Tagging is freeform, meaning it’s up to the author to define what words they want to use to classify their content. A common issue with using tagging as an approach to categorize content is that different people use different words to refer to the same concept. For example, an article about rain might be tagged with the word “rain” by one author, “precipitation” by another author, and “drizzle” by a third. Site visitors trying to find articles about the general concept of rain would have a difficult time finding the ones tagged with words other than “rain.” Another common problem is misspellings. If an author tags an article about rain with “reign,” then site visitors are going to have a hard time, using taxonomy, to find that article using the word “rain.”


Drupal 8 – User Account Settings


Before creating your first user account, it is advisable that you visit the user account settings page and review or modify the general user account configuration settings, of which there are many.

To access the settings page choose Manage ➤ Configuration (assuming you are logged in as the administrator), and, on the Configuration page, locate the section titled “People.” Click the Account Settings link, which will take you to the page that you will use to set various configuration parameters for user accounts:

Contact settings: you may enable individual users on the site to have a personal contact form. This feature is enabled by default; to disable it, simply uncheck the box.
Anonymous users: the name used to identify anonymous users: In most cases, leaving the default value is appropriate, which is “Anonymous.”

Administrator role: what role to associate with administrator capabilities: The role selected becomes the default role assigned as the administrator of new modules that you install on the system. Using the default value “administrator” is an appropriate action.
Registration and cancellation: defines several attributes about user account registration: Who can register accounts: if only administrators can create accounts, select the first option “Administrators only.” If any visitor to your website can create their own account, select the “Visitors” option. If visitors can request an account but an administrator must approve that request before the account is active. This option is selected by default. For demonstration purposes I’ll select the first option, so that only administrators may create user accounts. Several Drupal 8 developers share more info on their blogs.

“Require e-mail verification,” is a good option to leave checked. This option requires that the user responds to a Drupal-generated e-mail that asks them to confirm their account. This helps to avoid “bot”-created user accounts, as most bots do not have the intelligence or capabilities to respond to user account verification e-mails.

The password strength indicator is a helpful tool to indicate how strong a person’s password is. A weak password may be easily hacked, whereas a strong password is harder to crack. It’s a good tool to enable to help keep your Drupal site secure. When cancelling a user account: a set of options allows you to define what happens to content on your site that was created by this user when you disable that person’s account in the future. In most cases the default option, “Disable the account and keep all content,” meets the needs of a majority of websites. You may, however, decide that one of the other options is more appropriate for your site.

Personalization: defines whether users can add signatures to their profiles. I will leave the default values for our test site; however, you may wish to enable or disable signatures depending on whether you wish to provide those capabilities to users. The e-mail address in the “Notification e-mail address” field is the e-mail address that will appear on all user account–centric e-mails that are generated by Drupal during the registration and password recovery process. By default, the site’s e-mail address defined during the installation process is the value that will be used; however, you may override the default by entering a valid e-mail address in the “Notification e-mail address” field.

Drupal 8 – Users, Roles, Permissions


Now that your site is up and running, you have a couple of decisions to make. First, will you have any administrators on the site other than yourself? Second, will your site be open to everyone, or will users need to log in to view content and other features? In this chapter, I cover how Drupal treats visitors to your site, and how you as a site administrator can configure Drupal’s user account features to restrict the capabilities of those who have user accounts on your system.

Controlling who has the ability to do what on your website is performed through Drupal’s security features. Drupal’s security features provide the ability to define who has the ability to view, create, update, delete, and participate through a combination of individual user accounts, user roles, and permissions.

Users (or site visitors) in Drupal 8 are divided into two general categories: anonymous users and authenticated users. Anonymous users are individuals who visit your website and do not log in using a user ID and password. With Drupal, you have the ability to support anonymous users, and you also have the ability to restrict what an anonymous user can do on your site. Authenticated users are visitors to your site who log in using a unique user ID and password. I’ll cover how user IDs and passwords are created shortly, but understanding the difference between the two categories of users is important. A lot of Drupal developers post useful tutorials about handling users.

Roles are a Drupal mechanism that allows you, the site administrator, to define categories of authenticated users of your website. You may define roles on your website that are department specific (e.g., a role each for human resources, purchasing, sales, marketing, and customer service), roles that are functionally oriented (e.g., content authors, content reviewers, content publishers), roles that are associated with a specific section of your website (e.g., products, support, sales, homepage), or any other definition that you can dream up. Roles are simply a way of putting authenticated users into categories, where categories are associated with specific permissions. Any authenticated user of your website may be assigned to none, one, or more than one role (e.g., you may have a user who is assigned roles of sales department, content author, and products).

Permissions in Drupal are a mechanism for controlling what a user assigned to a specific role can do. There are dozens of permissions that you can enable or revoke for each user role you have defined. Examples of permissions that you might set for a specific role include: the ability to create a new page, the ability to create a new article, the ability to edit any article regardless of who authored it, the ability to search content on the website, and the ability to add a new user account. The combination of permissions that you set for each role defines the capabilities that a user assigned to that role can do on your website once they have successfully logged in. When you combine user roles with permissions and individual user accounts, you end up with a highly configurable solution for securing access to key features and content on your website.

Drupal 8 – Comment settings


Drupal provides the capability for visitors to your website to post comments about your site’s content. To try it, click the Edit tab next to the title of your content item, or hover over your content item and click the pencil icon and select Edit. In the right column of the content editing form, click Comment Settings.

Two options are presented: Open, the default option, which allows site visitors to post comments to a content item created with this content type, and Closed, which precludes visitors from posting comments. There may be cases where you don’t want visitors to have the ability to post comments.

Try both options to see the difference in how the content appears on your site. Leave the Open option selected and click the “Save and keep published” button. You’ll see your content with the Add new comment form displayed immediately beneath the content. Edit the content and select the Closed option and click the “Save and keep published” button. You’ll notice a significant change in how your content item is displayed, because comments will no longer appear.

With the default settings of Open, visitors to your site can now write and publish comments in response to your content item. Try entering a Subject and Comment and then clicking Save. Your comment should now appear in the Comments section. By the way, there are many good Drupal developers that share tutorials on their blogs and sited.

As the content author (or as an administrator of the site), you can delete, edit, or reply to a comment by clicking the links under each comment. Comments typically appear in chronological order. As the site administrator, you have the ability to specify how comments are displayed: either the newest comment at the top of the list or the first comment posted at the top of the list.

Turning comments on and off at the individual content item provides absolute control over which items accept comments. You can also set whether to accept comments at the content type level, meaning every content item created using that content type will “inherit” that setting.

Drupal 8 – Editing content and other content options


At some point you will need to change something about a piece of content that you’ve posted on your site. The process for editing content is nearly identical to the process for creating it, the only difference being the need to find the content that you want to change. To find content, click the Content link in the menu at the top of the page.

The Content page lists all of the content that appears on the site and is filterable by published status, type of content, language, and a title search feature. To edit a content item from the list presented on the Content page, simply click the Edit button for that item and Drupal will display the content editing form for that item. If you are on the page where the content you need to change resides, and you are logged in as a user who has the correct permissions, you will see View, Edit, and Delete tabs.

In the right column of the content editing form, we modified one of the items—Promotion Options—before we saved our new content item. Let’s look at this and the other options associated with a content item before moving on to more advanced content topics.

  • Click the Edit tab next to the title of the content item you just updated and examine the items in the right column:
    “Create new revision” check box
    Menu Settings link
    Comment Settings link
    URL Path Settings link
    Authoring Information link
    Promotion Options link

The options associated with each of these items are described in turn in the sections that follow.

Revision Information

Have you ever made a change to a document, saved those changes, and then realized that you made a mistake and need to “undo” the changes you made? Have you ever realized this after closing Microsoft Word, when it’s too late to revert to the document in its pre-changed state?

There will come a time when you or someone else makes changes to a content item, and you’ll wish you had a copy of the content before it was changed. Drupal solves this problem by providing the ability to create a new version (copy) of your content when that content item is changed. Edit the sample article you created in previous steps and check the “Create new revision” check box in the right column. Enter a description of the changes that you made in the “Revision log message” field.

Drupal 8 – CMS basics and content


Content is the primary building block of any website, whether it is constructed using Drupal or any other tool in the marketplace. Content is what visitors come to a website to find, and a lack of content is often the reason visitors fail to return to a website after the first time. In its most basic form, content is any combination of text, pictures, video, audio, and graphics. An individual piece of content may take a variety of different forms:

• news story
• blog post
• product description
• company overview
• forum post
• photograph
• wiki entry

Content on a Drupal-based website often starts with a title followed by body text. We created a basic page, which consisted of content with just a title and body. Drupal provides the ability to expand on this with a custom content type. A custom content type enables you to create additional fields that can be used to capture other relevant and related information. A common example is a calendar event.

An event includes a title and body text (the description of the event), as well as other pertinent information, such as the date and time, the location, and possibly a map or photo.

An article is identical to a basic page, with the single exception that an article has an image upload feature and an additional field where the author can enter what are called tags. Tags are simply words that help classify, organize, and search for related content on your site.

To create and publish your new article, click one of the “Add content” links on your website and select Article from the list of content types. The form that is used to create an article looks identical to the form used to author a basic page, with the exception of the image upload and tags fields. Proceed with the content creation process by entering a title. Next, upload a picture by clicking the Browse button and finding a picture on your computer to upload and include in the article.

Drupal 8 – Core and Contributed Modules


When you download and install Drupal, you are installing what is commonly called Drupal core. Core represents the “engine” that powers a Drupal-based website, along with a number of out-of-the-box features that enable the creation of a relatively full-featured website. The primary components of Drupal core include capabilities to create and manage

• content
• file uploads/downloads
• menus
• user accounts
• roles and permissions
• taxonomy
• discussion forums
• views to extract and display content in various forms such as lists and tables
• WYSIWYG-based content editor

Drupal core also includes a feature-rich search engine, multilingual capabilities, and logging and error reporting.

Although Drupal core can be used to build feature-rich websites, there are likely situations where core lacks the functionality needed to address specific requirements. In such cases, the first step is to search through the thousands of custom modules, contributed by developers from all around the world to the Drupal project, for a solution that meets your needs. It’s very likely that someone else has had the same functional requirement and has developed a solution to extend Drupal core to provide the functionality that you need.

To find a contributed module, visit the Drupal.org website at http://www.drupal.org/project/project_module. You will find a general list of categories and the current number of contributed modules (for all versions of Drupal) contained within each. Here is a short sampling of the types of categories and the number of modules you can find in each (modules are added to the list on a daily basis, and the number of modules in each category will have grown considerably since the time of this writing):

• Administration (1145)
• Community (614)
• Content (1981)
• Content Display (1612)
• Content Construction Kit (CCK) (673)
• Developer (960)
• E-commerce (892)
• Media (778)
• Third-party Integration (1908)
• Utility (1959)

To find modules that are supported on Drupal 8, select 8.x for the “Core compatibility” search filter. A few of the most popular contributed modules, and the ones that you will likely want to install, include the following (also check out the “Most installed” list to the right of the search filters):

Commerce: A full-featured web storefront module that provides all of the mechanisms required to sell products (physical as well as electronic downloads), collect credit card payments, and manage shipments. If you want to sell something on your website, this is the module you will want to use.

Display Suite: Allows you to take full control of how your content is displayed using a drag-and-drop interface.

Calendar: Provides the ability to create and render a list of events on a calendar.

Backup and Migrate: Handles scheduled backups of content in your Drupal database, with the ability to restore the database to a previous state based on one of the backup files created by this module. This is a must-have module for any production website.

Google Analytics: Provides a simple to use form for setting up Google Analytics on your site. Google Analytics is a free service that tracks the number of visitors to your website, where those visitors came from, what search terms they used to find your site, the pages they visited while on your site, how long they spent on your site, and many other useful metrics that will help you view and understand the usage of your website.