Drupal Views Part 1 — Pages

An overview of the Views feature, which lets you list created pages and place them freely anywhere on the site.

Views is the feature most Drupal users cite as one of Drupal's key advantages. In brief, Views lets you list and display published content — articles, pages, and so on — filtered by any extraction condition you specify.

Clicking Articles on Drupal and Web > All articles in the navigation menu displays a category list page of Drupal and web-related articles, created with Views.

The feature that creates this category list page is Views. Views can create not just pages but also blocks — and placing a created block on a specified page lets you surface any list of articles or pages freely anywhere on the site.

One of the reasons I use Drupal is its exceptional flexibility for organizing information. Views is the feature that makes that flexibility possible.

Introduction.

Views can create not just the category list pages used in the navigation menu, but also blocks placed within content and on pages. Here's a brief summary of what Views can do.

Views specification conditions

Choose whether to use as a page or block

  1. Create a page listing content by specified conditions
  2. Create a block listing content by specified conditions

Specification conditions

  1. Content type
  2. Taxonomy

Display format

  1. Plain HTML
  2. Table
  3. Grid
  4. Responsive grid

Information that can be displayed on the page: fields

  1. Title
  2. Article body
  3. Taxonomy
  4. Author
  5. Publication date/time

Filtering

  1. Taxonomy term
  2. Content type

※ Can be specified from existing entities.

This is only a brief outline — the actual configuration offers considerably more granularity. The taxonomy list pages and admin menus described in the previous article are also configured using Views.

Views can configure the display of articles, pages, admin menus, and core feature outputs in a wide variety of ways. A complete explanation would be enormous, and I've only used a portion of the feature myself — so I'll explain by example, using the configurations on this site.

1. Views in Use on This Site

Here's how Views is used on this site.

Full list of Drupal and web-related articles > Views page creation feature

  1. Articles on Drupal and Web. > All articles
  2. Life Style articles.  > All articles
  3. Web Creation Article.  > All Article. / English
  4. Life Style Article. > All Article. / English

Latest articles for the top page > Views block creation feature

  1. Welcome. > Middle of page > Drupal Articles. / Life Style Article.
  2. Welcome. >  Middle of page > Drupal Articles. / Life Style Article. / English

Related articles placed at the end of pages by content type > Views block creation feature

  1. Related articles. at the bottom of each article  > Also displayed at the bottom of this article.
  2. Related articles. at the bottom of each article  > Also displayed at the bottom of this article. / English

Not covered here, but the taxonomy list pages are provided by default in Drupal Core — they're already configured as list pages using Views, and I'm using them as-is for the category lists.

1-1. Views Page Feature.

Here's a summary of the Page feature used to create category lists.

Navigate to Home > Administration > Structure > Views.

A list of Views configured by default in the Core program is displayed. From this top screen you can create new views and edit, enable/disable, duplicate, or delete existing ones.

Click + Add view to create a new view.

The Home > Administration > Structure > Views > Add view screen appears.

Basic view information
View name: Administrative name
Description:

View settings
Show: Content   Type: Specify content type   Tagged with: Empty   Sort by: Newest first

Page settings
Create a page: Checked / Can be configured later, either is fine

Block settings
Create a block: Checked / Can be configured later, either is fine

 Enter the required information and click Save and edit to open the Views configuration screen.

Configuration for the created view is done at Home > Administration > Structure > Views > View.

2. Configuration Example from This Site.

Let's look at the Views configuration used to create the category list of Drupal and web-related articles on this site.

Created page > Articles on Drupal and Web. > All articles

Configuration screen > Home > Administration > Structure > Views > View > Creation block (Content)

Since the configuration spans several areas, I've divided it into five blocks to make it easier to understand where each setting is made.

  1. Top Block
  2. Left Block
  3. Center Block
  4. Right Block
  5. Footer Block

The actual configured settings are summarized below.

Views settings screen

Views settings screen

2-1. Top Block.

Add pages or blocks and configure translation settings as needed.

Top Block Setting.

Creation block (Content)
Edit / Translate view
Display
Page / Block + Add ----- Edit view name/description >
Display name: Page  ----- Show page >

2-2. Left Block.

Most of the key configuration is done in this left block: setting the title and display format, selecting fields for the items to display, filtering the content to show by taxonomy and specified terms, and setting the sort order.

Left Block Setting.

Title
Title: Creation // Title set to "Creation".
Format
Format: Grid | Settings // Display format set to grid.
Show: Fields | Settings // Fields displayed in the grid are as follows.
Fields ----- Add // Fields displayed in the grid above
Content: Title
Content: Body (article content)
Content: Post (publication date)
Content: All taxonomy terms
Filter criteria ----- Add
Content: Published (= Yes) // Generates the content list. Displays published/active content.
Content: Contains taxonomy term (= Creation) | Settings // Displays only content containing the Creation term configured in taxonomy.
Sort criteria ----- Add
Content: Publication date (descending) // Sorts the list with newest publication date first.

2-3. Center Block.

Page path, header, footer, and list display conditions are configured here.

Center Block Setting.

Page settings
Path: /creation // This becomes the link destination for the page created in Views.
Menu: No menu // Not used since navigation menus are configured separately.
Admin theme: No // Not currently needed.
Access: Permission | View published content // Matches content publication permissions since it's public.
Header ----- Add
Global: Text area (Global: Text area) // A header doubling as a description is configured.
Footer ----- Add // Not needed for now, but will be used if supplementary notes become necessary.
No results behavior ----- Add // Left at default.
Pager
Use pager: Mini | Mini pager, 10 items per page // Set to 10 since this is a category list.
More link: No // Not used since full pagination is in place and page numbers are displayed.
Language
Rendering language: Content language of view row // This page is set to Japanese.

2-4. Right Block.

Settings not available in the basic configuration are handled here.

Right Block Setting.

^ Advanced // Left at default.
Relationships ----- Add
Contextual filters ----- Add
Exposed form
Expose form in block: No
Exposed form style: Basic | Settings
Other
Machine name: page_1
Administrative comment: None
Use AJAX: No
Hide attachments in summary: No
Contextual links: Shown
Use aggregation: No
Query settings: Settings
Caching: Tag based
CSS class: None

2-5. Footer Block.

Save configured settings and preview the results here.

Footer Block Setting.

Save / Cancel // Saves the configuration.
Preview ----- Auto preview // Changing settings shows a preview below.
Preview with contextual filters: // Preview display conditions
Update preview // When settings are changed, update and check the preview displayed below.
Title -----  Creation. // The configured title
Path ----- /ja/creation // The configured page path
// Preview content appears below.
Title
> Creation.
Header
> Header content
Content
> The configured list is displayed
Pager
1 >

That covers the full configuration.

3. Notes on the Configuration

Having walked through the Views configuration screen and its settings, here's a brief summary of what's actually being done.

Views is being used to create a category list page. The Views feature works by freely calling entities and generating pages or blocks that list those entities in any configuration. "Entity" is a term that comes up frequently in Drupal — thinking of it as a database unit makes it easier to understand, so that's the framing I'll use here. Strictly speaking, entities vary by use case, but for this article they're treated as database units. I haven't fully mastered entities myself, so I'm hoping to dig deeper into the topic when the opportunity comes.

Configuration involves the entities being called and displayed and the entities used as conditions — but thinking in terms of entities gets confusing, so from here I'll use the actual terms used in the interface.

  1. What to list and display > Content > Drupal-related articles
  2. Extraction condition > Taxonomy > Term > Creation.
  3. All Drupal-related articles have the Creation. term set as a tag.

These three conditions are used to create the category list.

One of Drupal's strengths is that even in the Views configuration screen, settings are organized purposefully across the five blocks described above: Top Block, Left Block, Center Block, Right Block, and Footer Block. "Block" is my own naming for clarity in this article — these aren't official Drupal terms.

Top Block handles selecting or adding pages and blocks; Left Block determines extraction conditions and how results are displayed; Center Block shapes the output as a page; Right Block handles additional settings; and Footer Block is for reviewing the configuration.

Organizing the Views configuration process:

  1. Select or add page/block > Top Block settings
  2. Determine extraction conditions and post-extraction display > Left Block settings
  3. Format as a page > Center Block settings
  4. Additional settings > Right Block settings // Not configured in this case.
  5. Review configuration > Footer Block

This article documents the Views configuration example used to create Articles on Drupal and Web. > All articles. The number of settings may look daunting, but the logic is simple.

  1. Create articles using the Creation content type for Drupal and web-related articles
  2. Place the Creation term — configured in the Tags vocabulary of the Creation content type — in each article
  3. Use Views to list pages tagged with Creation and generate a page

The details of those three steps are what the Top Block, Left Block, Center Block, Right Block, and Footer Block settings described above cover.

With this configuration in place, the list page for Articles on Drupal and Web. > All articles is generated.

Conclude.

This article covered the Views feature — how it categorizes created articles, lists them, and generates a category list page. The focus here is on the page generation configuration, walked through with a concrete example. Since the article got long, block generation isn't included — the next article will cover Views block generation. Once a block is generated, it can be placed freely on any page, enabling things like latest articles on the top page or related articles at the bottom of article pages.

Next article.

Drupal Views Part 2 — Blocks

This article covered creating a category list page with Views. The next article covers how to create related article blocks that can be placed on any page.

Last update
Contributor
S.Takeda
Article

Powered by Drupal 11.4.2 and Bootstrap 5.0.4

Published AWS Jamstack by Drupal