Content

by Gisle Hannemyr

This chapter is intended to give you a basic understanding of how to create and manage content using the Drupal CMS using the GUI. It introduces the node-based content types that is part of the Drupal 8 and later core, with some brief notes about how to use and extend them.

Table of contents

Drupal core modules discussed in this chapter: Book, Forum, Activity Tracker.

Drupal contributed extensions discussed in this chapter: CKEditor Markdown, Diff, Extensible BBCode, SimpleMDE Markdown Editor.

Introduction

Content is of course what web publishing is all about. There is little point in having a website without content.

See alsoThis chapter relies on the terminology defined in Introdiction to the Drupal WCMS. Make sure that you've read that chapter before this one.

The Drupal core provides several different sets of tools to deal with content by means of the GUI. The tool set available in Drupal is highly configurable. The following will appear by default if Drupal is installed with the “standard” profile:

  1. Manage » Extend: This interface lets the administrator add or remove extensions that implements specific content types. For instance to add a Forum topic to the repertoir of content types, install the core Forum extension.
  2. Manage » Content » + Add content: Select a content type and fill in a content creation form to add content of that type to the site.
  3. Manage » Structure » Blocks: Create a block of content, and select the region on the page where the block will appear.
  4. Manage » Structure » Content types: Add a new content type, or alter the characteristics of existing content types.
  5. Manage » Structure » Taxonomy: Add and edit vocabularies and terms that can be used to categorise content.

The super administrator has access these by default tools. To give other users access, set the appropiate permissions for the user.

Content creator permissions

For the user to be able to be an content creator or editor, provide a role with these permissions:

Book [If books are used on website]
Add content and child pages to books and manage their hierarchies
Contextual links
Use contextual links
Node
…: Create new content
…: Delete own content
…: Edit any content [if editor]
…: Edit own content
Access to content overview page
System
Use the administration pages and help
View the administration theme
Toolbar
Use the toolbar

You may also want to give content creators and editors permission to use the “Full HTML” text format.

Where content appears

There are two different locations to display content on a Drupal website.

As noted in the introduction to Drupal, the main unit of content in Drupal is an “entity”, and the main entity type is “content”, which is also knows as a “node”. Like all Drupal entity instances, a node has a numeric identifier (nid) that uniquely identifies the instance. To view a particular node instance, the user visits a Drupal page identified by a path. The path, in the case of a page registred by the core, consists of the name of the entity and the numeric entity instance identifier (e.g. the path node/42 leads to the node with nid 42).

There may also be custom pages. There is no provision in the Drupal core to create custom pages using the GUI, but they may be created by means of a module. Custom pages are also accessed by means of a path, but the path is defined and registred by the module.

In Drupal, a block is a custom piece of content that is not identified by a path. There is a provision in the core GUI to create simple blocks, and it possible to create a custom block by means of a module. To make a block visible to visitors, the site builder assigns it to a region (an area on the screen defined by the theme template), using the GUI.

tipThe contributed module Views UI provides the site builder with a GUI to create custom pages and custom blocks. It is used to build queries to the content database and display the result of these queries in a page or a block.

Text formats and CKEditor

The text formats, associated text editor , and roles permitted to use the format can be inspected and changed by navigating to Manage » Configuration » Content Authoring » Text formats and editors.

This is the default configuration:

  1. Basic HTML (CKeditor) only format avilable for the "Authenticated user",
    avilable for the "Administrator".
  2. Restricted HTML – only format avilable for the "Anonymous user",
    avilable for the "Administrator".
  3. Full HTML (CKeditor) – avilable for the "Administrator".
  4. Plain text – cannot be assigned to a role, but is shown when no other formats are available.

The difference between "Basic HTML" and "Full HTML" text format is that the former uses the filter "Correct faulty and chopped off HTML". Instead, "Basic HTML" uses the filters named " Restrict images to this site" and "Limit allowed HTML tags and correct faulty HTML". The allowed tags and attributes are:

<a href hreflang> <em> <strong> <cite> <blockquote cite> <code>
<ul type> <ol type start> <li> <dl> <dt> <dd>
<h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <p> <br> <span>
<img src alt data-entity-type data-entity-uuid data-align data-caption width height>

The "Restricted HTML" text format uses the same two text filters, but restricts tags and attributes to:

<a href hreflang> <em> <strong> <cite> <blockquote cite> <code>
<ul type> <ol start type> <li> <dl> <dt> <dd>
<h2 id> <h3 id> <h4 id> <h5 id> <h6 id>

I.e. it does not allowlist the following tags: <p> <br> <span> <img>.

It does not enable the CKeditor and instead add the text filter "Convert line breaks into HTML (i.e. <br> and <p>)". This format lets users type in safe text that will be correctly dispalayed with correct line breaks.

By using this assignment to roles, anonymous users will by default only be able to use "Restricted HTML". Authenticated, non-admin users will by default only be able to use "Basic HTML". Neighter will see any other format on the list.

There should be an additional format, "Raw HTML" without any filters, for the super administrator."

The super administrator will have access to all four HTML formats from a pull down menu. With the default ordering, this will default to "Basic HTML". Most of the time the super aministrator will need "Full HTML", so it is recommended to rearrange them to this:

  1. Full HTML
  2. Raw HTML
  3. Basic HTML.
  4. Restricted HTML
  5. Plain text

If authenticated users can be trusted, or there is a trusted "content editor" role, then the this user should have access to "Full HTML" instead of "Basic HTML".

Alternative editors

As an alternative to a WYSIWYG text editor, some websites prefer to provide their users with a non-WYSIWYG content creation tool that is based upon some lightwight markup language is combination with a plain text editor. The two most widespread lightweight markup languages are BBCode and Markdown.

The BBCode markup language is much used on online message boards, including the Ultimate Bulletin Board. This contributed bridge extension exists.

The Markdown markup language is used on a number of popular websites, including StackExchange, reddit, Diaspora, OpenStreetMap, GitHub and SourceForge. These contributed bridge extensions exist:

Drupal core content types

Drupal has two types of content (entity type “node”) installed in the default installation profile: Article and Basic page. These two content types represent the most basic form of content in Drupal. Both consist of a title and a body. The Article also have tags and image fields.

The Drupal core comes with several other types (see below) that can easily be turned on by enabling the core module that implements the type. Beyond this, the developer can extend Drupal with even more content types as follows:

  1. By selecting Structure » Content types » Add content type. (This option is going to be discussed in detail in the next chapter: Creating content types.).
  2. By adding projects containing custom content types and modules to the site configuration.

To create content with Drupal, you first expand the Add content item in your personal menu (often found in the left sidebar when you are logged in). You are then shown a list of available content types, and pick the type you want to create.

noteOne of the advantages of Drupal is that it is very easy for an administrator to extend the content types available, to configure the installation to include or exclude particular content types, to change the name, description and/or “rules” for using a particular content type, and also to grant or refuse a any user role the right to create content of a particular content type. The list of content types below is what the user will see if you run Drupal 8 and later straight out of the box, install all core content types, and give the user access to them. If you click on the Add content-link on some Drupal-based website, you will probably see a different list, depending upon how the administrator has set up the site.

This is a list of the core content types that available in the core of Drupal 8 and later. I've added my own notes about how I think they should be used (or not).

Article:
An Article is similar to a Basic page (see next item), except that it is published with an author byline, is automatically promoted to the site's front page, and provides the ability to post comments. It is suitable for publishing articles, blog entries, news items, press releases, site announcements, and similar material. This is one of the two content types that comes pre-installed if you use the Drupal 8 and later default installation profile.
Basic page:
A Basic page is for creating and displaying official and static information that rarely changes. It is a basic content container that is intended to be static and to stand alone. By default, a Basic page entry does not display the name of the author/owner, does not allow comments, and is not featured on the site's front page. You must create an explicit link to a Basic page if you want it to be visible. A Basic page is mainly for permanent notices that is made accessible through custom navigation, (e.g. the “About us“ page for the website, or “Privacy policy“). The Article content type is better suited for news and other topical content. This is one of the two content types that comes pre-installed if you use the Drupal 8 and later default installation profile.
Book page:
Any node content type can be inserted into a book. This means that you will probably not want to have any content belonging to the Book page content type. However, if you install the core Book module, administrators and authors will get access to a set of functions to manage nodes tied together in a hierarchical structure. For a more detailed description about how to use books, see the section about book pages below.
Forum topic:
A Forum topic is the initial post to a new discussion thread within a forum. It is linked to from the appropriate forum. To have this content type, install the core Forum module.

Using books

In Drupal, it is possible to connect nodes together. Such an interconnected set of pages is called a book. Books are a very useful structuring mechanism in Drupal. They are typically used to organise manuals, projects, cookbooks, and whatever else where the designer needs to maintain a collection of related entries in a hierarchical structure.

To be more precise, a Drupal book is a set of nodes tied together in a hierarchical structure, with a node designated to be a “book” as the root element “child” nodes beneath that. When nodes are organised into a book, Drupal will automatically create a table of contents and appropriate navigation links between the nodes that make up the book, providing a simple navigation system for organising and reviewing structured content.

If the premission “View printer-friendly books” is installed for a role, every page that is part of a book, will have a link to a Printer-friendly version in the links area. If users clicks this link, it will take them to a single page containing all the content of that page and any subpages it may have. The resulting document can be styled with a separate print stylesheet stack, so it is also possible to have material irrelevant for a printed copy, such as navigation stripped out. Clicking this link on the top-level page of a book, will produce a page containing the whole book in one single page, ready to print.

tipIn most themes I've seen, the print stylesheet stack is missing or very incomplate, so the printer-friendly version will appear unthemed. Do not enable this option unless you put in some effort in styling the printer-friendly version.

THe Book also adds a content type Book page and will make it the default content type to appear in a book. To change this, navigate to Structure » Books » Settings and select the content types allowed in book outlines and content type for the Add child page link.

See alsoFor more about creating and managing books, please see the article: Book module overview. For a tutorial on books using a FAQ as an example, please see: Maintaining a FAQ using a collaborative book. Both articles are part of the Drupal.org site. For an alternative to using books, take a look at the design notes for Drupal.org documentation. Instead of the book content type, it makes site documentation an organic group using sub-groups (per sub-section of documentation).

Creating content

[TBA]

[about teaser]

<!--break-->

[no spaces before or after break]

Tracking content

Drupal can be set up to create a new revision every time a node is revised. This allows you to track how the node has changed over time on the site.

To install this feature, go to the default node editing form (administer » structure » content types » bundle » edit » publishing options) and check the box Create a new revision in the node editing form. This will result in a new revision automatically being created every time the node is edited. (Administrators can override this when editing an individual node.)

An useful addition to revison tracking is the Diff module. This module displays the differences between two revisions.

The Activity Tracker module (in core, but disabled by default) displays a site's most recently added or updated content. It also provides user level tracking. When you install it a new meny entry (Recent content) is added to the Tools menu (path: /activity, and a new tab (Activity) is added to each user's profile.

See alsoThe Activity Tracker module has no administrator interface beyond installing and unistalling. To learn avout the module, see DO: https://www.drupal.org/docs/8/core/modules/tracker-module/overview.

RSS

Needs updating for Drupal 8 and later, see DO: RSS publishing.

In Drupal 7, core Node module provides basic RSS publishing for content. An RSS feed is generated at /rss.xml. By default, the RSS feed will contain the ten most recently created pieces of content promoted to the front page. you can add a description, change the number of items displayed and contain the content of the feed by visiting Configuration » Web services » RSS publishing.

If fields attached to content are desired to be attached to the feed, these may be configured on the manage display page for the content type. Navigate to Structure » Content types, and click manage display for the content type you want to configure. Exapand the panel Custom display settings and tick “RSS”. There is now a manage display setting for “RSS”.

Layout Builder

https://www.drupal.org/docs/8/core/modules/layout-builder/layout-builder-overview

Content editors and site builders can choose from a predefined set of layouts and use them to build pages easily with Layout builder. Note that you'll need to enable this core module in Drupal 9 to use it. It has a WYSIWYG layout user interface with drag and drop functionality, making it extremely user friendly and customizable, even to novice users. Its real time preview functionality makes it a unique and powerful page building tool. You can even extend Layout builder's functionalities easily when you integrate it with these modules.

Final word

[TBA]


Last update: 2021-11-14 [gh].