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

Submitted by TheMain on Fri, 12/04/2015 - 14:01

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

Posted by Samuli Natri on 04 December 2015