Tips and Tricks for Getting the Most Out of Views [April 30, 2013]
Tips and Tricks for Getting the Most Out of Views [April 30, 2013]
Want to learn more about Acquia’s products, services, and happenings in the Drupal Community? Visit our site: http://bit.ly/yLaHO5.
Views is the most popular contributed module on Drupal.org and an essential tool for any Drupal website. It allows you to create dynamic listings of content with just a few clicks of the mouse. This webinar will give you an overview of essential Views concepts and give you a taste for what this powerful module can do.
• Examples of what you can do with Views
• Organizing content, users, taxonomy terms, and more with Views
• Filtering and sorting Views results
• Formatting Views: learn about options for changing the output of Views
• Extending Views with other modules
• A taste of more advanced Views functionality
Female: Today’s webinar is Tips and Tricks for Getting the Most Out of Views, with guest speaker is Suzanne Kennedy, who is the co-founder and front-end lead at Evolving Web. We’re very excited to have Suzanne on the call today, and I’m Hannah Corey and I’m a marketing specialist here at Acquia.
Suzanne Kennedy: Hi, My name is Suzanne Kennedy and I’m going to be presenting today on Views. We’ll be covering some tips and tricks on how to you use Views. I’m assuming a lot of you already have a lot of knowledge about Drupal and want to learn more about how to build more effective websites in Drupal. Just trying to get to my first slide here.
Okay, so as Hannah mentioned my name is Suzanne Kennedy. I worked at Evolving Web and my role at Evolving Web is as a trainer and also a themer and site builder. I do a lot of the work taking care of the front-end of the Drupal sites that we build.
I’m just going to do a quick introduction to Views. If you’re already familiar with Views, this will be kind of a recap but I just want us to go over some of the key concepts. When you start off with a Drupal site and you’re using Drupal core, you have a lot of content management features taken care for you. So you already have content in your site and then you can have users and a set of taxonomy terms and things like comments, and that gives you a lot of individual pieces of content. So the role of Views in a Drupal site is really bring all that content together and organize it on your site so that might in the form of lists of content that you would find in different places on your site. So if you go to a certain page, you might see a list of articles.
A View consists of a lot configuration but the most key pieces of configuration are the fields that show up in your Views so the actual content that gets displayed and then also, you can also sort and filter what content your displaying. So you can select only to display certain types of content in your list and you can choose to sort that content in a certain way.
The basics of configuring the View consist of a bunch of steps but for any of View, it’ll consist of choosing what you want to list. So what type of content you want to pull out of the database whether it is pieces of content like nodes, users, taxonomy terms and then you can add filters and sorts to that. So you can say, “Okay, I want to show certain types of content. I want to show articles or I want to show job postings.”
Then you can choose a format so you can decide how you want all of that content to be formatted. There are bunch of different options out of the box but the most common ones are unformatted content, which gives you a list of DIVs, a list - an HTML list with ULs and Lis - and then a table, so a basic HTML table. Then the other thing you have to choose is how you want your View to be displayed. So do you want it to display when you go to a certain URL, as the main content of a page or do you want it to show up in a block.
So the first step what to list. It’s really important when you’re in the process of making a View, it’s really important to know what you want to pull out of the database.
Adding filters and sorts. This is important because obviously showing all the content on your site is not going to be so useful to your users. You’re probably going to want to add at least some kind of filtering. Often people filter by content type if you are displaying nodes. You also probably want to make sure you’re only showing published content to your users. Then it’s also important to think about how you want to sort the content. So common sorts are things like the date the content was posted or the titles if you want to show things in alphabetical order.
There are a lot of options for how you want to format your content in Views. As I mentioned there are some built-in options but you can also extend the list of options. So I’ll be talking about today about some modules you can add to Drupal to give you more options for how you format your Views. Things like calendars and maps are other ways you can display your list of content.
One of the things you want to think about right off the bat with Views is how you want to display your list. The two main options for displays in Views are page displays and block displays, but there’s other options as well. So you can display a View as an RSS Feed and attach that to a page display. You can also create attachment displays which you can add to other Views. So displays are really important when you’re working on building a View.
To just give you an idea of the anatomy of a View, what it consist of. Most Views have a title, you can add a header which is some text that goes above the list of results and then each item in the View is called a row. The whole set of rows are often called results and at the bottom, you may have pager which lets you go to subsequent pages of results if there’s too many to fit one page.
So if you’re looking at a real live View, it might look something like this. Like a list of articles and then each row consists of either a teaser or some fields.
So the role of Views in Drupal is really as a query builder. It’s a way of telling Drupal what content you want to pull out of the database and rather than having to write sequel of statements and custom code to pull out exactly what you want, Views provides a user interface for doing pretty much the same thing.
So selecting what content you want to display and then configuring exactly how that’s going to show up on the site.
The Views Editor looks like something like this. I’m sure its familiar to a lot of you and in the presentation today, I’ll be pointing out certain parts of it that you might be less familiar with. So really the goal of this presentation is to give you some insight in to what Views can do. I’ll be showing you a lot of examples and then I’ll also be pointing to places in the configuration that you might not know about even if you are familiar with Views like check boxes that can save you a lot of time and frustration and I’ll be talking about a bunch of modules you can use to extend Views functionality.
The first thing I’m going to be talking about is how to change the markup of your View. So how to change how the content is formatted and exactly what markup is used around the fields that make up your View.
So as I mentioned there’s a lot of format options to choose from in Views and it’s important to choose the right format.
So the built-in format is listed here and the unformatted list is kind of the default that people go for but you might want to explore using some of the other ones.
So for example, if you are showing a lot of visual data, it’s ideal to use the grid format which you can use to make a table but it’s to display non-tabular data. So often content is more visual, if you have a lot of images that you want to show in a grid. It’s often used for displaying grids that show the users on your site.
Another option is HTML tables. So if you have a lot of content and you want to make it easier for users to scan the content, displaying your list as a table rather than an HTML list can be a good choice.
Another thing to think about when you’re working for a markup for your View is whether to display your list as a set of fields or as part of content.
So this is a terminology that can be a little bit particular to Views but there’s a setting in Views called the ‘rows style setting’ and this lets you switch between showing fields and showing things like teasers. So do you want to have fine-grain control over your View and be able to manipulate how each field is displayed or do you want to leave that up to the settings that you already have for View modes on your site so things like teasers.
So that option looks something like this, choosing between fields and content. With fields, you get to control exactly which fields are showing up, what order they’re showing up, and you can change the markup for each field. Whereas if you choose content then you’ll be selecting a View mode on your site so the common View modes that you would be using will be things like Teaser and the Full Node but you can add other View modes to your site as well. The advantage going with fields is that you get a lot more control over how the fields are displayed. The advantage of going with the View mode, is that you can create a teaser that really looks great for your content and then you can reuse that on multiple Views so you don’t have to re-configure it every time. So if you do go with fields, you get a lot more options. I’ll be showing you some of the other things you can do if you display fields in your View.
So one thing you can do if you’re displaying fields in your Views is that you can change the markup for each field right in the configuration. So if you have a list of articles that’s what you are showing in your View and you want the title of each article to be an H3 tag instead of span or a DIV then you can change that right in the View’s Configuration.
So when your configuring your View, you can go into the style settings and the configuration, and you can actually use exactly which HTML tag is used to wrap that field. So you don’t need to be a themer and make a custom template to make this change, you can do it right in the Views Configuration. This can be really useful if you have specific requirements for search engine optimization or if you’re trying to follow a certain standard in terms of the markup in your site.
Another thing you can do with field is you can combine multiple fields together in the same HTML markup. So if you have two fields that you want to show and you want to show them next to each other, or if you want to combine them somehow then you can actually exclude a field and add it later as part of the second field.
So for every field in the configuration, there’s a check box to exclude it from the display and then there’s another setting for each field to rewrite the results so you can add some text to the field before it’s printed out or you can actually use tokens to combine multiple fields together.
Another thing you can take advantage of when you’re displaying fields in your View is using field formatter. So you are probably familiar with field formatters when you configure content types in Drupal. You can select exactly how the field is displayed using the field formatters that the field type provides. So for example, if you’re using a link field, you’re using a link module for example, you’ll have an option to display the link as a link or as a text, a linked text. So there are different field formatters available depending on which fields you’re using.
So for example, if you’re looking at a mockup of site and it looks something like this, you’ll notice that there are social media links in there that are styled in a certain way and then you have dates listed for each result and those have a certain format as well. So being able to choose exactly how these fields are formatted is really important.
Another example of needing to format fields is if you’re displaying media in your View. So if you’re showing a View that lists a lot of videos or audio content then you want to have some way of formatting the audio file or the video file as an actual player like a video player or an audio player.
So in the field configuration, you can select which formatter you want to use and a lot of the formatters have settings as well. So you can choose to display your images as actual images and then you can choose the size to use for those images. Or in the case of the date that we saw in the examples, you’d be able to choose what date format to use.
So those options are all for how to have more control over the format interviewer field in Views but the other option is to use View modes. So the built-in View mode that you’re mostly to use in a View would be a teaser. You can control the display of the teaser through the content type configuration and then you just take advantage of that in your View and use the configuration that’s already been done on the content type UI. If you need to display your content in more than one way on your site, you might consider using View modes, and you can set up custom View modes using the display suite module.
If you want to display content in different ways on different parts of your site but you want to reuse that configuration across Views then this is really a great technique to use for that. So to take advantage of this, you have to set up your View modes using Display Suite and then choose to display the content of your site as content rather than fields. Then in the settings for that, you can choose exactly what View mode to use. So you can switch between teaser, full content and then in this case, I’ve set up a custom-made View called mini-teaser that I can use to display my content.
Another great feature of Views which is really useful is being able to add multiple displays. So you’re likely to be displaying content throughout your site in different places and you want to be listing that content in different ways depending on the context.
So for example, I may have a View that shows articles and I want to display them on an articles page but I also want to display them on the homepage on a block and maybe I want to display them on another page at the bottom of the content. So I have three contexts that I have the same View that I want to use. I want to be displaying the same content. I just want to be varying it slightly on depending on where it is showing up in the site.
You can accomplish this using multiple displays and just creating a single View. So let’s say I make an article view, I can have a display of those articles on a page and then I’m going to be associating about a path for that page but then I can also set up a couple of blocks. So I could be displaying the same content in three different ways using the same View. So in the Views UI, there’s a bar at the top that shows you all the displays you have and you can add more displays that way. Now, once you set up multiple displays there’s probably going to be some variation between them. So maybe in one display you’ll be showing certain fields and then in another display, you’ll be adding a couple of extra fields.
So Views lets you override any of the settings you have in your View or many of the settings you have in your View depending on the display. So whenever you’re choosing a setting or changing a setting you can choose whether you’re changing the setting for all the displays in your View or just the display that you’re looking at currently. So this is a way to build in to reuse the Views logic or the Views configuration that you have built across your displays but still allow for flexibility. So it still allows you to change some of the settings depending on the display.
So talking about displays, pages and blocks are the most common displays that you’ll be using but there are other displays that you can use as well and one of those is the attachment display.
Attachment displays basically let you combine multiple Views together. So let’s say I have one list of articles and then I have another display that shows articles but I actually want show one of those lists above the other. I can use an attachment display and it will let me attach one View to another display of the same View. This is really useful if you have a list of content and you want to show a featured item at the top of the list. You’ll see this a lot on new sites but I’ve seen it many different other types of sites as well. How you do this with the attachment is if you create a list of your articles say a page display and then you create an attachment display that had a slightly different configuration.
So in this case, just like I’m showing on this slide, the first one has larger image so you change the formatting of that image in the attachment and then you attach the attachment to the page display at the top.
Here’s another example on the right of the slide from the Economist.com website. The first result in the View is meant to have an image whereas the rest of the results don’t. So it’s really easy to create an attachment display and then there’s a setting to add the attachment before or after one of the other displays in your View.
Another thing that you might want to do to vary the markup in your View is to create a grouping of results to make it easier to scan results or for users to see what’s going in terms of the organization of content in your View.
So a grouping of results might look something this where you have a view that list a whole bunch of items and then you have subheadings in your View that grouped together similar items and the subheading is based on one of the fields in your View.
So in this example is a news archive and then I’m grouping the results, I’m grouping the news items based on the month in which they were published. So you can accomplish this in Views really easily by adding a field for the item you want to group by. So in this case, I’d add a field for the month in which the news was published and there’s a setting to group by any of the fields that you’ve added to your View.
So when you’re configuring the format settings for your View, there’s a grouping field setting. So you can choose to group by any of the fields you’ve added to your View. This can make it a lot easier to organize your View and organize content to make it easier for people to find what they’re looking for.
Another thing you can do with Views is create RSS feeds. So a feed is actually one of the display types and you can attach a feed display to page display. So really easy to set up RSS feeds on your site using Views.
One thing that’s really common on sites, is to have a block display that links to a page display. So you might have a list of recent news items on the homepage but you want to give users a link to a full page of results and you can do this by adding a block display and a page display on the same view.
So for example, you might have a list of upcoming courses and then you have a CL link that would link to a page of upcoming courses.
In the View Configuration, if you add a block display, there’s a link display setting which lets you choose which page you link more links to. So if you have multiple blocks and multiple pages in your single View, you can configure exactly which blocks link to which pages.
Now I’m going to move on to talk about Views configuration for filtering and sorting so ways of making your site more dynamic in terms of how your content is filtered and then also how it gets sorted and how users can interact with that on your site.
I mentioned earlier some really basic filters and sorts so filtering by content type, sorting by post date. These are things you’ll see quite a bit.
How filters and sorts work in Drupal is that you add something to filter or sort by. So you’re adding a filter criteria, for example, the published status of your content, and then you can configure that filter or that sort. So you can decide “Okay, do I want to show content that is published or content that isn’t published?” So it’s always a two-step process adding filters and sorts.
So one thing you can do that can be really useful for your content is filtering content by whether a certain field exists or not.
So let’s say you’re displaying a list of your users and this is very visual content because you want to show a profile image of each of your users; but you don’t want to show users that don’t have an image because then it kind of takes away from the visual impact of the View. You have all these placeholder user images. So one thing you can do is you can filter by whether or not a certain field exists.
So I can add filter criteria for the user image on the site and then I can configure the setting so that the result will only show if that field exist. So if user has an avatar then I’ll show the result for that user.
Another thing you can do with filters is you can expose filters to your users to let them filter the content. So rather than doing the two-step process where you add a filter and choose exactly how it’s configured, you leave that second step up to your users and give them a form where they can have some control over the view.
So for example on this site, there is a list of projects and you can search for the projects based on cities or based on states, and that configuration is left up to the users. So they can enter in whatever they want and then click apply to filter down the results. So rather than the site builder deciding exactly how the content is going to be organized, it’s left up to the user to go in and filter and find what they’re looking for.
In this example, the exposed filters are little bit more visual so they’ve been themed to look a little bit more attractive. It’s the same idea. It’s a page where you can find the project and you can filter down based on the taxonomy terms listed in the exposed filter.
So exposing a filter is really easy. In the configuration settings for the filter, there’s a check box ‘expose this filter to visitors’ to allow them to change it. So you just check that off and then you have a bit of configuration around the label for the form element that you’re setting out.
There are some modules you can use to extend exposed filters. So exposed filters are built-in to Views but there’s module called ‘better exposed filters’ which gives you some more options. Then there’s also a module called ‘views dependent filter’ and that lets you set up exposed filters that have dependencies. So maybe you’d filter by content type first and then you would have another filter that opened up depending on which content type you had selected in the first field.
So when you looked at exposed filters, they start to look a lot like search, right. You are kind of building a search UI and you can actually add an exposed filter that’s basically for search.
It’s a keyword exposed filter that you can add to your View. How you do this is you add a filter criteria for a search term and then you can configure ‘expose this filter to visitors’ like you do for any other filter that you’re adding and that effectively becomes a search field. Now, you have to have core search enabled for this to work, but as long as you have that then you can build simple search UI using Views.
So another thing you can do in terms of making your Views interactive is you can expose sorts to your users. So exposing filters is really common, exposing sorts maybe isn’t quite as common but you see it sometimes on sites that have more tabular data.
So if you’re displaying a list of content in a table and you have a heading at the top of the table listing of all the column headings, sometimes you’ll see an arrow up the top there, next to the heading and that’s a way to expose the sort to the user. So they can control how the sort is being applied. So for example, in this view the content is being sorted by when it was last updated and you can choose whether that’s an ascending sort or a descending sort. So whether it’s showing most recent changes first or the ones that are furthest in the past.
Exposing sorts is just like exposing filters, it is just a check box when you’re configuring a sort.
If you’re showing content on your site that is really date specific like you’re showing a list of events, then you should consider using the date views module to give you more flexibility in terms of how you filter and sort your results. For example, if you want to show an upcoming events View, and you want to show only the events that are taking place in the future, you can use the Date Views module to show only content where the date associated with the content is in the future.
So Date Views is part of the Date Module so it’s an extra contributed module you will have to add, and you’ll be adding it anyway if you’re creating event content on your site. Once you’ve set that up, you can add a filter based on date, and you can control exactly what content is being displayed. So like I said future content is one use case but you might have others and there’s a lot of options and flexibility there with how you filter your content by date.
So those were all the ideas about how to add more filtering and sorting to your views and now I’m going to talk about adding contextual filters and relationships. So this is kind of going the next step, getting a bit more advanced so if you haven’t been using Views for very long or you’re brand new to Views, this is just kind of a more advanced topic. Contextual filters and relationships really are what start to make your Views very powerful in terms of displaying dynamic content throughout your site and a lot of Drupal site building is dependent on these two features of Views.
So first of all contextual filters, contextual filters are a way of displaying content that gets filtered in a dynamic way. S=So rather than always filtering content the same way, the filter is dependent on where you are on your site. So if you’re looking at a certain page, one filter will be applied but if you go to a different page then the filter changes. An example of this would be a page display where you’re filtering by taxonomy terms and based on the path of the page, the taxonomy term changes. So if you go to one taxonomy term page, you’ll see content about that term but if you go to a different page, you’ll see content about the other term. There’s a built-in taxonomy term View in Drupal. You can look at that and see how that works. You just have to enable the view on your site when you install Views.
So for example if I go to a page on my website evolvingweb.ca/category/tags/Drupal – how is the content of this page being filtered? Well, /category/tags/Drupal is actually an alias because I have Pathauto on my site, as most Drupal sites do. So the actual Drupal system tasked for this page is taxonomy/term/1 and the ‘1’ part is the argument or where the contextual filter comes in to place. So my Views configuration, I don’t have a View with a path of taxonomy/term/1. In Views, it’s taxonomy/term/% and that percent sign is a placeholder for my contextual filter and the one is just the taxonomy term ID. If I want to display this page of results rather than coming up with a separate view for every taxonomy term on my site, I can make a single View that’s dynamic. That filters the content dynamically.
In the Views Configuration, it looks something like this. There’s an advanced column in the Views UI on the right, if you expand that, you’ll see where you can add a contextual filter. So I’m adding a contextual filter for a taxonomy term because that’s what I want to filter by and then I can configure it to say I want to make sure it’s a taxonomy term and then I can configure it on the second part of that interface. So that’s for pages, contextual filters where there is an argument that’s being passed through the URL to the page, and then being used to filter the content in the Views Configuration.
The other place where we see contextual filters come into play is in blocks and so I’ll give another example. Let’s say I have a lot of nodes on my site and I want to show the tags associated with the node in the sidebar rather than as part of the node content. So I have a website with some content in the main content area but then I want to break out some of that content and put it on a block somewhere else on the page maybe on a sidebar. Again, contextual filters, I want to be filtering based on the node that I’m looking at on this page but that’s going to change based on which node I’m looking at. In the block on the sidebar, the tags for the Node 1 Block in my diagram that’s going to be a View. So I’m going to use a View to display one of the fields for my content but that view is going to be dependent on which node I’m looking at. So again we’ll talk about the URL of the page that I’m looking at. It’s evolvingweb.ca/content/blogposttitle but that’s an alias, right. So the actual Drupal path is node/1 and I can use that URL, the node/1, to get the node ID, in this case it’s 1, and I can show the tags just for node 1. So I can still filter the content in my View so I’m only showing the content associated with the node that I’m looking at. So in the configuration, again, you’re adding the contextual filter and I’m adding the node ideas to contextual filters because that’s how I’m going to tell which node that I’m going to look at. Then in the configuration, you can choose to take the node ID from the URL. There’s a setting ‘provide default value for my contextual filter’ and one of the options is ‘content ID from a URL.’
So that’s just a quick overview of contextual filters and I’ll be talking about some of the use cases for that. So the user interface can sometimes be a little bit confusing at first to wrap your head around but I just want to give you an overview of some of the places where you can use this functionality on your site.
So one really useful thing you can do with contextual filters is to show related content or break up your content and show it in different places. Often in Drupal we kind of think of being confined to the node content area when we’re creating sites and so contextual filters lets you kind of break out of that and add Views in your sidebars or in other regions on your site relating that back to the actual content of the page that you’re looking at.
For example, if I want to show a field in a separate block, I can do that by adding a view to show that field and then using a contextual filter to relate the view to the node that I’m looking at.
Another example would be if you had a field that showed related content and then using a contextual filter to only show the field for the current node.
Another thing you can do with contextual filters is use it to exclude results. So the example, we just looked at was for only showing results for the current content but you can kind of do the opposite. You can say, “Okay, show me a list of the contents except for the piece of content that I’m looking at.”
The use case for case for this would be something like you’re looking at a piece of news or an article on your site and then in the sidebar you have a list of other news items or other articles, but you want to exclude the article that the user is currently looking at because of course they don’t need a link to that in the sidebar, they’re already there. So if you want to create this “More News” block or “Other News” you can actually exclude that current node from the results using contextual filters.
So how you do this, you set up the contextual filters like what we saw before. You add the contextual filter for the node ID and then you set that up to use the node ID from the URL. Then the settings for the contextual filter at the bottom, there’s this ‘More’ section which is extremely useful and it has a check box for ‘exclude’, which just lets you exclude the current item.
So the next thing I’m going to talk about is how to extend Views. So pretty much everything we’ve talked about up and until now has been part of the Views module, but there’s a lot of modules you can add to extend Views functionality so to add extra functionality for your Views.
One thing that’s incredibly useful in our Drupal site is to set up some Views for your administrators because often Drupal sites have a lot of content and it can be really useful for administrators to have Views just for browsing through that content and you can edit and manage the content of site.
The administrative Views module replaces the default content administration pages. So the default content administration in Drupal is a little bit clunky, it’s kind of hard to add filters and you can’t customize it. So administrative views add a View just to replace that page and it sets it all up for you so you don’t have to do any configuration if you don’t have time at the end of the project but you can go in and configure that and add more settings.
Another module you can use for your administrators is draggable Views and it’s a module that adds a field to your Views or allows you to add a field of Views, but associates an order with the Views results. So this is really useful if you have content that needs to be displayed in a very particular order, but the order is arbitrary so it’s not based on a certain criteria that already exist but you want your administrators to be able to display the results in whatever order they want. So for example, on a slide show on your site, you might want to let the administrator choose exactly which order the slides appear.
So draggable views allows you set up a display which an administrator can use to reorder the Views. So it gets you a drag and drop UI for changing the order of the results and then that ordering is going to impact the actual display that the users are going to see on the site. So it’s an extra display that you’re adding to your Views and then you’re given that UI to administrators to change the ordering of the results.
Another really important module for administrative views is view bulk operations and that sets up a UI where administrators can select multiple pieces of content and then do operations on them. So delete a whole bunch of content or publish it or change the status somehow and so if you set up a table view for your administrators and you have ‘views bulk operations’ enabled on your sites then you can add ‘use View bulk operation’ field which gives you a check box for each of the items in the View’s results. Then at the top there’ll be a form where you can actually do the operation on your content.
Another really powerful thing that you can do with the View is you can combine it with the Apache Solr module, which gives you search results which you can configure using the Views UI.
So basically, your search page will be powered by Apache Solr but you can change the configuration of the results and everything using the Views user interface that you’re used to. So adding fields, changing the formatting, all of the functionality that I’ve been talking about, you can do that for all your search results. So it’s a really powerful combination.
You can use Views to display at lot more types of data. Pretty much today, I’ve been using nodes as an example but of course you can use Views to display things like users and taxonomy terms. If you’re adding other modules to your site that provide other entities or other types of content then you can use Views to organize that too.
Most modules come with Views integration so you’ll be able to control the organization of that content view as well. So things like if you are adding products or media to your site using the commerce module or the media, then you can use Views to control how that content is displayed.
If you have custom data that you’re adding using a custom module, you can add Views integration yourself and there’s a post up on our blog about how to integrate Views with your custom data.
I’ll just run through really quickly a couple of modules you can add to add extra formats to your Views. So if you don’t want to display your contents in a table or a list but you want to add something that’s a bit more dynamic, you can use Views Slideshow for example, to show a rotator on the homepage of your site so each item in the slideshow is a Views results.
Views Slideshow gives you configuration for the transitions in the slideshow and how the controls work for it to change to the next slide. So all of that is added to the Views Configuration when you add a Views Slideshow.
The Calendar Module is another example of using an extra module to format your Views in different ways.
The calendar module gives you templates that you can use to add - so you are adding a new View but you’re using a template. So rather than adding it from scratch it’s going to give you some of the configurations for displaying your content in a calendar right out of the box. The user interface for that looks something like this.
So you get a single calendar view and you’ll have a display for how you want that calendar to show up. So it could be a month’s display that would be the most common type of display but you could also show a week’s display or a day display or a year display, and then you can go in and customize that.
You can also use Views to display maps. So if you have location data in your content and you’re using something like the open layers module just to show maps on your site then you can use Open Layers Views to display a list of content with the list formatted as a map.
So obviously, there’s a lot of functionality that you can build that with Views and you’ll probably be spending a lot of time if you’re a site builder just working with this Views UI.
So just a couple of things, a couple of tips when you’re working with Views. First of all, when you are editing your View, there’s a preview at the bottom of the Views Configuration UI that you can use to see what your View’s going to look like before you publish it. So if you’re doing a lot of work, it can save you time.
You don’t have to save the Views every single time you want to see the changes. You can also export your Views after you spend several hours working on your View.
You probably want to make sure that your changes don’t get lost or blown away. So you can export Views just in the built-in Views user interface. If you’re using the features module, which I highly recommend then you can add your Views to feature which effectively exports your Views into code and that way you can add them to version control and not worry about losing all of your changes.
If you’re a themer, and you’re not satisfied with all the markup that you can change through the configuration, there is a way to easily theme your Views results and the Views module comes with a theme information page or a link in the interface for your Views display. That’s going to show you exactly which templates you are using and help you overwrite those using your own custom templates and themes.
So lots of ways to plug into to Views and do custom theming with Views content.
I know I covered a lot of different topics today and hopefully I gave you a sense of what you can do with Views and a bit of an idea of how to do some of that configuration. If you want more information, I’m doing some upcoming Views trainings, one in Ottawa on May 13th and then also at DrupalCon Portland on May 20th. I think there’s one spot left in that class at Portland. So if you really want to learn more about Views then you can sign up today and get the last ticket. So I guess we might have a little bit of time for questions? Hannah, if you…
Female: Yes, thank you, Suzanne. We had a couple come in so we can answer those and then I think we can wrap up. So the first question that came in is there a way to convert a Views page to a Views block and vice-versa through the UI?
Suzanne Kennedy: No, there isn’t. You can clone - You can clone a display in Views. So if you have an existing block display or page display then you can clone that but it will still be a page display or block display and that’s because there’s certain settings associated with the fact that it’s a page or a block like the path for pages and then for blocks whether it’s link to a page.
Female: Great. We had one more question come in, if you have visual data and we choose the grid display, table format, how can that be responsive?
Suzanne Kennedy: That’s a really good question. So usually it’s pretty hard to make tables responsive. So I’ve seen people do different thing with grid displays basically changing it so that when you reduced it in size, it collapses down into single column displaying all the results just in one column rather than having multiple columns like you’d normally have a for a table. So for example if you go to the DrupalCon Portland website, on the attendees page there is a grid display and you can collapse that down and see how that behaves but that’s what that View does.
Female: Okay. We have one last question. How do you display data in charts and graphs?
Suzanne Kennedy: Okay. Another good question. So charts and graphs similar to things like maps and slideshows, it’s kind of different way of formatting the data. So you’d want to look into some of the modules out there for Drupal that give you charts and graphs functionality. I can’t think of the names off the top of my head but basically you’re looking for modules with Views Integration that let you add charts and graphs. Then that would be another formatting option. So if you click on format then you’d be selecting the option to use that module’s formatting through interface that way.
Female: Great. Thank you so much, Suzanne. Thank you everyone for attending. Again, the slides and recording of this webinar will be posted to the Acquia.com website and we’ll also email you out a copy. Thank you, Suzanne, so much for your great presentation and answering those questions. Do you want to end with anything?
Suzanne Kennedy: No, I guess just thanks everyone for coming. I know it was a lot of information but I’m sure if you look over the slides, you’ll get a better idea of where to look in the UI and best of luck with Views configuration.
Female: Thanks so much.
Suzanne Kennedy: Thanks.