Create Views in Drupal 9 (Page and Block)

Lyubomir Filipov
4 min readDec 25, 2020

In order to proceed you should have:
- Drupal installed
- virtual host ready for you
- xampp setup or other web server
- composer installed
- drush installed

#STEP 1: Create page view

Navigate to Structure and then click on Views

After page load find the “Add view” button and click on it.

Add name for the view in our case it will be “Article page list”, add description to the view “Used to provide a list of content type”.

Choose “Content” and then select type “Article” and sort them by “Newest first”.

From PAGE SETTINGS — choose to create a page and provide title
“Article page list”.

PAGE DISPLAY SETTINGS — choose “Unformatted list” of “teasers”
Use a pager and include an RSS feed, once you submit the form you will see.

Check created page {DRUPAL-DOMAIN}/article-page-list

It is not looking great — lets alter the view — Click in Format on the “Unformatted list”

On the window that is shown change to be applied only to this view and then choose Grid.

On the next screen, choose “Apply” and then Save the view.

View will be updated with more pleasant presentation.

We might consider reducing the amount of text in the Teaser, in order to do that we need to go to: Structure -> Content Types -> Locate Article and then click on “Manage Fields” and then go to “Manage Display” tab on the top. Switch to “Teaser” tab and click on the settings next to the Body field.

Set the new limit to be 150 chars and save.

#STEP 2: Check RSS feed

Navigate to the view but click on the feed.

Open the url http://{DOMAIN.NAME}/article-page-list.xml

#STEP 3: Create block view

In order to create block view we need to navigate to view edit page and then click on “+Add” button.

Choose “Block” from the list.
Remove pager — use “Display a specified number of items.” Make sure that you are applying the changes only to this block.

Set 4 items to be shown. Save settings.

#STEP 4: Place block on node view

Open Structure — Block layout and find “Right siderbar” region.

Note: Please check that we are using a custom drupal theme and we have such region — if you have different theme you need to check the available regions for it.

Click on PlaceBlock button.

Find the correct block

Click on Place block and then on the “Configure block””

Remove title and make sure that this will be shown only on article pages.

Make sure to press “Save blocks” on the bottom of the page.

Open any Article and check on the right side.

VIDEO

--

--

Lyubomir Filipov

Group Architect at FFW, believer, developer, enthusiast