Samuli Natri
Dec. 04, 2015
Updated: Sep. 28, 2016
0
By Samuli NatriDec. 04, 2015
(Updated: Sep. 28, 2016)
0

Views #4 : Header & Footer, Page Settings, Pager (Drupal 8 Tutorial #6) (Article + Video)

We make the view available only for administrators, show a summary in the header and add a contact block for the footer. There is a no result behavior and the pager is a little more compact.

Page Settings

We already set the Path to /home when we created the view and we don't have to add the Menu item because this views page was earlier set as default homepage which already has a menu item called Home.

Let's restrict this view just for Administrators.

  • Click the Permission link in PAGE SETTINGS section and set the Role as Administrator:

  • Log out and you will see this:

Header and Footer

You can add things on top and bottom of the view. Let's add the number of items on top of the view.

  • Click the Add button in HEADER section and add a Result summary.

With the default settings you see this:

You can also add here more complicated stuff like blocks and views. See examples in the video.

No Results Behavior

  • Click the Add button in NO_RESULTS_BEHAVIOR section and add a Global: Text area.
  • Write in the content:
No results for the [view:title] view.
  • Change the Authored on filter temporarily to +2 days and you will see this:

Pager

Let's make the pager a little more compact and edit the labels.

  • Set Items per page to 6 and change the labels:

More compact pager:

More link can be used to link this view to a display. More about this in the Displays tutorial.

View so far:

Result

Samuli Natri is the founder of WDTutorials.com. He started building Drupal sites in 2010 with Drupal 6. He attended Helsinki University and Helsinki University of Technology (Social Sciences and Computer Science). Read more...

Add new comment