In this example you will create a page view listing users on your
site. Through this step-by-step process, you will become familiar with
some basic steps in creating a view, and familiarize yourself with the
Views User Interface.
Creating a new view
Go to add new view. Give your new view the name ‘user_list’, description ‘A simple user listing.’, tag ‘users’, type ‘User’ and click Next.
About the Interface
You have been brought to the Views User Interface. As you start, you
are editing the “Default” options for the view. In the 1st column on the
left you can see the drop-down menu offers ‘block’, for example, to
select settings specific only to block views. In the remaining columns,
you will be able to add or change options by clicking on links or icons.
These options will then appear below this main area. Most likely, you
will need to scroll to see the options appear. As you make changes,
these options will appear in bold until you save your view.
Creating a page display; choosing a URL and creating a menu link
- In the 1st column, ensure that ‘Page’ is selected in the drop-down menu, and click Add Display.
- Next we’ll define the path for this page. A page must have a path,
and we define it early so that Views doesn’t warn us “Display Page uses
path but path is undefined.” Locate the Page settings in the 2nd column, and click the None link next to the Path
setting. In the options editing area that appears below, set the path
to ‘user_list’ (or something else if you prefer) and click Update.
- Next to Menu setting, Click the No menu link. In the options which appear below, select Normal menu entry, and set the title to ‘User list’ and click Update.
- Scroll up to Basic settings, in that same 2nd column, and click the No link next to Use pager. Below, in the options, select Full pager and click Update default display.
Selecting the fields to display
- In 3rd column locate the Fields options. Click the + icon to add fields.
- Scroll down to Defaults: Add fields. In the Groups drop-down menu select ‘User’, then check the following fields: User: Created date, User: Delete link, User: Edit link, User: Last access, User: Name and User: Picture. Then click Add.
- You will be taken through the fields you added one at a time. Click Update default display to go to each next field. Leave the default options on all fields except Delete link; change that field’s label to ‘Operations’.
- Scroll back up to Fields and click the ↑↓ icon to rearrange fields. Down below, drag the Name field, by dragging its four-sided arrow, to the top. Drag the Delete link (Operations) field to the bottom, and the Edit link field just above it. Then click Update.
Seeing what we’ve done so far
At this point, you have done enough to create a valid view. If you
scroll down, you will see a preview of your view. If it doesn’t show
already, click the Preview button; but generally this display updates automatically whenever you finish working in one of the mini forms.
Styling the view as a table; combining related fields into columns
- Under Basic settings, in the 1st column, click the Unformatted link next to the Style setting. In the options below, under Page: How should this view be styled, choose Table and click Update default display.
- You will be taken to a Page: Style options form to edit the table settings. Locate our Edit link field in this mini form, and notice the Column drop-down. Change this drop-down to show Operations. In the Separator column next to the Operations field, type ‘ | ‘ (note the spaces around the | symbol). Check all of the Sortable checkboxes, and set Default sort to Name. When finished, click Update default display.
Filtering the user list to exclude unwanted entries
- Click the + icon next to Filters.
- In the Groups drop-down menu select ‘User’, then check the User: Name filter, and click Add.
- Select Is not one of and enter ‘Anonymous’ in the Usernames box. Click Update default display.
Adding an argument to list users by role dynamically
- Scroll up to Arguments, and click its + icon.
- Check the User: Roles argument, and click Add. Set the title to ‘%1’ (don’t type the quotes), and under Action to take if argument is not present select Summary, sorted ascending. Leave the other settings as they are. Click Update default display, and click Update through the prompts that follow to accept their default values.
Saving the view
Finally, click the Save button to save your work. At the very top, click View “Page” to go to your new view!