Adding and editing content

The main functionality of a content management system is in the name itself – the ability to manage content; that is, to add, edit, and organize content. Drupal provides a central form that allows you to manage all of the content within your website and allows you to create new content. Additionally, you can view a piece of content and have the ability to click an edit link when viewing it.

Getting ready

This recipe assumes you have installed the standard installation profile and have the default node content types available for use.

How to do it…

Let's manage the content by adding, editing, and organizing the content:

  1. Visit Content to view the content management overview from.
  2. Click Add content to view the list of available content types. Select article as the piece of content you would like to make.
  3. Provide a title for the piece of content. Titles are always required for content.

    Fill in body text for the article:

    How to do it…

    Note

    You may change the text format to customize what kind of text is allowed. If the user only has one format available there will be no select box, but the About text formats link will still be present.

  4. Once you have added your text, click Save and publish at the bottom of the form. You will then be redirected to view the newly created piece of content.
  5. Note that the URL for the piece of content is /node/#. This is the default path for content and can be changed by editing the content.
  6. Click on Edit from the tabs right above the content.
  7. From the right sidebar, click on URL Path Settings to expand the section and enter a custom alias. For example /awesome-article (note the required "/".):
    How to do it…
  8. Save the content and notice the URL for your article is /awesome-article.
  9. You could also edit this article from the Content table by clicking Edit there instead of from viewing the content.

How it works…

The Content page is a View, which will be discussed in Chapter 3, Displaying Content through Views. This creates a table of all the content in your site that can be searched and filtered. From here you can view, edit, or delete any single piece of content.

In Drupal there are content entities that provide a method of creation, editing, deletion, and viewing. Nodes are a form of a content entity. When you create a node it will build the proper form that allows you to fill in the piece of content's data. The same process follows for editing content.

When you save the content, Drupal writes the node's content to the database along with all of its respective field data.

There's more

Drupal 8's content management system provides many features; we will cover some extra information.

Save as draft

New to Drupal 8 is the ability to easily save a piece of content as a draft instead of directly publishing it. Instead of clicking on Save and publish, click the arrow next to it to expand the option of Save as unpublished.

Save as draft

Pathauto

There is a contributed project called Pathauto that simplifies the process of providing URL aliases. It allows you to define patterns that will automatically create URL aliases for content. This module utilizes tokens to allow for very robust paths for content.

The Pathauto project can be found at https://www.drupal.org/project/pathauto.

Bulk moderation

You also have the capability to perform bulk actions on content. The table provides checkboxes at the beginning of each row. For each selected item, you can choose an item from With selection to make bulk changes – such as deleting, publishing, and unpublishing content:

Bulk moderation

See also

  • Chapter 2, The Content Authoring Experience in recipe Customizing the Form Display of a Node
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset