18.11.2015 Views

Beginning Drupal 8

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

Todd Tomlinson - Beginning Drupal 8 (The Expert's Voice in Drupal) - 2015

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 9 ■ Views<br />

6. In the Filter Criteria section, leave the Content Publishing status and Content<br />

Type criteria set as only showing published content (Yes) and only content that is<br />

of type Article.<br />

7. In the Sort Criteria section, click the Add button and search for Date. You’ll see<br />

“Content: Post date” in the list of options. Check the box next to this field, change<br />

the For option to “This block (override),” and click the “Apply (this display)”<br />

button at the bottom of the form. On the next form that appears, select “Sort<br />

descending,” as we want the most recent Articles to appear at the top of the list,<br />

and the oldest articles at the bottom. Apply that change as well.<br />

8. The last change we need to make is to limit the number of Articles that will<br />

appear in the list to three. In the second column of configuration options, check<br />

to make sure that the value for “Use pager” is set to “Display a specified number<br />

of items | 3 items.” This was the value we specified when we initially set up the<br />

view.<br />

Click the Save button, and you’re now ready to place the block you just created on a page on your site.<br />

To place the block created by your view on a page, navigate to the Structure page and click the “Block layout”<br />

link. On the “Block layout” page, in the “Place blocks” column, you should see the View display that you just<br />

created listed under the Lists (Views) section (see Figure 9-5).<br />

Figure 9-5. The List (Views) blocks<br />

Click the Recent Articles: Recent Articles Block link and assign the block to a region. After selecting a<br />

region from the list, save the block and return to the homepage of your site. You should be happy to see the<br />

list of articles that you created displayed through the block that you created using views (see Figure 9-6).<br />

108

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!