Documentation Level: 
Introduction
Documentation Status: 
No known problems

View edit page

The view edit page gives you access to a wealth of options to refine and control your view. Get to it either by clicking "Continue & edit" when you have set up a basic view or by clicking a view's Edit link at Structure > Views.

Edit page layout

The view edit page is divided into areas, each focused on a different aspect of your view: displays, content, and so on. Every link and drop-down control on the edit page lets you change or configure some aspect of your view.

View controls

The controls at the top of the edit page manage your view. Each display has a button. Clicking a display button opens it in the editing area at the center of the page and in the preview area at the bottom.

Display controls

  • Display details - The controls at the top of the display details area let you name, clone, and delete your display. The display details header hides or shows the editing area to let you see the preview area higher up the page.
  • Left panel - The controls in the left panel manage how the view results are shown in the display: title, format, content or fields, filters, and sorting.
  • Center panel (Display settings) - The controls in the center panel let you define the "wrapper" around the view results in your display: URL path, menu link, access, header, footer, pager.
  • Right panel (Advanced) - The controls in the right panel let you define advanced aspects of your display: relationships to make more fields available to it, contextual filters to make it behave differently depending on how it is used, "No results behavior" or what to do when your view comes up empty-handed, and "Other", most of which you'll never need to use, though adding a CSS class to a display can help you out of a tight themeing corner every now and then.

View preview area

The bottom area of the edit page shows you a preview of the current state of the selected display, automatically updating it as you make changes, unless you clear the Auto preview check box. Each part of the preview also has pop out gear menus that show you the current view settings and give you access to controls to make changes.

Note: The screenshots on this page are based on the options shown when editing a page display of a view of content. When editing views of other items (including users, comments, and taxonomy terms) and other kinds of displays, the options will be similar, but may not be identical.

 

Tips

  • Making and saving changes - All changes you make to your view on the edit page are temporary until you click Save. For example, if you change a display title and click OK in its dialog, the change will be lost if you leave the main view edit page without clicking Save.
  • Use administrative names and descriptions - Many elements of your views allow you to add optional descriptions or names. It will help you manage your site and keep track of your views, displays, texts, and so on, if you take advantage of this. Some places you can add administrative descriptions or titles include: the description of the view itself; display name (especially if you add more than one display of the same type); header, footer, and "no results" texts.

 

Configuring the View

Existing Views can be edited on the View configuration page. There are two ways to access this page:

  • Find the View on the Views listing page and click “Configure view” in the Operations dropbutton
  • Hover the mouse over the actual display of the View (for example on the “/all-my-content” path for the View created above) and select “Configure View” from the contextual links menu.

Below is a summary of the most important settings, in the order they are usually configured when creating views.

TIP: Views that never have been saved may be lost if leaving the Views main panel. It is a good habit to save your view early – note that the continue & edit button doesn't save it for you. A view displaying error messages cannot be saved until the error is addressed.

 

Configuring filters

A good start to configuring views is to set filters. A view will, by default, fetch all available objects of the data type the view is based on. Filter settings allow you to set criteria which limit which objects are included in the View.

For example, a node view will fetch all (accessible) nodes on the website. Filter settings makes it possible to restrict the results to nodes of a certain type, or nodes created by a selected user, or those that have been updated the last week.

 

Adding and editing filters

You add a new filter to your view by clicking the add link at the group filter criteria in the main panel. This opens a dialogue containing a list of all the data fields Views can use for filtering.

The magnitude of the list depends on the data type of the view. Node views have enough data fields to fill a few screens. You will learn a lot by browsing this list and seeing which options you have for filtering. Once you have become more familiar with the filtering options it is convenient to use the search or filter options to quickly find the data fields you want.

New filters are added by marking one or several data fields and clicking the button add filter and configure criteria. This opens another dialogue of settings, where you set how you want to restrict the selected data fields. You can for example require that the data field content: type should have the value article to restrict your node view to articles only. The options available depend on the selected data field. You can for example require that a node title contains (but isn't necessarily equal to) a given string, or that a time stamp is later than -7 days.

Hidden under the more settings in the filter dialogue is an option to set an administrative title to the filter, making it easier to overview your settings. If no administrative title is set, the name of the data field will be used – which works fine in most cases.

The filter settings contain two options that are described in separate sections. The checkbox expose this filter to visitors, to allow them to change it is explained in the section about exposed settings. The option configure […] for all displays in the dialogue head makes it possible to have different settings between (for example) pages and blocks for the same view. See the section about displays for details.

When you save your filters, the dialogue is closed. You can change settings for existing filters in three different ways:

  • You can change settings for individual filters by clicking their name, thereby re-opening their configuration dialogue.
  • You can create logical AND and OR groups from your filters by clicking the and/or option available in the menu at the add link for filters.
  • You can delete filters from their respective configuration dialogues, or from options available drop-down menu at the add link.

Click the Add dropdown, and select "And/Or, Rearange" to open the filter configuration dialogue.

TIP: Views does not automatically exclude unpublished nodes from its results. A filter to exclude unpublished nodes is added by default when a node view is first created, and if you remove this filter you should make sure that only trusted users are able to access the view.

 

Configuring view fields

As soon as the filters are set, and sometimes even before that, you usually add your view fields (labelled fields in Views, but here called view fields to separate them from entity fields). View fields are the data fields that the view will display to end users. Even if the view has access to all data about (for example) a node, you can choose to only display title, author and the time when the node was updated.

TIP: Depending on the settings in the Views quick-wizard, your view will either display entire nodes or single fields. To configure view fields you must have the row style (in the format group) set to fields. See the section about row style for more information.

 

Adding view fields

New view fields are added in the same way as filters. A click on the add button in the fields group will open a dialogue, allowing you to choose from all available view fields. By checking one or more data fields and clicking add and configure fields a new dialogue opens, where you provide further settings for each view field.

The settings for view fields are more extensive than those for filters and may vary considerably between different types of view fields. The settings usually include the following:

  • Formatter: This setting is available for entity fields, to determine how they should be rendered in the view. You can either choose the default formatting (according to the display settings for the entity field), or any of the other formatting options provided by the field and its widget.
  • Link this field to the original piece of content. This option creates a link to the node this view field belongs to. You may combine this setting with the output this field as a link option, to manipulate the link properties. (See the rewriting view fields section.)
  • Create a label: This provides the view field with a label, usually displayed right before the view field's value.
  • Exclude from display: This makes the view read and process the view field, but won't display it publicly with the other view fields. This may be useful in more complex manipulation of the view output. See the rewriting view fields section.
  • Style settings: These settings allow you to change the markup for the view field. This can make it much easier to style the view field with CSS.
  • Rewriting: These options allows you to change the content of the view field before further processing, including options to turn the view field into a link. See the rewriting view fields section for details.
  • No results behavior: With these settings you may affect how the view should interpret and react on empty view fields – for example by completely hiding the field (including any label).
  • Multiple field settings: View fields with multiple values can be displayed on a single row. These settings allow you to control how this should be done.
  • More/administrative title: The administrative title will be used in the Views interface to represent the view field. Setting a customized title is especially useful to tell the fields apart if you use the same view field multiple times in a view.

 

Editing view fields

You handle and edit existing view fields much in the same way as you do with filters:

The configuration for each view field may be changed by clicking its title, to open its configuration dialogue.

The order of the view fields may be changed by clicking the sort option in the drop-down menu accessed by the add button.

View fields can be deleted from their configuration dialogues or by a link in the drop-down add menu.

 

Configuring sorting

The settings for controlling how view results are sorted follow the same patterns as filters and view fields. You add new sorting criteria by clicking the add link in the sort criteria group, selecting one or more data fields to use for sorting, and selecting whether the sorting should be ascending or descending.

It is worth mentioning that more than one data field may be used for sorting. If so, any additional sorting criteria will be used only as tie breakers for previous fields.

Sorting settings can be exposed to site visitors. This is described in another section.

TIP: Most data fields are available as both filtering, view fields and sort criteria, but not all. There is, for example, a data field global: random available for sorting only, sorting the results in a random order.
 

More basic Views settings

You can make a View considerably more useful with the help of the following settings:

  • Title: A click on this setting opens a dialogue where you can enter text to use as the title of the view.
  • Header/footer: You can add elements above and below the view, for example to insert help texts. It is also possible to add views as headers and footers.
  • No results behavior (in the advanced settings): This setting controls what should be displayed if the view doesn't yield any results. An interesting alternative is to load another view, but you can also display text telling the visitor just how sorry you are that no results could be found.

 

Pager

You may limit how many results should be fetched by a view, and you can separate the results on different pages. You access these settings at the pager option.

The setting has four main options:

  • Display a specified number of items: This limits the number of results in the view and displays them all on the same page.
  • Display all items: This displays all the results at once.
  • Paged output, full pager: This makes the view fetch all results, and by default divide them to show 10 results per page – with a pager allowing the visitor to go forward and backward in the result. You may change the number of results per page, and you can also put a maximum number of pages to display. You can expose the pager settings, to have the user change these settings, see separate section for details.
  • Paged output, mini pager: This option is similar to the one above, but has a more compact pager (without an overview of page numbers).

All the alternatives above include the offset setting, making the view skip a number of results at the top of the list. If a pager is used you can also set a pager ID. If more than one pager is on the same web page, all pagers with the same ID will be affected by the same forward/backward links. This is usually, but not always, an unpleasant effect.

Some modules may change or extend the pager options.

TIP: Settings that include sub settings are in the main panel separated by a vertical bar, for example Use pager: Full | Paged, 10 items. When changing the main settings you are automatically forwarded to the sub settings, but the next time you want to change the sub settings you have to click the sub setting title.

 

Access settings

In the middle column in the main configuration panel is a small but important setting with the name access. It can be used to limit the access to the view in three different ways:

  • None: This means no access restriction – anyone may see and use the view.
  • Permission: This allows all users with a selected permission (such as administer content) to use the view.
  • Role: This allows all users with at least one of the selected roles to use the view.

Node views have the access setting to the permission view published content by default. Views showing unpublished content should have additional access restrictions.

 

Displays

Before a view can be shown on a Drupal site it must have one or more displays. Displays determine how a view may be called from Drupal. Without a display a view is only a database query with no way of being displayed.

A default Views installation has four types of displays:

  • Page: This makes the view available as a web page on the site, with its own URL and optionally a menu link.
  • Block: This creates a block of the view, which can be used on the site like any other block.
  • Feed: This creates an RSS feed at a given URL, and is optionally attached to other displays in the same view.
  • Attachment: This display item will be attached and displayed before or after other displays in the same view, much like using the header/footer setting and embedding a view.

 

Creating and deleting displays

You can create both a page and a block display in the Views quick-wizard, but it is also possible to add and delete displays at the Views main configuration panel.

All the configured displays are listed as buttons at the top of the main panel. A click on each button changes the main panel to show the settings relevant to the selected display. To the right of the display buttons is another button, used to add new displays to the view.

To the right of the display-switching buttons is the aptly titled edit view name/description button, used to change the name and description of the display. This is particularly useful to keep track of several displays of the same kind. Pressing the drop-down arrow indicator reveals options for cloning and deleting the display.

TIP: Among the items in the edit view name/description drop-down menu is an option for reordering displays. Changing the display order could be useful when access to the view is restricted, as the first display a visitor is allowed to access will be used, or if you have several attachment displays and you want to control the order in which they attach their content.

 

Display-specific settings

Most displays add a new group of settings to the middle column in the main configuration panel. Page displays, for example, add the options to set path and menu items, while block displays allow you to set an administration name for the block.

Apart from these settings, each display has three specific settings hidden in the advanced section:

  • Machine name: This is the display's unique name within this view. It is usually not displayed for visitors (except as CSS classes).
  • Comment: This setting allow you to add comments about how the view is configured. This is useful if it contains unexpected settings that other developers might overlook.
  • Display status: This setting allow you to disable the display, making it unavailable without deleting it.

TIP: Some display specific settings are required and will yield error messages if missing. Be sure to set all required options to be able to save your view.

 

Overridden configuration

Often you will want to have several views that display almost the same information, such as a page with the ten most recent news items, and a block with the three most recent. In these cases it is very useful to have several displays in one view and use overridden settings to vary each display individually.

When editing settings you will (when possible) get a select list in the settings dialogue header allowing you to select if you want to save the settings for all displays (except overridden) or for this display (override). The exact wording varies depending on the type of display you are editing. The latter option is used to apply your settings to the active display only and make it different from the view's default (master) configuration.

By overriding settings, one single view may be reused for many different purposes saving a lot of work.

There are a few more details worth knowing about overriding view configuration:

  • Display-specific settings cannot be overridden.
  • You may return overridden settings to their default values by editing the setting and specifying that the configuration should Revert to default.
  • When working with the Views 2 interface, overridden settings are indicated with a broken link in the Views main panel. In the Views 3 interface overridden settings are indicated with italicized text.
  • All groups of settings with add buttons are overridden as one unit – you cannot, for example, have a single filter configuration overridden and the other filters in default.

Elaboration: How far should I override?

When working with views you must often decide which settings should be made default values, and which should be overridden. One approach is to make the most common settings the default. Another approach is to keep all settings in the most-used display in default mode.

A related question is when to create a new view rather than create another display (within an existing view) where half the settings are overridden. One approach is to collect all displays managing the same kind of functionality in the same view. Another, perhaps more common approach, is to move separate displays into new views when too many settings require overriding. There may also be technical limitations forcing your decision. Feed displays, for example, can only be attached to displays in the same view.

 

Views formats

How view results are displayed to end users is ultimately determined by the view format. A layer of Views formatting, processing and wrapping the data when a view displayed is called to be embedded by Drupal.

A standard Views installation has five view formats:

  • Grid: This provides a grid with a configurable number of columns, with one view result per grid square. Grid settings include if the results should be ordered horizontally or vertically. It is worth knowing that the grid format uses a HTML table, which some would like to avoid to style presentation.
  • HTML list: This provides an ordered or unordered HTML list.
  • Jump menu: This creates a shortcut menu, linking to a URL provided by a selected view field. Format settings include whether the current path should be the default option in the jump menu.
  • Table: This provides a table of the view data. Settings include making the table headers click-sortable and the option to display several view fields in the same column.
  • Unformatted: This provides a list of the results without any special markup.

Each view format can have a number of extra settings. Many modules provide additional view formats.

 

Row style

In the Format settings group, below the Format setting, is the setting for row style, which is labeled "Show". The value of this setting can be either Fields or Content. The most common value is Fields, allowing you to select which fields to include in the view. This is sometimes the only option available (for example when the Format is set to Table), in which case the the row style setting is hidden. For node views the row style can also be set to Content. The Content row style displays each resulting node in one of the view modes available on the website, such as Teaser or Full content. In some cases, such as the display for RSS feeds, the row style must be set to Content.

If the row style is Fields, sub-settings are available, including the option inline fields. This can be used to show several view fields in the same row, with a configurable separator. There is also a setting for automatically hiding empty fields.

TIP: Using the content row style may be slower than the fields row style, since preparing a node for display in a view mode may require input from a lot of modules.

 

https://www.drupal.org/node/1578360

Sources: https://www.drupalgardens.com/documentation/views