Customizing the display output of a node

Drupal provides display view modes that allow for customization of the fields and other properties attached to an entity. In this recipe we will adjust the teaser display mode of an Article. Each field or property has a control for displaying the label, the format to display the information in, and additional settings for the format.

Harnessing view displays allows you to have full control over how content is viewed on your Drupal site.

How to do it…

  1. Now it is time to customize the form display mode by visiting Structure and then Content Types.
  2. We will modify the Article content type's display. Click on the dropdown button arrow and select Manage display.
  3. Click on the Teaser view mode option to modify it. The teaser view mode is used in node listings, such as the default home page.
    How to do it…
  4. Change the format for Tags to be Hidden. Additionally, this can be accomplished by dragging it to the hidden section. The tags on an article will no longer be displayed when viewing a teaser view mode.
  5. Click on the settings cog for the Body field to adjust the trimmed limit. The trim limit is a fallback for Summary or trimmed when the summary of a textarea field is not provided. Modify this from 600 to 300.
  6. Press Save to save all of your changes that you have made.
  7. View the home page and see that your changes have taken affect!
    How to do it…

How it works…

View display modes are configuration entities. View display modes dictate how the DrupalCoreEntityContentEntityForm class will build a view display when an entity is viewed. This will always be set to default unless changed or specified as a different mode programmatically.

Since view display modes are configuration entities they can be exported using configuration management.

..................Content has been hidden....................

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