Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now that you've seen how Drupal stores and displays data, it's time to start recombining it. The way we do that is with the module you installed at the beginning of the course called Views. In case you didn't install it, do that now along with the Chaos tools module that it requires. You will find them at drupal.org/project /ctools and drupal.org/projects/views. You will also need to enable the Views and Views UI modules. We will go back to our site and click Modules and as we scroll down you will come to a Views group down toward the bottom.
These are the two that you need to enable. If you've already installed C tools; that will automatically enable the parts of C tools you need as well. If you need help installing these modules, see the section about expanding a site's capabilities with modules in the Drupal 7 Essential Training Course from lynda.com. The best way to explain how Views work is to create a simple one, by way of demonstration. I'll be very brief, but don't worry; you will see all of this again in detail as we go through the rest of the course. To get there we go up to Structure and Views.
I will add a new view. This view will be called Simple list of employees. It shows only employees and I'll leave all of the other settings alone. Go down and Save & exit. And here it is. It looks very much like our front page, doesn't it? We can go back and edit it by going over to this contextual widget up here, click it and Edit view. That takes us straight to the Views settings pages. We will be spending a lot of time here throughout the rest of the course.
The first thing that I am going to do is instead of showing the content; I am going to show individual fields. So I click Content and then change it to Fields and Apply it to all displays. I will accept the defaults and scroll down to see what that looks like. Now we are just showing the titles. You might remember that we had the employee IDs in the title field. If we scroll up to this Fields area we see that's all that we are showing. It just gives us that one field to get us started. But I want to put some useful information there.
So I am going to add the First name, Last name, photo, and Department. Go over to add and search for a First name, add it. I will simply accept all of the defaults so that we can go through this quickly. Add the Last name. Remember, we changed that to Family name. Add it. We want the photos, so we click add again, search for a photo, add that, and finally one more, the Department, and add that.
There, now when we scroll down we can see what we have. The first few records didn't have photos, but then remember, this is the original size of the photo. We can go back and change that by editing that photo and changing it, so that it's only a thumbnail, and apply, scroll to the bottom and see what that looks like. Much better! I will just make a few other changes. The first one is I don't like the way that the shows all these labels and it's all just sort of one thing after another.
There is a very easy way to change that. I am going to change it from an unformatted list to a table. Apply and Apply to all displays. I am just going to accept the defaults. Go down. Already, it looks much better, doesn't it? But let's say that I want to be able to filter this depending on what department somebody is in. We can do that with exposed filters. I will add a filter, select Department, and then expose it, and make the label simply Department, Apply.
Now as we scroll down you see that people can actually select this to see only those people who are working in the field, very handy. The last thing that I'm going to do is to go back up to my Table settings and make all of the fields Sortable. Now not all of them will be Sortable;, for example, the photo really doesn't have any sort of sorting order, but all of the other ones will be. As we go down we see, yup, we can sort by the Family name and so forth. The last thing we have to do is to Save this view.
There it is on our page with the photos and all of the fields we put in. Amazing, what you can do so quickly with Views, but these are the things that we are going to learn in more detail as we go through the course. So I am just going to go back up to this view and keep things clean by deleting it. I'll go to my list of Views, find my Simple list of employees, and Delete. I hope that gives you an idea of the amazing power of Views to change how data appears on your site, and we've only just barely scratched the surface.
Most of the rest of this course in fact, is all about making Views do exactly what you want. We will start off easy, but by the end of this course, you'll see how you can do some amazing things with it.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 96855 Viewers
56 Video lessons · 110551 Viewers
71 Video lessons · 79390 Viewers
131 Video lessons · 38082 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.