Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
One data display often compliments another. Let's take vote counts from a presidential election, for example. A two color map that shows that leading candidate in each state provides one sort of information and that's a kind that's easy to understand at a glance. A table of vote counts provides details that would cluttered up such a map, but if you put the two together on a newspaper page then well, you get the kind of impactful informative combination that made USA today so successful. You can do the same thing with your Drupal displays. First, by changing some options in the Basic settings section of the Views administrative interface and secondly, by taking advantage of a kind of view known as an Attachment.
First, let's take a look at the Basic settings options. We've already touched on a few of these in other videos in the series. Now let's put all that learning in one place. I should warn you though, in my opinion, the Basic settings administration area is kind of a mess. It includes some pretty random stuff, and not all of it attaches information to your views. Here are some parts that do. In the Basic settings area, the Title and Header generally go at the top of your information, while the Footer, as its name implies, goes at the bottom. By default they're all turned off. That is, there is no Title, Header, or Footer.
We are going to go back to our View, and we are going to add a title, a header
and footer to the default, so we'll see them in the block and the page. Just to
be clear, I'm going to make the Title, This is the title, update it. The Header
I'll say This is the header, and update it, and the Footer I'll say This is the footer.
Now you may have noticed that with the header and the footer, we can actually
enter HTML or any other input format that we have installed in our Drupal
installation. In fact, I'm going to go back, and I'm going to change the
header, so it's a little bit bigger, I'll say
and close that tag, of
course. Make sure our Input format allows that by changing it to Full HTML, and
click on Update. Good.
Now let's save that, and take a look at our page. You see there is a title, the header, which as we made it bigger, shows up large, and then at the very bottom, we see the footer. Now let's go and take a look at how it looks on the block. We'll go to Administer > Site Building > Blocks, and turn on the block that we'd created called People block. We'll put that in the left-hand sidebar. Scroll up just to see where it is. Yup, it's going to be above the Navigation block, scroll to the bottom, and click Save blocks, and go back Home, and there it is.
We see how the header appears, but actually the title doesn't appear in a block. That's important to know that these header, footer and titles don't always appear quite the same way as you expect them in the different formats. In any case, we don't really want them to say this is the header, this is the title, and so forth. So let's go back and edit them and remove those things. We want to see what that block looks like, so we go back to our Blocks page, and turn on the block we created called People block, and we'll put it in the Left side bar. Scroll down and save, and as we scroll down, we see it here. Now you see there is the This is the header, and This is the footer, but not the title. If we go back and edit that view, we'll see that it's in Roman characters, not italics; we had edited that earlier, we had overridden it.
If we switch up to our defaults, we see our This is the title. Let's get rid of that default title, header and footer, we don't really need them. So I'll delete that and update; delete the header and update; delete the footer and update. I do want to mention this display even if the view has no result. Sometimes you'll do some sort of complicated view that will pull in information but won't always get any. In those cases, you might not want the header to show, because it would look strange. You can specify that right here. Click on Update though, and we have gotten rid of those default header, footer and title, although, of course, we still have that title in the block, because we overrode it. Click on Save. Good. So that's the first way that you could add information to a view.
The second is using Attachments. To get there, we'll go back to our View, under Administer > Site building and Views, and Edit the People view. The one that I want to work on is this Recently added here. I like the way it is now. It's showing the three most recently added people to our site, but I want the first one, the most recently added to be bigger than the others, maybe have a headshot there. We can do that using an attachment, and by changing the way that this particular block is arranged. The first way I'll do that is create the attachment. Go to Page, and Attachment, and Add. For the Title, I'm going to override it. This is just going to show the very most recently added person. I'll override it and say Welcome our newest member, and update.
Again, this is going to go in the block area here, so we don't need all of the default fields. We are still on the Attachment display. Remember to always check which display you are working with, and I'm going to override the fields, and then click Update. Now I'm going to remove all except for the Title, and the headshot, I click on the Rearrange button, which brings up our option of deleting multiple fields at once. Click to delete the ones I don't want, and then click Update. Now here is something interesting. We don't actually have a preview of the attachment, and is obvious the way as we'd like. When you go down to this preview, you have to select the thing that you want to preview. Take a look at our attachment and there it is. It's just the name with a headshot. I'm glad I did that too, because I don't really need the word Name there. I'll go up and get rid of that. Scroll down and update. There, much better.
We can do even more by making that name bold. To do so, we go over to its field, which remembers the Title, and then scroll down so that we can see all of our controls. The part we are actually going to change is we are going to rewrite the output of that field, by clicking in this box here and then adding the title itself with bold tags around it. Now how do we add the title? If you look down, you see these replacement patterns. There is only one available to us here, the title. So we'll copy it, and paste it in here, and then add our bold tags before and after, and scroll down and click Update and see if that works. Indeed, everything is now bold.
Now let's go back and remember why we are doing this. We have that group on the side of the screen, which shows what are most recent members are, but we want the very first one to have this name and photo. To do that, we have to have it sorted, so that the most recent person comes to the top, and at the moment we have the exact opposite, the oldest person, the first one that we added comes to the top. So let's change our sort order first and foremost. We have a default sort order to have it going from oldest to newest. We have to first override that, we'll click on Sort criteria and scroll down, and click Override, so that we don't change the default display, and update. Now, of course, that didn't change our sort order yet. It just said that when we do change it. It's not going to affect the default display. And we see that it's in Roman characters here, so we know it worked. We'll click on that again, scroll down and change it from Ascending to Descending and click Update. We know it work because there is our most recent person, Dani. Very good.
The next thing that we want to do is show only one person with the picture, and then everybody else will show up. So this first one over here, Danni de Nada, should have her picture but then Dave and Sophie should not have their picture showing. To do that, we scroll up and we see how many items to display. It's in italics. That means that our attachment is using the default value. The first thing we have to do is to override that. We do that by clicking on the value, go down and click Override and Update.
Now we go back up, click on the value, we see it's in Roman, so we know it worked, and then we can change it just to 1. I always do this in two steps, by the way, just to make sure that I don't change the default value. I've done that a few times, and it could be quite messy when you change the default values, then go back and see that your pages were all sorted wrong, and have the wrong fields, and so forth. Anyway, we'll click Update, and now we should only see Dani, and indeed we do. Very good. The next thing that we want to do is make it so that attachment appears above this block. The way you do that is in the Attachment display here. Down at the bottom we have the settings that are specific to attachments, and we see Attach to, we want it to be attached to the block, so we click on that None, and that shows us what our options are.
We can attach it to all of them, the defaults, just the Page, just the Block, or any combination of those. We just want it on the block, and we click Block and if you look up, you'll see we have a choice also Before or After, but we want it Before, so that's fine. Click Update, and then click Save. Let's take a look at what this actually looks like on our page. Aha! We are almost there, we have the picture that we wanted, and the person's name in bold, but then underneath it, you'll notice something; we have the person's name again. We have it showing once with the picture, and that's the attachment, and once with the block. Let's go back and fix that. Click on Edit to go back to edit the view, and then we want to change the block. Remember, we have the attachment showing one object, and then we have the block showing three more but repeating the first one.
We click on Block, and change Items to display. Fortunately this is already overridden, so we don't have to do it again. Click on it, scroll down and see what we have. Here is where the magic happens. We want to show 3 in addition to Dani. We could change it, of course, but let's say we want to show 3, but we are going to offset it by 1. Click on Update and now instead of seeing Dani de Nada here twice, we should just see it once. Update and Save, and there you have it. We now have Dani followed by Dave.
There is one more thing that I'm going to do. I want to separate this graphic even further from the rest of the people. So I'm going to put a line between them. To do that, I'll go back up to Edit, and add something at the bottom of the Attachment. Now you might ask how can you add something as arbitrary as a line? Well there is a Field control you can get to by clicking on the plus sign, and then scrolling down, and under Groups, select Global. Here you have the option of putting any text you want. I'll select it and click Add, and I don't really need a label; it's just going to be the text itself, and the text I'm going to add is going to be a break, followed by a horizontal rule, followed by another break. That will put a little bit of space around the lines. Scroll down to the bottom, Update, Save and there it is. There is our little line.
We'll come back to using attachments in another video, and in fact, they will play a crucial role in making our final site a real doozy. One technique I'd encourage you to learn is to keep your attachment small. Very often it works best to have attachments as introductory or side content that frames a view's main display sort of speak. If you throw too many big different attachments into the mix, the point of lost, the page or the block can quickly get but if you keep them simple, as we've done here, they have quite an effect.
Get unlimited access to all courses for just $25/month.Become a member
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.
Your file was successfully uploaded.