Home / Taxonomy term


How to Create Single-Page Apps With Drupal [May 28, 2013]

Drupal Essentials: How to Configure Accounts in Drupal [May 22, 2013]

Ce que les Chef de Projets doivent savoir sur Drupal [May 21, 2013]

The Practical Guide to Selecting a Web CMS for Media and Entertainment Firms [May 16, 2013]

Views Mini-Course, Part III: How to Back Up Your Views Safely [May 15, 2013]

Drupal for Publishers: How to Build a Better Newsroom CMS [May 14, 2013]

How to Power a Rich Video Experience with Drupal [May 9, 2013]

Views Mini-Course, Part II: Creating Flexible Views with Drupal 7 [May 8, 2013]

Click to see video transcript

Hannah Corey: Today’s webinar is Views Mini - Course Part II: Creating Flexible Views with Drupal 7 with our manager of training, Heather James. We’re really excited to have her doing the series with us. I’m Hannah Corey. I’m a marketing specialist here.

Heather James: So this is me. I'm Heather James, as Hannah was saying, manager of training the program at Acquia. Our training program, you can see the events there up on the website, we have them all over the world. I actually counted 80 events just in the U.S. upcoming in the next couple of months. Our course materials are actually maintained in-house and we’re continuously updating them. It lets us keep on top of the latest developments and make sure it’s fresh as well. Our trainers are actually our partners. So these are folks who are experienced developers. I have to say - I love to say, they actually like getting away from behind the computer and helping people. They’re the kind of people that others in their company go to for help. So as subject matter experts, they’re really good. We can also provide tailored packages as well for your teams. So please contact me if you have questions.

So we’re in the second part of the Views Mini Course: How to Build Flexible Views. Next week is the last part of this course. These three parts are just an introduction. Views is such a powerful module. I could go on forever on Views probably. After that we’re going to follow up with one class, just on how to configure accounts in Drupal. Something quite simple but people often get a lot wrong with it. Then we’re going to have a four-part mini course for product managers. So I'm very excited about the folks - my colleagues who are going to be helping out on that course this summer.

So what we’re going to do today is look at how to build flexible views. We’re going to see relationships, attachments, contextual filters. So probably things you may have heard of before and hopefully some things you haven’t considered yet. So if you’re watching this webinar, you need to know a bit Drupal already such as how to add content, customizing content types, installing and configuring modules. So we’re sort of picking up from last week as well. So I’ve already explained how Views work and how to add a new View and just manage displays.

So just to recap what we covered, if you go to j.mp/acquiaviews1, I've got all the notes from last week’s class up there. You’ll be able to follow along with what we did. There’s also the recording as well. So what we covered last week were the main concepts of the workflow. If you need to think about Views, think of it in two parts: first what you’re selecting and then how it should appear. So we talked a bit about selecting a base table and then applying various filters and then choosing formats and displays. So just keep that workflow in mind. You’re choosing what you’re querying, you’re limiting your selection and then selecting formatting and displays. As long as you understand at this stage that Views is a query builder, then we’re set to go and we can continue on and dig deeply into the Views UI.

So one thing I said about the Views UI last week was that the Views wizard disappears. So I’m really not going to focus on the Views wizard. Just think of it as a way to get your quickest settings completed but quickly you’ll be moving into the advanced Views editor. So we’ll spend a lot of our time there. This is how we sort of broke this up last week into these two mains section, what to filter and how to format and display. So we’re going to look at, for example, field formatting, filter criteria and how you can actually expose filters, sorting and how you use sorting, for example, in tables, and we’re going to look at contextual filters, number four, and relationships, number five.

We’re also going to look at - I did touch already on attachments last week because I had a little bit of extra time. So I will touch on that briefly. We’re going to focus a lot on number two, formatting. Then in three and four we’re going to look at the page settings and how you get access control, and number five as highlighted there, the pager, and number six, exposed forms. We’re probably not going to use those much in the session but just to call your attention to it.

So let’s look at formatting and display. There are a number of formats available. You’ve already seen me use, for example, the HTML list last week or the unformatted list as well. There’s also something called a jump menu. So in this example, on my site, I got - showing here in this block a level jump menu. You might have beginner, intermediate and advanced. So that’s one example of how you could use the jump menu with the taxonomy terms.

There’s also table formatting. So table formatting lets you actually put each individual field as a row in your table. When you’re doing your table formatting, just as a tip, make sure you customizing labels and making those columns sortable. People generally expect with dates that they descend in order from most recent on top down. So just try and use these sorts of standardized controls. I’m going to give you a demo but I just want to say as a note, if you’re going to add, for example, a new table, think about how your users are already accessing the table base data. So, for example, we have the title, then the date, then the operations, for example. So if I’m going to add another admin view, I should follow that same order. Overall, just with anything you add in Views, just be consistent across your site. If you also find with Views that you’re doing a lot of custom formatting such as rewriting output fields or, in this case, you can see it’s quite small in the screen, how to do a custom date format. You might use this little J, big N, little Y to change how your short date show up, if you’re familiar with that PHP formatting. If you find yourself doing this kind of thing a lot using this custom date format, then change it across the whole site. Go into your date and time settings and change the format or add a custom format for your short date and change the short dates all across your site. So you really want to think about that reusability. So instead of going and trying to do it custom every time, use the short format that you’ve customized just all across the site. In general, we’ll kind of keep that in mind as I do the demos today. Just try to think of reusability all across your - as you’re developing, I should say.

As well, use the default view mode. So if you find yourself doing a lot of field configuration and display configuration within Views, you might be interested in trying display suite to create these custom view modes. I had decided not to go into display suite today because I think it might make a good class on it is own and there are some great materials out there for display suite but just so you can know. The view modes - we talked a bit about this last week. Here’s a teaser and the full content for some website here. Try to use the display suite view modes instead of always of doing fields formatting and views. I guess this just goes to the point, try and reuse the image styles across multiple different areas on your site. It's going to make everything so much easier. So just as a principle with Views, be consistent, think of reusability, think of who can access it, who’s actually going to use the content, and how they need to access it.

So speaking of access, I wanted to just first mention that we should consider, when we’re creating Views, who’s actually going to get access to the content. We’ll actually be looking at this in more detail in my first demo. I should call your attention to the fact that if you’re going to set by access, it’s most easy to do it by specific permission rather than a role. You may be tempted to say, “Oh, give all administrators the access to this” or “all editors access to this.” You may find in the future, you’ll add another role who has some more permission. So do it by, for example, permission, in this case, whoever can access the content overview page for example.

So the next point is filters. So filters actually - mainly what we’re doing with filters is limiting the selection across the whole site. I’m giving you an example here of an exposed filter because I think you saw filters last week. What I didn’t show you was actually sharing it across the site - I’m sorry - sharing the access to the filter with peer users, that’s what I mean to say. So in this screenshot you can see that someone can type in an author name and apply it and see just the list of that author’s content. So I’m going to do a demo just to show you that. We’re going to edit an existing view I’ve created and we’re going to expose the filter to viewers and even insert an edit link for administrators and change the path and the access control as well. So I’m just going to go to my site here. So I’ll go to my structure Views list here and I’m going to go to content by user. So here’s a view I made earlier.

First I’m going to show you what it looks like from here. I’ll show you what I setup first. So I made a list of content. Not a user list but actually a content list. So we have the fields, titles and post date and it's formatted as a table. So I’ll show you what that looks like. So this is just showing me all the content across the site. What I can see is if I pick a specific author and start typing their username and click apply, then I can just see all that content by the author. The reason I made this is because when I go to my normal content list, one thing I find frustrating is that there’s no way for me to browse the content by author and can’t even sort on this author field. So as a content editor or site editor I find this really difficult. So what I’ve created is another view, and you can see how it’s showing up here in my administration interface. It’s actually showing up as a tab on my content menu here. I made it so I can browse. So what I’m going to do to this is add an edit link here. We’ll develop that throughout the class today.

So let me show you, first of all, how we expose that filter. So the filter we added was the author ID and I could have specified a specific author. I’m just going to deselect that there. I could say, for example, just show me content by a specific author, site admin, for example. Instead, if I expose it that let's anyone who’s looking at it to choose their author. So do author name and I can say type the author’s user ID, username. So here we go. So let’s see how that looks now. So you can start to see how it gets much more helpful. I’m going to add another field here which is going to be an edit link. So we often think of all the different ways that you use Views on your site but the administrative views are really helpful. So there we have the edit link. Cool. So it’s getting somewhere now. I’m going to save it and then just refresh this and see what changes we have made. There we have the link showing up. The other thing I probably want to do, as I was talking before about table formatting, is letting people sort. So I’m going to change it so you can sort on the title. So I go into the table settings for that. I can make that field sortable. As I was mentioning before about date sorting, people expect that the default order is descending. So I’m going to make the post date the default and I’m going to make the most recent stuff show first. So I can save that and refresh and see what changes there are. So now the content is sortable by title and by date.

So I'm just going to go back to my presentation briefly and talk a little bit about pagers. I will actually talk to you about the menus to tell you how I got that menu up there but we’re just moving swiftly along. On your Views, you’ll have to decide whether or not you need pagers. Here, I've show you the configuration options. For example, for this block here, on the right where I’ve actually set it to have a mini pager and just show me three items. If you’ve been using a lot of websites now as well, you probably noticed the infinite scroll. I didn’t install that module myself because it gives me vertigo but it’s very popular. It simply means that instead of having a pager at the bottom, it would continue to load the additional - to load the additional list. I'm going to give you a demo of that block just on the site so you can see how that works with the Ajax loading for the sidebars. Then I go back to look at the site here and I can see that news article block in the side. Hopefully you can see that okay. So the Ajax loading means that I can load the next list of content without having to reload the whole page because it’s actually pulled in all the results. So I’m going to edit that view and show you where that setting is. So I'll go down to advanced and look at Views, Ajax, yes. It’s really a simple toggle of yes or no. By doing that, like I said, all the content gets loaded. So what you don’t want to do is use that setting on, say, a view that lists all the content on your site. That would be a lot of content at once. You want to be careful, I suppose. I think it’s pretty useful in the sidebars though, sidebar blocks too.

Now I’ll show you the attachments. We did talk about this briefly last week. I gave the example of listing the news articles on their site and then having just the titles of these, say, older articles. That just allows us to get more content up and probably makes it a little easier to browse. So let’s just look at what we did last week. So here are our news articles on the front page. I have three or two articles showing up and then three articles showing up in the attachment here. So I’m just going to edit the view. Here is the regular list. So that’s just showing us two items. That’s showing an unformatted list. I’m just going to scroll down so you can see. Fantastic. These are kind of - it’s just showing the title, the updated date and image. The attachment - if it loads today - is attached to that display. So when you do your attachment positions, you can actually choose whether it’s before or after, whether it, obviously, inherits different filters you set. Then, finally, you can set it to skip three or I should actually say skip two in my case because I’m only listing two items of content. So that basically lists the upcoming kind of older news, for example. Save it and go down. As soon as it refreshes - we’re getting more news now. At least.

Okay. So then I want to show you relationships. So we spoke about this last week that the first decision you make, especially when you select the Wizard is what your base table is. That’s content - sorry - content or users or taxonomy terms. You can’t change that later but what you can do is get other data from other tables. So say, for example, you’re making a list of users. You would not have access to any content because you wouldn’t - it’s the user table. So what you actually do is make it join on what content was authored by a specific user. Here’s an example where we’re using a module called Entity Reference. Entity Reference actually is on the job listing and there’s a company referenced, there's another type of content node of any selection they want.

So in this example, that becomes a type of relationship you can reference. I think it’s a little confusing until you actually see the demo. So what I’ll do is actually just do a demo and show you what happens when you add a relationship to something. So let’s see. I’m going to go to my structure Views and we’ll say, add a new view, and we’re going to say user list, busy, busy users. So we’re going to show a user list and we have a page automatically created. As you can see, that was my base table, the choice user. I won’t be able to change that later. So we’ll see here, if I want to add some additional fields, let’s say I want to add the user’s name - that’s not showing up for some bizarre reason. I’m just going to cancel this and see why that happened. I’m not sure. So add new view. Add busy users, users and - I actually didn’t check the display format. I really meant to choose fields. So the calendar at the end is available because I have another module that’s installed which I’ll show you later, which is calendar.

So here we have a list of usernames. So cool. It got usernames here. I only want to see the users that have posted content recently, and I want to see what that content is. So, say, a title from a recent post. So if I go to fields here and I look for something like titles - it’s not showing up - or content, nothing, and say, article. Nothing is showing up in terms of anything related to - kind of like nothing related to content will show up because I’m just in the user table. As we can see, the only thing that’s available are user fields. I’m just kind of belaboring the point of it. So what we’re going to do is add relationship. In case we’re adding it by author. There are so many relationships that you could actually add. I think that what you probably want to do is when you add another module such as Flag or Entity, is to see what relationships became available. In this case we’re just going to stick with nodes. So we can see now the user content that’s been authored by a specific user.

Now, when I go to add field, I should see content title. So now that - as you saw before when I tried to get anything related to content it wasn’t available but now it is. So just to move things along a little bit, you can see here I have some users that have no content and some users are actually quite busy. I’m just going to go jump ahead to this one I've made earlier because I just want to speed things up a little bit to save the time. So what we’ve done here is that we’re actually using the latest post as a way to filter. We don’t want to see people who haven’t posted to content. Remember it’s just showing the busy people and we only want to see content of course or recipe type. I don’t really want to - I don’t care if some site administrators have posted a basic page on the site. I want to see those who are contributing new content. So that’s actually used then as a filter to kind of filter out anybody who is not busy. So we can see a specific user and then we can see their actual - whatever content they’ve post. So we can actually - I think I should rearrange those fields so it makes a little more sense. Username, picture, role. Here we go. So you get a username, what their role is and then what their latest post was. It wouldn’t have been possible without their relationship. I've got so many things to show you. Let’s see how much time we have.

Okay. The next thing is contextual filters. I guess this is probably something that is so widely used and I think it’s kind of confusing at first. To be honest, a lot of the configuration is honestly confusing. The terminology doesn’t make a lot of sense. I know they worked really hard on it but we’ll just work through it slowly. So I want to give you an example of our site where we’re looking at a course called cake decorating. This is an all level course. I want to see any recipes that are also related to all levels. So that would be an example of using a contextual filter. Another contextual filter example would be - I’ll show you on the website, our own website. If you look at my user profile, you can see my recent blog post. So what it’s doing there is looking at every single user, basically they’re checking by their user ID. Is there any content by this user ID when we’re looking at this user’s profile? Let’s list it out here. So in the previous class someone was asking “What if you want to have 250 views?” My guess is that if you want to have that many views it’s something you can do programmatically like this using contextual filters. So let’s think of it that way. It’s sort of a way you can get through a lot of content. Let me see.

Okay. I’ll just do a demo really quick. I think I got time. To show you - using a block view, we’re going to pull in a user ID and select, sort and format the content. We’re going to do that user profile. I can also show you the recipes one as well. So I’m going to go back to - look at our user page. Let’s say we look at a particular user here. We don’t see any content by this user just yet. So what we’d like to do is have a list of their titles, anything that they posted to the site. So I’m going to go to structure views. Probably at this stage you have a pretty close idea of what I’m going to do now. You’re now going to go show content. I’m going to show – I’ll type all. I’m quite happy to do that. I don’t need a page, actually, in this case. Probably the first time we’re just seeing - creating a block. We’ll do an HTML list of titles which is good enough for our needs now. So as that is, actually just from having done that, I just want to show you. I'm going to click save because it is quite helpful to see. Just from having done that one thing using the wizard, making a block, a block is now available under structure blocks. User content list here. I can actually place it right under my content. So here is my page content. I'm going to show it on the user content list. So if I go to my user profile I’m going to go by - look at this user again. We’re seeing all the content by all the users on probably all the pages. So we don’t want that, right? We want to limit that block to only show up on user profile pages which in this case - let’s go back to user page. We’ll be under users as a path so we’ll use that.

You can also set that block to show up only on specific content types or for specific rules. In this case, we’ll only list it on pages that start with users. I’m putting in the wild card there. /and * makes the wild card. So we’ll use - those work for anything like a user profile. So I go to refresh here, still seeing it on the test editor page but I am not seeing it on, for example, my homepage. Okay. Cool. So let me go back to that user content list here. I’m going to edit the view from here. So you may have seen this or see me do this before using the contextual link. It's kind of a quick link. What we’ll have now is a chance to just filter out whatever that user’s content is. So we looked at the users/ and then the username, and that’s what is in the URL and that’s what is available to Drupal. So we’re going to look at it - the author ID. As you probably guess, there is no other filter available because this is the content view. This is not a user view so none of the other user information is available. So we’re going to use a user ID from URL. That’s when the filter is not available. When the filter is available we will specify validation criteria. That will be to a user. I have user and we don’t have to do anything. Okay. How to handle it if doesn’t validate. So if there isn’t anything, you can just hide the content or you could have something like a no result found message. I'm going to leave that. Actually, I have a better example of that later. So we will - I’m just going to double check here. Okay. It should be okay. As you see in the preview here, we’re not getting anything actually showing up because we don’t have a user’s ID setup. So if I put any user ID and click update preview, it’s going to check by that user one which happens to be like the site admin. I think there's probably a user two. We’re seeing different content, and user three just to show you. Here we go. So we’re seeing different content by different users. That’s not going to impress you, really, until you actually see it in that user’s page. So after I click save you’ll notice I’m brought back to the view where I was editing it. So here we’re seeing the user - test editor’s content.

Let’s prove it by looking at another user’s content. So we’ll go - which one did she or he not edit? Okay. We did all of this. It's the same user. Here’s the test editor and we can see this user’s content list. So this is taking the user’s ID from the URL and changing what’s available or what’s displayed based on that contextual filter, whatever that context is. One thing - I guess I’ll - I think I have some more things to show you. There’s more fun stuff to show you there. Sorry. You know demos are so fun. I'm just going to show you the related recipes because I think that’s another example that’s helpful. So say, for example, you're looking at a particular course such as introductory baking which is available, I think, I said to all levels for this example here, that's the term. Here's the related recipes by all levels. So I'm just going to edit that view and show you how that works. So this is, again, it is actually just a block view as well. Here we have the - contextual filter is actually the level. So that's the related - you can think of it as the related field between the two pieces of content that I'm relating. So courses and recipes both have levels in them. Here I can show anything that’s related by the specific vocabulary. So there's option there for vocabulary where you can load the default filter from the term page, load it up from the node pages, so that's good for related taxonomy block. That's kind of the key thing you need to do. In my case I limited just by specific vocabulary but you can imagine by selecting multiple vocabularies, you can actually have a much more organic way to relate content all across your site. I also overwrote the title in this case. So when we see the block, you'll see this basically the level name is being pulled in to the block title. So there we go. That is - the last part is defining the validation criteria when a filter is available.

What I thought was useful to do is if there are no results, you can display the content of no results found. If we go back - I haven't shown you this yet but if you go to no results found, you can have, for example, just text message: “There were no related recipes, why not add one?” You can add a link then to your - to prompt someone, if there is no content, at least try and go and add some content. So you can think of ways to encourage content creation instead of saying there's no results here. So this is what would show up if there were no results in there.

Okay. The last thing I'll show - no, there's a few more things I want to show you - is adding a link to your menu. So you can actually create menus with your Views as well, menu tabs. You can also create a link from Views to any of your existing menus. So I think this is something that’s actually quite often overlooked. I wanted to show you how to do this because, especially if you're making administrative Views, you may want to leverage that. So in this case I added the content by user as a menu tab, in fact not just a normal menu entry, as you might do in other examples. I put it into the management menu. The actual path, the page settings, the path, is part of what determines where your menu is going to show up in the future as well. I'll give you another example of that too. What happens in this case for this view is that the tab shows up under the content list. I've also noted here that the permissions is something we talked about before but that is also going to make sure that it shows up in my admin area and only administrators can access this view. So that is the access to the content overview page.

So another - I think I may have shown this to you last week. It's interesting to me because it's something I use all the time, is sort of - this is actually a menu created with Views. So if I go - this is on my website and it's actually built on Drupal 6 but I think it's useful to see because it's just quite handy if they have events in Europe or Canadian events. So I will go to edit this view and show you how that works. So as our menu tab here, for example, the tab is Canada, it's a menu tab and I have set the weight, for example. I've done the same thing for Europe. I've added a menu tab. Still loading] options for Canada. It's the same thing for Europe, added a menu tab and put in the link there. What they're doing, actually, in the view is showing up as links between each other, between each of the displays. The defaults - I'm sorry. The default tab here is set as the U.S. - I'm sorry. The U.S. - the default tab is actually set by the top level menu item or - sorry - the top level of the path. So that's events/ and every other one of them is showing up the child items basically, if that makes sense. I hope that shows maybe a bit - if I go back and look at the view it might make a little more sense. So these individual displays are actually just links between each other in the menu tabs, using menu tabs.

Okay. So I will show you this to demo how to add a menu to your – how to link to one of your menus. I'll also show you how this one works, the content by user one works. So back to our - right here. If I go to the content list - I'll show you, I've already set this up but I'll just go and click edit view from here. You can see the menu option is set as a menu tab within the management menu. So it's going to look for who the parents are in this case. I could have also done a normal menu entry, in which case it won't show up as a tab. I'll give you an example of a normal menu entry now. I'm going to go to structure, views, and I'll give you a recipes. We have a lot of my recipes here, and I'll add this. What I'll do is add it into the menu. I'll show you where I want it to show up, actually, first. That's probably useful. Go back to home. So I got this top of the menu here about all courses, home. So this is my main menu. So what I was going to do is in my menu settings, do a normal menu entry, my recipes, and set it to be in the main menu. I can have it be heavier or lower. Negative numbers are going to bounce up. So I'll put this as a heavier number. So let's see how that works. Save that and go back to my front page. You'll see the menu showing up there. Like I said, you could actually place that link anywhere on your site. On my own training site, I don’t know if I still have it up - never mind - I use that to put in administrative links as well. So there you go. That is just briefly how you can add in menus. You can create as many menus as you like.

Okay. So there are actually so many modules that really love Views and work very well with Views. There's a lot that actually give you templates, calendar is one of these modules. It actually creates kind of quick and easy templates. I'm just going to give you a sense of how that works really quickly. So it used to be - if you're familiar with calendar from Drupal 6, it used to be that it would create kind of a format or field formatter but now it's not. So I'm going to show you. Under structure views, you see here we have add new view, we also have from templates. So this is sort of new with Views 3 if you're new to it. Here we can see, for example, calendar templates as an option. So I can actually create a calendar view of specific fields. Here's field date or last comment or - we’ll just show created field in the - or field date in the node base table I guess would be an example. I think this field date is actually a good example because it's related to my courses and it's not related to my content, just my regular content updated dates. So here we see in the calendar and here we can see an upcoming course. Well, there's one upcoming course anyway. That's basically what calendar does. It creates these kind of quick and easy to make Views templates. It does allow you to do quite a bit customization. I think the great thing is that it comes with all the CSF, formatting just works and it's really a quick way. You could use this to browse content on your site. You could also use it to, obviously, show events listings like that. There are a lot of different displays, week, day, et cetera, that are available. So I'm just going to publish this. [Or save it I should say, and I'm going to click to view week. You can see that similar to the menus I showed you in my Drupal 6 site, you can see how this multiple displays are showing up as menu tabs. So that's quite helpful. Okay. So that's the calendar module.

There's a lot of different ones actually that use jQuery, for example. There's probably as many modules almost as there are jQuery plug-ins, it seems I think, of these types of plug in. The most popular one that I'm aware of I think is slideshow. This is a really handy tool. It's actually giving you another format. So I showed you the jump menu or the table. Slideshow becomes one of the options you have. So you can select how quickly it goes. You can select even the image type. You can even have - text can be in the slideshow. It doesn’t necessarily have to be in pictures, I suppose.

I wanted to talk quickly about the various modules that assist administrators. This is something that is often forgotten when site building with Drupal. It's so worrying because when you see the regular content list in Drupal, it's just - there’s so little you can do with it and it's hard to configure. I even get frustrated just not being able to see my own content so I almost insist on every site that there's some way you can see your own content. So here we see the example of Views bulk operations. I'm actually going to do a demo for you. I want to show you quickly Workbench is another one of these modules, similar to calendar which is actually built with Views. So Workbench is actually a set of views. They just work out of the box. It gives you a list of your own content. It gives you quick access to probably everything that you want to see when you are a content editor, what you've edited, what you've added and quick links to edit content. So it almost seems to me a given. If you're going to build a Drupal site, you'd probably want to put Workbench on it. It's such a handy tool.

If you want to take it a step further, Views bulk operations is super helpful. I feel like I use it all the time. I've got - I had a user put in 20 different items of content, and there was error in every single one but I was able to use Views bulk operations and actually change the value of a specific field, very quickly. So it definitely saves a lot of time. So what I'm going to show you - I'm just going to give you quick introduction to it first, is that Views bulk operations is a field once you've enabled the module. It's creates a field type. Then what you do is you change what operations are available in that field. So I'm just going to show you how to do that. We’re going to go back to my content list by users. I'm going to go to content. You can see my content by user there, and edit my view. So I'll just tell you what we’re going to do. We’re going to add an operations link similar to what we see on our content list here. We’re going to have a selection link which is our Views bulk operations field. Then we’re going to have some options to allow some changing of the content, so some kind of managing tools. So we’ll go to fields - I guess it's sort of belaboring the point to say that I've been enable - installed and enabled the Views bulk operations module and all the dependencies as well. So this is the bulk operations field you're looking for. So I will apply it.

I'm going to change - or selected bulk operations. You can see, for example, unpublishing content might be something you want to do and saving content or maybe removing content from the front page, publishing content, promoting something to the front page. You can see how just being able to do these simple operations can be very time saving. Changing the author is something you might often do. That's quite helpful. So we’ll just slide up and see how see how it goes. Here we get the operations link that's showing up on the side. Remember what I said before about being consistent. People will expect the operations list or check boxes are on the left. So always think about that when you're adding in new fields. So move that over to the left, apply it, and here I've got my select button there, and here are my operations available to me.

Now, you're probably thinking, “Why aren't all administration pages overtaken completely by Views?” Well, in fact, that's what that module admin Views does. So you'd be able to say - it actually overwrites all of administration lists. So definitely check out admin views as an alternative. Here we go. We’re going to see - I can actually see - I can't see the specific author I've selected. I guess if I'm looking at something by site admin, I'm probably clear that this is site admin content but I might actually want to add in the field. I've just realized that might make a little more sense. I'm going to add a field to show the author or the author username. So similar to that problem we had before, author names showing - oh, author ID, ha-ha. I'm not getting the author name because the author name is not available for me. Can you guess probably what I need to do to get that? You're probably thinking “Hmm. How am I going to get the author name here?” You probably guessed I need to add a contextual filter and I'll need to do that on the author ID. So this is just proving the point that if user information was not available - that's not a contextual filter. Excuse me. You want to add a relationship. I hope nobody is taking notes. I'm sorry about that folks. You probably realized what I was doing wrong. So the content author is what we’re looking for. So that's relationship we’re trying to create here.

So now when I go to add a field - someone is laughing at me. I can see the smile. That's great. You caught that, didn’t you? So now we can see the author username is available. So the username is now available instead of just the author ID. So that's far better than what we had before. It's a little more user friendly. So fine that it's there, I think I definitely want to move it over just to finish this off, I guess. I'm going to remove this and move this up and apply to all displays. So there you go. So now you could see - all right. I want to select by just text editor and maybe change the author of a specific piece of content. Okay. So that was good. You got another bonus example of seeing relationships which is great.

So we've got just a few minutes left but I want to go through very quickly, the things we’ll be doing next. So last week, if you watched this class or the last class, you made a view, right? This week as your assignment, please try to add a display that has an attachment with it and maybe use the contextual filter or user relationship to get other data, and add a link to somewhere on your site. If any of the stuff that you've seen today is confusing, I have actually made a tutorial that's in four parts. They're about five minutes each but it goes through contextual filters and using attachments. It's literally 20 minutes long, step by step, very clear. So not as much detail about some of the best practices we talked about today, but there's also a webinar that was just last week with our partners, Suzanne Kennedy from Evolving Web. They have a course, actually, at DrupalCon on Mastering Views Configuration. If you can imagine what we covered and I was able to squeeze in to an hour, if you do a full day long class, you'll get a lot more out of Views. So there's also - this is all in the - the slides we will be uploading as well. You'll be able to get these links easily.

So next week, I'm going to show you how to build your first module with a backup Views. I timed in. In fact, it wasn’t even an hour long. I had to come up with other fun stuff to do next week. Do sign up as well for the following class about configuring accounts in Drupal. It doesn’t like fun but it is interesting and it is really important. We’re going to talk about profile fields and user accounts and roles, a lot of different aspects of accounts on Drupal. Then after that, I think you'd be interested - you might be interested or maybe one of your colleagues is on the project for - Drupal for project managers course.

So next week’s topic, we’re going to do a Views QA. We’re going to go through some views and look at - try and improve the quality of them by going through a checklist. We’re going to talk about theming Views as well. So I want to show and break apart the basic steps of how you go about theming Views. Then we’re going to talk a bit - we did last week and touch on it but formatting and how you configure your formatting. We’re going to do the final steps for caching and performance to improve how your Views actually cache content and load very quickly. Then we’ll build a module to back up your Views. So if you’ve never done anything to back up your Views before, you’ll be really excited to see this. If you’ve never build a module it is super simple and you’ll be very happy you’ve done it. So there’s a lot of events in person as well so please do check them out.

Are there any questions? I haven’t been able to see. There's about a few minutes left.

Hannah Corey: Yes. We had a couple of question come in. The first question is about column sorting. If there is paging, will the sort consider a current page only or the whole set?

Heather James: It will - the sorting will be set across any pages, any subsequent pages. So if you sort it by alphabetically and it like A to J, it will do K through Z on the rest of the site - sorry. K to Z on the rest of the page.

Hannah Corey: Awesome. We have another question on sorting. Will it issue a new query to the database or store at the presentation tier level?

Heather James: I think that - that’s actually a good question. I don’t know the answer to that. I think if you sorted it - I actually don’t know the answer to that question. That’s a good question. I will find out for you next week.

Hannah Corey: Awesome. The next question is can we get a quick look at the generated SQL for relationships?

Heather James: Yes. Okay. Well, if you are a database programmer, you probably have already kind of you’re scratching your head and you’re wondering “What is that?” It's a join. So here we have the join, we’re seeing - it’s very small and very pale. So this is exactly what you would have done if you were writing your query. Is that kind of what you expected to see? I assume so. I guess I won’t get the answer right now.

Hannah Corey: Yes. That’s exactly what they wanted to see. Thank you.

Heather James: Yes. If you’re following along and you’re working on your Views and you can’t see your query settings, remember you can go to Views, settings and you can actually show the SQL query in the live preview. We can talk a little bit about some of those performance things next week too.

Hannah Corey: Awesome. Okay. We have a couple more questions. How can we assess how efficient those joins required by relationship are?

Heather James: I think that’s when looking at the performance statistics will come in. I think once - tune in next week. You’ll see how you can actually export your Views to code. Once you’ve done that, you’ll be able to tweak any of those queries yourself and improve them. You can sort of, in a way, could say let Views be something that you and your team prototype with, and then you may use it sort of as jumping off point to maintain more optimized Views queries.

Hannah Corey: Great. The next question is can you please give us a sense of what kind of things we should not try to do with Views?

Heather James: Yes. I actually - I was going to talk about that with this view of all content here I made. I think that Views - I’m pretty sure this has been hammered through very clearly but seeing this earliest version of Views, the default setting was to show all content and actually - instead of showing fields - I’m just going to edit this one here. Instead of showing fields, it actually would show the full node. So, for example, here, like the full content. So what that meant was if you had a view such as this which shows all content and also uses Ajax, you’re basically trying to pull all the content from your entire site in all at once. So this is sort of - this was basically always the fear of - for example, when we did Drupal Gardens at Acquia, one of the fears when they added - before they added Views was someone could make a query that could cripple their whole website and slow it down.

So if you sort of think of Views as limiting a selection and you’re filtering to limit what content you’re showing, you’re not trying to just vomit out everything from your site, then you’re pretty safe. There’s probably a limit as well. I spoke about this last week. When you’re adding a lot of displays, additional displays are actually loaded - when you view, for example - on my own website, you look at the Canadian list, you are also getting on any content that’s loaded for the other displays as well. So you might think just that. If you’re using displays, make sure there’s a lot of similar content between them. Caching is going to help there too.

Hannah Corey: All right. Awesome. The last question is can you filter the visibility of the block view by content type rather than by path patterns?

Heather James: You can, absolutely. I mean, in my case it wasn’t going to work because I was trying to change the users of - showed on the user profile but you actually totally do that. So I'm going to go this level block, for example. Instead of showing it on every page, I’m only going to show it by specific content types like I only want to show it on courses and recipes. It’s kind of the only place that levels is relevant too, for example. So I’ll save that and my level block no longer shows up here but if I click through to my course, for example, I’ll see my level blocks show up. Well, it’s actually interesting. This here is a taxonomy view when I went to the beginner list. This is just - excuse me - a list from the taxonomy. It automatically comes with the taxonomy module that’s core in Drupal. So what’s interesting is you might think “Well, I don’t like the way this looks. Maybe I want to change that with Views.” If you go to structure Views - it’s one thing I intended to show you. You can actually get an overwrite of taxonomy with this Views template that’s actually available to you. So it actually overwrites taxonomy. There’s also one for the tracker. There is one for - there’s an automatic one for archive. So definitely checkout some of those Views defaults. It might give you some more help too on using some advanced functionality in Views.

Hannah Corey: All right. Great. I think that’s it for questions. Thank you everyone for attending and thank you so much, Heather, for this great training presentation. Again, the slides and recording will be posted to the Acquia.com website in the next 48 hours. Please definitely signup for next week’s training course with Heather. Heather, do you want to end with anything?

Heather James: No. Thank you so much. I’m seeing this, Hannah. It’s a huge help. I’m looking forward. If people come next week and have questions as well, if they’ve prepared things and - I think, Hannah, you’ll be able to give the questions from this week and I can follow up on anything. There is one question I definitely will follow up on.

Hannah Corey: Yes. Definitely. All right. Great. Thanks everyone.

The Practical Guide to Selecting a Web CMS for State and Local Government [May 2, 2013]

Views Mini-Course, Part I: An Introduction to Views [May 1, 2013]

Click to see video transcript

Moderator: Views Mini-Course Part 1 – An Introduction to Views with Heather James who is the manager of training here at Acquia. We are very excited to have Heather on the line.

Heather James: …the training program at Acquia was established in 2010 and just last year, we trained over 3,000 people, so we get a lot of people in the door who are brand new to Drupal. We maintain our own course materials so they’re continuously updated, and that keeps us pretty busy.

The training is actually run by our training partners and those folks are experienced developers and they actually enjoy getting away from behind the computer and helping other people, so you’d actually find the events are quite fun and you get a lot of insight into real-life kind of Drupal problems and solutions.

We have a lot of tailored courses available and I’m happy to talk with you at any time about setting up training for your team, so please contact me if you need some advice.

So you’ve landed on the very first class which is our first mini course, which is an introduction to Views, and we will have soon a Drupal for Project Managers mini-course that will be a four-part course coming in May. We put these together because we thought that there were still lots of people who – and even though there are a lot of free stuff out there, we wanted to contribute and make some more training available for you guys.

In this mini-course, you’re going to find out in these three weeks how to expose data across your site, create lists of content, users, and terms; and format it as tables, lists, galleries, slideshows; and that’s really what Views does. Today, we’re just going to start with the very basics. We’re going to start with just how Views works and what it does, and give you a general orientation and terminology of just so you’d kind of know enough basically to be dangerous, at least in the next week.

In order to get most out of today’s session, you’ll need to already understand how to add content to Drupal, how to customize content types, what modules are, and how to install and configure modules.

You might find yourself somewhere on this spectrum. I actually was sort of surprised that you might find people like this little orange dot here, someone who has actually got some experience with Drupal but really doesn’t know what Views is or is aware of Views but hasn’t actually felt them or made any use of them. I expected everyone to be like this blue dot. If you know Views and you’re experienced with Drupal, you probably know a lot about Views, but what I was surprised to find is on a lot of client sites where they’re building websites and not making any use of Views at all, and that’s why I wanted to run this mini-course.

We’re going to dig in now and first thing we’re going to do is address a kind of misconception, we could say. We’re really I guess brainwashed by this metaphor of manila folders and files and manila folders, and we sort of still think that way to the point when you’re even developing your own website, you may be thinking, “I’ve got a mental sitemap with pages and they fit in folders.” In fact, some or many actually - CMSs actually work this way so you may be familiar with other CMSs where you’d want to add a section on your site, so you add a folder and then you add in pages within that folder.

The problem is this isn’t just a mental hurdle. It also causes logistical problems if your CMS does work that way. Say for example, you want to add news headlines showing up in the sidebar of your contact page, so you’d have to what – maybe every time a news item was added, you’d have to copy the text, put a link, and update the contact page or update it all across the site wherever it appeared. Believe it or not, there’s a lot of people still even using Drupal that way and you don’t have to.

What we’re going to do right now is think of Drupal as holding data so not everything you’re going to see on our Drupal site is content per se but everything is data. Views is going to help us expose those data across the site, so you can think of these in different groups.

Now, I just thought it would be good if we got our hands dirty first of all. I’m going to do a very quick demo and kind of a magic trick and just show you how Views works. I promise I will go into it in much more detail afterwards.

The first thing we’re going to do is look at what Drupal does out of the box for listing content, and then we’ll see how we’re going to override that and we’ll see how to make a new view listing content type.

I’m going to bring you over to my Delicious Drupal site here. Here, I’m logged in as the User 1 or the Administrator so I see all the various controls available. Here’s a list of content on the site. We call this like the “river of content” which is okay. If I go over to Site Configuration, Site Information, I can see that I could change the amount of posts on the front page and I could even change the path, but that’s pretty much all I can do. The only other option I have is to go to Structure, Content Types. Say for example, with a specific content type like the fan art or cooking website, we don’t want recipes to show up on the front page. So I could change the default option that it doesn’t show up on the front page, and so I could limit that by all the various content types but still it’s quite limited in what I can do.

What I’d like to do on my Delicious Drupal Site is have a list of news items or news articles, so I’ll show you how to do that. Go to Structure, Views; of course, with the Views module enabled already. So we’ll go to Structure, Views, Add new view, and I would call it News Articles. Show in Content, so I mentioned before, we’ve got lots of different data here. We’re going to select Content in this case; of type, Article, so I’m limiting how much I’m going to show. I will create a page, here we go. I can even customize this path to make it shorter or change it any way I like. I’m going to keep the Default options. This is where you can see you can change your formatting and to keep it as Teasers, and that’s pretty much very similar to what’s on the front page and I can change the number of items to display.

I’m just going to save the options as we set them up in that wizard there, Save & Exit, and here we see a news page. Okay, fantastic. We’ve only got news articles now. We’re not getting everything else but if I go back to my home page, of course, it’s not set to my home page yet so I have to go back to Site Information and make my Default front page the news path that I just created.

Now, this is a little bit of magic hand-waving I’m doing right now. I am going through this a little bit quickly. I’m going to ask Hannah. If anyone has questions, Hannah can message me on Jabber and I’ll be able to see her questions if I’m going too quickly. I just want you to know that I will be covering this in more detail.

Here we go. We’ve created a view and it has got just the news. So hopefully at this stage now, what you know is that Views can allow you to basically limit your display of content. Let me go back to the presentation now. Now, there’s a potentially confusing problem. You may have realized that when we’re displaying content, we chose Teasers. Those are called View mode in Drupal and that has really nothing to do with Views, so another option which I’ll show you soon is to select Fields and then you can get field specific control.

At least at this stage, if what you understand so far about Views is that it’s a query builder, then we’re goaled in. We’re right where we need to be. We’re going to take a step back now and let me give you a little understanding of why we really have Views.

I love this website here. This is the Jane Pickens Theatre site. When we look at the front page – or the Coming Attractions Page, I should say – we may think, “Oh, okay. Well, we’re looking at a page of all of the content on this site and maybe this page is a piece of content where I can go in and edit the title of that coming attraction.” In terms of what Drupal thinks about this content, it’s only this piece here so we’re looking at one item of content or actually it’s called a node in Drupal, and that excludes anything in the sidebar, the header, the footer. This is just one entry in the content table as one piece of content. When we see something like a landing page like this, what you’re actually seeing is a collection of lots of different content from across the site. In the middle here, we see a slideshow so it’s just showing us things which have somehow been marked Featured, and then we’re seeing at the bottom, Coming Attractions like a gallery of movie posters and music posters.

This may be very different from how you’re thinking of how you approach developing your own sites if you’re new to Drupal. Now, perhaps your process and your workflow starts at Fireworks and you make your perfect markup and then you go to make your perfect markup and you got everything working just fine. Maybe in the old days, when you were doing database connections and combining HTML with your query results, you had to write this kind of messy code yourself. Things have gotten a bit better. We’ve got some great CMSs out there.

Here’s an example of ExpressionEngine which is like a tag-based templating system that has a query that we can actually alter and change. For example, say give us some information about the users. My question is what happens in the case that a client wants to change some of the logic or change what gets listed? They’re going to have to be calling you, right? I think it’s fine definitely if your business is keeping people’s websites updated and changing them, then you’re happy but if you work with a larger team of people, you may find that Views is going to be much easier to work with that will allow your colleagues to go and change the queries and update things or even create their own Views.

In fact, Views itself was actually developed at Sony by Earl Miles or merlinofchaos, and it has become so popular in fact that it has been included in Drupal 8. I don’t know if you can see the text here is quite small but one of the things that was found in Drupal 8 is that basic default front page was replaced with Views, so even that activity that I just showed you, replacing your front page with Views, is already included in Drupal 8.

So let’s say you’re brand new to Drupal and this happens a lot in a situation where you might want to create events. You probably would go directly to Drupal.org and you might be looking, for example, for a module that will allow you to have easy date selection, sidebar block showing like a little calendar or something like that, and you look for the event module. In Drupal 5 or 6, that’s exactly what you would’ve found but now with Drupal 7, we’re sort of pushing over into more generic and flexible solutions. So it’s actually a funny thing because you’ll actually be using less modules altogether. You have to use more modules to get the event – obviously, you use more modules to get this event functionality but once you have Views installed and the date modules, you can use them in lots of different ways.

You have a lot more control as well so instead of in the event module if you want to change, for example, how the data entry was, you have to write custom code yourself whereas with the date modules, you can create a field and control how the input is – if ever received I guess you could say. You can also have options for formatting how it displays so with Views, for example, you have the option of display formats or templates that create these calendars, the Full Calendar or the Calendar module. I hope that gives you a sense of really want makes Drupal a little bit different. I like to call this the “big fancy middle man” where Drupal allows you to control and configure display and layout. It makes it very different from other systems as you saw with ExpressionEngine or maybe WordPress.

At Acquia, we really believe that you’re going to get a better quality site that’s easier to maintain through more configuration, more site building, and less custom code. In fact, this just results from a survey done in 2011 of Drupal agency executives and they said that’s pretty much what they were looking at. It’s about 80% of their development project was done with site building and configuration and overall, that has less security risks, it’s easier to maintain, and I think you’re going to find it much easier to manage.

At this point, as long as you understand I guess that the CMS supposedly makes it easy, obviously, for a lay person to update content on the site without a developer, it’s Drupal taking it one step further and putting those developer tools within the reach of other people on your team. In fact, with the training we provide, we often find it’s a matter of change management because people have to change even the way they communicate within their development team so you may find that someone else in your team who is involved in user experience is able to now create a view and get involved in actually creating workable prototypes of your site.

We’re going to take a second to find your way around the Views. I just wanted to ask really quick - did anyone have any questions so far? I’m going to see. This is my first time actually doing the webinar so I’m sorry about any problems I’m having.

Moderator: We have one question come in. Will you be explaining one of the Views you’ve used versus one that’s not?

Heather James: That’s a really good question. Yes, definitely. I think that in general, you want to be using Views especially for listing content on your site. I’m sorry, I’m just getting a little dazzled by the interface here on WebEx. If you’re going to be listing content on your site or making any lists of any data on your site, you want to be using Views basically. There are situations where if you have a site with a large volume of content or large volume of comments, for example, you will probably want to export your queries and optimize them and make them a little bit more fine-tuned but other than that, Views would begin, would start as a really great prototyping tool, for example, so I hope that makes sense.

Moderator: We have one more come in.

Heather James: Sure.

Moderator: Everyone has events. Does everyone have to build event content types or views? Is there a best practice?

Heather James: Yes. Actually, I did an events webinar a few months ago and because something like events we’ve done so frequently, there are people sharing modules that extend what Views can do. For example, write your calendar display, there are some great modules that help you get control over that. In terms of events management though, it’s actually sometimes you may be wanting to handle commerce, so you might start with something like Drupal Commerce to handle the payment or registration, or you might be using another service such as Eventbrite which handles your registration externally, and there are modules for that as well. I hate to say it depends but let’s see. I think it does actually. I hope that helps. We can get you the link to the – or you can look on our site for the events webinar which I think could give you a sense of how to configure your own event content type.

I am going to dig right into the Views UI and help you find your way around. I did a little magic trick before and we used the Views Wizard. The Views Wizard shows up when you first create a view and it has got some very basic functionality available but like any good wizard, I want you to know that it does disappear and that’s extremely confusing for someone who’s new to Views. I’ve had this time and again. People go back to edit the view and they expect to be able to get back to this wizard. It won’t happen.

What you will see the next time you edit your view or continue on to Save & Edit view is the regular Views editor interface. Admittedly, there are a lot of options here so it can be a little dizzying, but we’re going to simplify the whole interface. If we just think about two questions, we’re first of all going to limit what we’re displaying so you’re going to focus on the sections of what you select and filter. Next, you’ll be thinking about how to format and display that so there’s a few sections I’m going to talk to you about to show you how you can get control over what it looks like.

Next week for the second session, we’re going to go into all of these in a lot more detail but just for right now, I just want to give you an overview. The first thing you’re doing is you saw me do when I created that articles list is you’re choosing your base table. If you already understand how databases work, you probably have a sense of, “Okay. I’m actually going to run a query on a specific set of data in my database.” Once you do that, you cannot change it later.

You can, however, use relationships to get data from another table and if this sounds like gobbledygook, I’ll give you an example. You may have a list of content and then you want to also show the author or maybe something about the author, maybe a picture or something like that. You can use relationship to get more information about some related data.

The next thing you’re going to do is somehow to filter a limit, so you don’t want to just cripple your site by listing all the content and everything. You’re going to either like limit by which author you have or maybe you want to limit by a specific content type. After you do that, you’re going to somehow select – you can select the View mode as I showed you before with like the teaser or you can select Fields. You’ll probably most likely be selecting Fields and you can even change and arrange how they layout.

The next thing you’ll do is select a format. So you’ve seen a lot of different formatting options here. You’ll notice I put in a map. That would actually be done with another module that will plot your coordinates, for example, on a map. There are some great tools. There’s not just these. There are slide shows and there’s a lot of great other modules you can try out and we’ll be talking about those as well next week.

I’d like to point out as well, you can configure the formatting that is output. Let’s say you have a field like the title. You can change what header that will be output as. You can even rewrite the output. You get a lot of control I think that people miss when they’re creating their Views. In this example, it’s probably hard for you to see on the small screen but you’ll see you can add a level field then exclude it from display, and it becomes then a token. On the right, what I’m showing you is that you can add it as a CSS class. It just gives you a lot more flexibility of how you rewrite the output of your view.

You then choose the type of display. You probably do this in an earlier step but it makes sense at this point to think of you can either output page displays or block displays. There are RSS feeds. There are a lot of other displays that become available as well when you add contributed modules.

Just to give you a sense of like the output, for example, let’s say I created this table of recipes. If you can see I’m inspecting the code there, you can see that the level or intermediate, for example, became a class on that table data cell, so that will give you some ability in CSS. I can make that color a specific color or something like that.

So just to recap, we’re going to choose what to query. We’re going to limit the selection. We’re going to select what we’re going to display, whether it’s Fields or View modes. Then we’re going to configure the formatting and then we’ll choose the displays. Let’s go and do that. We’re going to do another demo. This is the second demo. Hopefully, everything works out.

We’ll be adding a block display to our news list. We’ll choose some fields. We’ll put it in the sidebar, and then we’ll change the fields and change the display and see how it works. So let’s get right to it.

Here I am in my news article view here. A handy way to get to edit the view is to go here on the little gear on a contextual link. I would like to add a sidebar block so I’m going to add a display. Now, I’ve got a block. Well, I’m going to give this display a name because I could end up with a lot of - News article list, I can put it that way, and then to put a lot of displays possibly. Probably for best practice, I should go here and rename this one – Front page news teasers. Do whatever, you could put some information like that, for example.

Here, we’re going to edit this block, News article list, and I’m going to change the format. I’m going to get a preview, first of all, like I don’t want all of this content showing up in my sidebar. That would not look good. I’m going to change the format from content. Oh, sorry. For selecting what’s displaying, we’ve already selected what we’re displaying just to point out that we’re already displaying the content type article. We’ve got something we’ve already selected.

So we’re going to change from Content to Fields, apply it in there and it should throw up an error. Fantastic. Oh, it should throw up an error anyway. It automatically added the field title. Oh, that’s fantastic. Okay. We’re going to add now I think a date will be good for the news list. Add a field, add a date, Content: Date, okay. I won’t need a label. You can change the format so just like a nice short date, Apply, and here we can see it’s not displaying. Fantastic. I love doing live demos and not realizing what I’m doing. Yes, I actually picked my date fields. This is good. Actually, it’s great to learn while someone else makes an error. I picked the wrong date. I picked the date field instead of the date the content was posted. That’s important. You could also choose by Updated date if you chose news, for example.

Let’s see if that worked. I’ll deselect Create a label and choose Short Format. I hope you’re all enjoying my live demo [laughter]. What an opportunity for comedy. So here we get the title and the date, so that’s okay. It’s coming along all right, but I’m going to go and change the format now because I’d like these to show up in a bulleted list. I’m going to change from an unformatted list to an HTML list and just see how this goes. Here we go, fantastic. We’re getting a bulleted list now that looks a little bit better. However, what I’d like to do is have the fields – I’d like to have the fields sort of running next to each other. I want them to show up in line, so go to the Fields Setting and select these fields to be in line. All right, so that’s a lot more – well, it’s a bit more close to what I was planning on doing.

I don’t want a pager at all on my news item. Excuse me, I don’t want a pager on my block. That’s just not going to look right, so I’m going to change it to - for This block, I will say Items to display, display 5, Offset, and – oh, sorry. Use pager. I’ll just click here, just Display a specified number of items. Yes. Items to display 5, sorry. So here we go, a list of news items with the date. It’s getting a little bit closer. I can already see I’ve made the error I was going to try not to make. Let’s see what happens. I added the block and I changed the options there. What I also overrode what happened on my front page, so it ended up that when I added the display, you’ll notice here I’m going to go Show Fields for example. I changed it for All displays instead of This page (override). That ended up overriding my default, so I have to go back and undo everything I’ve just done.

Let me go back to Fields, change to Content, and change to Teaser, Apply (all displays). That looks a little bit better and if I go back to my block, it should look… I hope you guys thought that was funny. Sorry, This block (override). Okay, get our Inline Fields.

All right, so here we go. We’ve got the front page news. Hopefully you can see it’s okay, and we’ve got the teaser showing up and then in my block, I get the News article list and we’re seeing just the bulleted list. Okay.

So now that I’ve created this block display, it will be available to me in Structure, Blocks, and it will show up down towards the bottom, hopefully the list, and we see the View News articles: News article list and I’ll pop it into the sidebar. Put it over here, it shows at the top. Okay, so that should show up in my sidebar second here, above my search form, back home and voila! I’m getting my title and my date.

At this stage, you should understand we’ve got displays. We’ve got the news display and we have the block display showing up, and you also saw what happened when I wasn’t careful enough that you end up actually overriding your displays. So I suppose you can’t put too fine a point on it. You just have to be careful when you’re selecting specific displays in the editing options. It’s something that generally tricks people up in the early stages, and as well best practices to name your displays and that helps you keep track. As you see, when you saw the block listing, that’s the spot what I was looking for.

Let’s recap what we’ve done. First, we selected and filtered with the news articles. We selected specific fields; in that case, we chose a title and a date. Then we change the format so we changed it to be a list. You saw me go back and forth between a list or the view mode, a teaser, and then we chose a display. We had pages and blocks.

Now, that you’ve seen the two demos, so where do you find yourself now? Do you feel like you know a little bit more what Views is? You’re on the – has your yellow or your orange dot sort of moved up a little bit? I’d like to hear what questions people have at this stage.

Moderator: We had one question come in that says, “I’m sorry if I missed this but are we able to add RSS feeds?”

Heather James: Yes, that’s a good question. Let’s look at how to do that. I’m going to go back to my environment here and let’s say, for example, I’ve got my news articles. What we’d like to do is especially on the front page, we’d like to customize it so the front page RSS feed only shows news items. Go back and edit. Before I make the change, you might be already thinking how could I add a list of RSS items to a view? So based on what you know so far, you get the idea that you can add displays. Right across the top here, we’ll click Add a display as a Feed. The Feed options are a little bit different so we don’t have the options, for example, to utilize Fields. It’s a little bit limited, but it’s just automatically formats your RSS feed as you need.

Let’s set a path here, so we’re going to say news stories. We’ll get an output and this is going to give me a preview what the RSS feed will look like generally. There we go, cool, so that’s our display. Does that explain it or no, maybe not yet because I haven’t saved it? Yes. Click Save. The Save button is at the top in Views as well so hopefully you won’t have any problems with that. I’ve actually seen plenty of times where people are working away on their view happily and then they’ll end up not saving what they’ve done. A sad day then. I should see a news – ah, fantastic. I actually will create this as an attachment, in fact. Maybe this would look better.

Another display we can do is an attachment. I’m going to just change one thing on the front page, Front page news first of all. It’s to actually change from five items to like two items, first of all, so we’re only getting two news items up at the top. The last display I’ll add is this front page sub-list, old news we’ll call it.

In the Front page old news, I’m going to change it so we have – I’ll show you the front page now. We’ll see the – what we’re going to do is have two news items and at the bottom, we’ll have like a bulleted list. Maybe I should show you guys something. Okay. I could close either views. So we’ll show you a list of This attachment, change it to HTML list. Instead of Content, we’ll change to Fields and let’s just show the title and save. I’ll remove the updated date from this list. So here’s a list of the other news items and instead of displaying 10 items, we’ll offset to three so we won’t display. There’s just three items that we’re only getting, a few of the options here. We’ll position this attachment After and attach it to the Front page news.

This is the last display to show you. I guess I was going to save this till next week but we didn’t have a lot, so I guess this went a lot quicker than I thought. Let’s look at after you save this, how it appears on the front page. So we see the news articles and there are two items showing up at the top and then the remaining news articles. It would show 10 if I had more news articles on this demo site, but that’s really the last type of display that’s available by default in Views.

Are there any other questions?

Moderator: Yes. We had a couple more come in. What theme are you using?

Heather James: This is just regular old Bartik. This is the default theme that comes with Drupal 7 and I’ve only just changed the logo. Awesome.

Moderator: Okay. The next question is how do you add a lightbox from each image that a view returns so a larger size image can be viewed in a pop-up window?

Heather James: A really good module for that is Shadowbox. I recommend it because it actually provides you – that’s a really good question. I’ll be able to show you next week so I’ll be showing you modules that extend what we usually do. What this allows you to do is it provides you a different display mode so you may think of – let’s say for news articles, for example, let’s go back to our Front page news and I’m going to mess around with this a little bit more just really quick. I’m going to change the Content to Fields for This page. I won’t make the same mistake twice, of course, and apply to this display. We’ve got title and an updated date. We’re going to add an image which is appearing in my node article there. You’ll see here we’ve got a Formatter, Image formatter and we’ve got the Image style, Medium, for example, and link to Content or File.

What Shadowbox will actually give you is another formatter option. There’s a number of modules that do something quite similar, but it will basically give you a formatter so it will have a display in a modal window. A lot of times these contributed modules are just extending what Views can do because it doesn’t have to do everything. It’s just things are offered from network to Views. I hope that’s clear.

Just see here, this is where we’ve done enough so far with messing around with the front page. Page display, this looks kind of horrible. So apply this, just change into an Unformatted list here and just to prove the point, I sort of showed you before you can change the style settings, even rewrite the output, for example. I’m going to change this to like heading three, for example. The image – oh, remove label. I’m just going to be demo-ing away here. I have a few more notes to add to the very end of this presentation here but if you have questions, feel free to ask.

What we’ve done so far, I guess, is you’ve got my idea that with Views, you get a lot of control over what you can display and how it displays. Oh, it’s fantastic. I’m so impressed that I keep on forgetting to do this. I meant to make the first time I did this, I didn’t mean to make a mistake. I thought I was being clever but yes, I’ve got time for questions. Sure.

Moderator: Okay, great. The next question is can you explain the difference between Views and blocks?

Heather James: Absolutely. What you see with Views is that you can create blocks so I’m going to rename this to be News block, for example. I could actually create multiple blocks with Views. I could add another block based on the same query of news articles, for example. Views creates blocks and then blocks are things you place onto the website, so we’ve got Structure, Blocks, and one of the things that has been output – let me just save this. One of the things in output is my News articles, News block. That was actually created by Views. There’s a lot of different blocks just by default. Drupal comes, for example, with a list of recent comments so I’ll just show you that default block. Let me put that up in the Sidebar Second under the Views block there. So blocks can be upped by a lot of different modules and you get some control over where they display. Does that make sense? Views creates blocks.

Moderator: Yes, great. The next question is will you be explaining how to export the queries, optimize them, and re-import them?

Heather James: Yes. Actually, that’s exactly what we’ll be doing in the third part of this. If some of this is a little basic for you, you already know a bit about Views, in the third part of this, we’ll be taking and exporting everything. You’ll be able to see how to export everything you’ve created and save it as a module. Let me just show you. I want to go to Structure, Views. You’ll notice, for example, with this News articles view, I can go ahead and just delete this, which is kind of scary. I can go and edit it and all the changes I’ve made and all that work I did could get lost instantly. What you’d be able to do with the module is have a list of content and I’ll show you one that I actually have, the one I did at a Drupal camp. This one here is not deletable because it’s actually saved in code, so there’s in database overriding code but I can also revert it and it will revert back to what’s saved in my module. So it’s a safe way to back up your Views.

The query that actually gets created is sort of helpful. I think if you want to look at the query itself – sorry, I have to go back to my settings. Go to your Advanced settings here and you can show the SQL query right when you’re looking at it. You can also show some of the performance and how it’s running. Let’s just look at the SQL query for now.

Okay. There you go. Here, you’ll see – if you already are a person who knows how to write database queries, you can get your insight here. Oh, my worst fears have come true. My unprofessional cat has showed up for this webinar. I’m sorry about that.

I’m going to just finish up with some final notes. I know that you guys are giving your time over to this and I just wanted to give you an idea of what I’d like to do over next week. If you’re brand new to Views, I’d like you to go ahead. Based on what you’ve seen so far, create a view yourself so this would be listing of specific content type or maybe all the terms on your site, and create a page display and a block display and then place the block in the sidebar of your site, just the same way we did.

I actually created a tutorial which has just four- or five-minute videos, 20 minutes, so I go through these steps very clearly and you’ll be able to complete that activity. When you show up next week, you can ask me questions more specific to the problems you run into.

If you are a little more advanced as well and you want to learn more, there is a webinar available that was just done yesterday with my training partner, Suzanne Kennedy from Evolving Web, as well as there’s a Mastering Views course actually happening at DrupalCon, so if you’re going to be in Portland, that’s a really great opportunity to get a lot of detailed help with Views.

Then we’ve got some Views tutorials so I mentioned my quick one there. There’s also Drupalize.me that has a great series. It’s not free. There are some free ones there. There’s also a free 10-part series with the Toronto Web Developer, Pete.

That should give you enough help so that by the next time we meet, hopefully you’ll come to the next one on May 8th. We’ll give you a lot more detail on how to build flexible views. Please do sign up for that one as well.

I put up all the notes from this class and all those links. I figured it was probably quite a lot of information. I’ve actually put them up on our blog and so you’ll be able to get access to those tutorials.

Of course, please do come and check out our events. You can meet me at Dublin Drupal Dev Days as well if you want to talk more about Views and configuration. I’m just going to show you that blog post there.

We have about a few more minutes. I think we’re closing soon, but are there any other final questions?

Moderator: Yes. There are a couple more questions that came in. Is there any limitation on the number of blocks we can create in Drupal? Can we create more than 256 blocks?

Heather James: That’s a really good question. You probably – what’s interesting actually about the various displays, you could keep on adding displays to this view and if you think of it, it’s really just variations on the same query. If we’re querying very similar content, it makes sense to just simply add a display. If you’re at the point where you’re adding 250 blocks, you probably have a different need, so I’m going to give you just a hint of how this is done.

Let’s say we had a news page or we have a news article obviously here. Or actually I may have something already created. Let’s look at one I did earlier. I look at the cooking, for example, cooking recipe here. We’re looking at this baking recipe. What we want to show are related recipes and we don’t want to be creating a new view for every single recipe on this site. I’m just going to click on – I’m trying to find one that actually has one. Let me get the baking recipe, or maybe not. Okay. Let me hold on a second. I could get something that’s related based on taxonomy terms. Right. We’ll be showing you this on the next one, but just let me try and do a very quick explanation.

Let’s say you have this recipe here for beginners and you wanted to show in the sidebar other beginner recipes. Well, you wouldn’t want to have to create all of those different blocks for all of those different levels. What you’d actually use are contextual filters, so what it will allow us to do is create a block. For example, we can create a view and I’m just going to quickly see if I can do it and get under the Related levels. Show Content of type Recipes. You don’t want to create a page. We’ll create a block, and we’ll just make HTML list and I’ll Continue & Edit. I will do this in a lot more detail next week, but what we’ll be adding are Contextual Filters. You’d probably do something like this where you will say, “Show me content that’s related by level.” They’ll take the taxonomy term. There’s a lot of magic that goes on here but hopefully it will give you a sense that you could relate content by level. If my demo works out okay, everything will be fine.

The tutorials, by the way, that I’ve linked to you here, there is actually a tutorial specifically on how to do this, so it looks like we’re going to run out of time anyway. Let’s say, for example, we had the setup. Let me see here. I’m going to display this content of title, okay, that’s fine. I’ll save this. Structure, Blocks, and I’m looking for my recipes block I just created, related recipes. Oh, I already had related recipes. Related levels, there we go. Sidebar Second, put it up to the top, and save it.

We’ll go back to our recipes page, show a specific recipe and – sorry. Someone who has done live demos before is laughing at me right now. So we’ve got – oh, that’s not even the related recipe, sorry. I’m sorry [laughter]. I’m looking at the wrong view. Oh, can we cancel this? I’m sorry about the demo. I’ll show you this next week and I’ve actually created a step-by-step instruction about this. Let’s just say if you’re going to create 250 blocks, you probably need to choose Contextual Filters. I hope that was a good enough answer.

The other problem with it is if you are creating views that have a lot of different content, you don’t want to be adding extra displays because you’re just going to be overriding a lot. Once you start adding, say, more displays instead across here, it’s just becoming unwieldy, difficult to maintain and manage. You’re not getting any benefits.

The other thing is if you have a lot of data being pulled into your view, like if you have a lot of different fields and you’re doing relationships and joins, for each one of those displays, all that content gets loaded, so that’s something to consider. You really only want to use multiple displays when a content that’s being selected is quite similar.

I will talk to you next week about caching your queries to make them a lot faster and what effect that has on your site as well. Are there any other questions?

Moderator: Yes. We had a few more. The next question is what is the difference between one view with many displays versus many displays? When do you use a new view versus a display?

Heather James: Yes. I hope that what I’ve just said there sort of explains it. The displays are just to help you create similar lists of content so I actually was going to show you on our upcoming training site, for example. We have a list of European, global, or Canadian, U.S.-only events. If we actually looked at them, we have these individual lists of content. They’re actually quite similar across all the various events. They look exactly the same. They got the same format and the only thing we’re changing is this information that’s coming to the URL here. Those are multiple displays in the same view because the content is very similar and the only thing that’s changing is this variable of the filter criteria of the location. In that sense, we’re getting a benefit from using multiple displays. This just happens in Drupal 6 but I hope that it’s clear from what I said.

Like I said, if you keep on adding multiple displays and you added more data through making a relationship, as you’ll see next week, the pulling in things from another table, all that stuff is loaded for each one of the displays.

Moderator: All right. Thanks so much, Heather. Again, the recording and the slides will be posted at Acquia.com website in the next 48 hours. Heather, do you want to end with anything?

Heather James: Yes. Thanks everyone who showed up. I‘m really sorry that I had a few hiccups myself. It’s my first webinar so I really appreciate you sticking – it’s my first webinar in a long time, I should say, so I appreciate you sticking with it.

I’m going to – hopefully, if you got any questions through the week, we’ll be able to get them answered for you. I’m hoping that you’ll give it a try this week and come in with questions so we can talk about what kind of trouble you ran into as well.

Moderator: Great. Thanks so much.

- End of Recording -