Site Building

9.3. Creating a Content List View for Drupal 8, 9, 10, and 11

Goal

Create a page listing vendors that will be automatically updated whenever a vendor is added, deleted, or updated on the site.

Site prerequisites

Steps

Sprout Video
  1. In the Manage administrative menu, navigate to Structure > Views > Add view (admin/structure/views/add). The Add view wizard appears.
  2. Fill in the fields as shown below.

    Field name Explanation Example value

    View basic information > View name

    Name of the view that will be visible in the administration pages

    Vendors

    View settings > Show

    Type of information listed in the view

    Content

    View settings > of type

    Specify content type

    Vendor

    View settings > sorted by

    List order

    Title

    Page settings > Create a page

    Create a page that displays the view

    Checked

    Page settings > Page title

    Title show above the view

    Vendors

    Page settings > Path

    Address of the page

    vendors

    Page settings > Page display settings > Display format

    Type of list

    Table

    Page settings > Items to display

    Number of items visible on the page

    10

    Page settings > Use a pager

    Split up the list in several pages if there are more items

    Checked

    Page settings > Create a menu link

    Add the view page to the menu

    Checked

    Page settings > Menu

    Menu in which to add the link

    Main navigation

    Page settings > Link text

    Label of the link in the menu

    Vendors

    Image
    Add new view wizard

  3. Click Save and edit. The view configuration page appears.
  4. Under Fields, click Add from the dropdown button. The Add fields pop-up appears.
  5. Enter the word "image" in the search field.
  6. Check Main image in the table.
  7. Click Apply. The Configure field: Content: Main Image pop-up appears.
  8. Fill in the fields as shown below.

    Field name Explanation Example value

    Create a label

    Add a label before the field value

    Unchecked

    Image style

    The format of the image

    Medium (220x220)

    Link image to

    Add a link to the content item

    Content

  9. Click Apply. The view configuration page appears.
  10. Under Fields, click Add from the dropdown button. The Add fields pop-up appears.
  11. Enter the word "body" in the search field.
  12. Select Body in the table.
  13. Click Apply. The Configure field: Content: Body pop-up appears.
  14. Fill in the fields as shown below.

    Field name Explanation Example value

    Create a label

    Add a label before the field value

    Unchecked

    Formatter

    The presentation of the field value

    Summary or trimmed

    Trimmed limit:

    The number of maximum characters shown

    120

  15. Click Apply. The view configuration page appears.
  16. Under Fields, click Content: Title (Title). The Configure field: Content: Title pop-up appears.
  17. Uncheck Create a label. This will remove the label that was created by the wizard.
  18. Click Apply. The view configuration page appears.
  19. Under Fields, click Rearrange in the dropdown button. The Rearrange fields pop-up appears.
  20. Drag the cross bar handles of fields to put them into the right order: Image, Title, Body. As an alternative to dragging, you can click the Show row weights link at the top of the table and enter numerical weights (fields with lower or more negative weights will be shown first).
  21. Click Apply. The view configuration page appears.
  22. Optionally, click Update preview for a preview.
  23. Click Save.

    Image
    Vendors view configuration page

  24. Navigate to the homepage and click Vendors from the main navigation to see the result.

    Image
    Vendors view output

Expand your understanding

The link to the view in the main navigation will probably not be in the right place. Change the order of the menu links in the main navigation. See Section 5.7, “Changing the Order of Navigation”.

Drupal User Guide