Override Views Configuration

Learn how to override view settings between displays.

We’ll cover the following:

  • Learn why configuration is shared in Views
  • How to override configuration
  • How to reset configuration back to the default
  • Add a “Read more” link

Transcript

Trainer (00:00):
Let’s make a few changes to the block. The first thing we’ll do is clean up the fields. Let’s edit the view, and you can do that just by hovering over the block and the view, and you should see these pencil icons. And if you click on the pencil icon, you should see another link, which is edit view. If you can’t see these pencil icons, make sure the contextual links module is installed. This module comes with Drupal. So let’s click on edit view. By default, most of the view configuration, such as fields, filter criteria, sort criteria, pager, and so on, are shared across all the displays, such as page and block.

Trainer (00:44):
If you add a field or a filter, then it’ll automatically be used across all the displays, and this is a good thing. If you have a view with five displays, which is common, it’ll be annoying to add or change settings manually on all five displays. So to demonstrate, let me add a label to the title field. I’ll call this custom label. And let’s change the sort criteria from sort descending to sort ascending, then scroll down and click on save. And now if we go to latest articles, we can see the custom label that we added and that the sort has been changed in both the page and the block, because the configuration is shared across both.

Trainer (01:38):
But what if we want to change the fields on just one display, such as the block display? Let’s edit the view again, and let’s remove the label first, and I’ll change the sort back to sort descending. And if you click on any of the fields, you should see the for dropdown, which allows you to override the setting, in this case the fields, for just this display. If we select this block override, then click on apply, we can now change the fields for just the block display. It won’t change it on the page. And you’ll also notice that the field’s title is now italics. This means it’s been overridden. This also applies to other settings as well, not just fields. If we click on a filter, we can see the same dropdown. If we click on the sort criteria, we can again see the same dropdown. If you click on the pager, you can also see the same dropdown. If you want to change settings for just a specific display, then make sure you override it first.

Trainer (02:51):
Now, if you need to revert back to the default settings, click on any of your overridden settings, and then select revert to default from the dropdown. Let’s go ahead and clean up the fields on the block. We’ve already overridden the settings, which is great, but let’s now remove authored on, and tags, and let’s reorder the image field, so it’s up the top. To do that, click on the down arrow and then rearrange, and move image above title, and click on body. Then change the trimmed limit from 200 to 100, and click on apply.

Trainer (03:34):
Let’s also make changes to the pager, but first let’s make sure we have overridden the settings. So click on the pager and then select this block override, then select display a specified number of items, and change items to display from 10 to five. Let’s save the view, and now we can see the adjusted fields on the block, and if we scroll down, we should only see five items in the block as well.

Trainer (04:05):
Another thing we’ll add is a read more link at the bottom of the block, so users can click on a link and go directly to the latest articles page. Let’s edit the view again, then click on more link, and first make sure you override it. Then check create more link, and scroll down, and change the more link text to more articles. Then click on apply, and then click on save. And if we go to the homepage, we can see the latest articles block with five articles in it. And if we scroll right down to the bottom, we can see the more articles link, and if we click on it, it’ll take us to the latest articles page.

Scroll to Top