Free Videos about Mastering Views

How To: Using Drupal Views module

Tagged:  
Play Video
Movie link (right-click to download)
Problem with this video? Contact me

Your task, should you attempt it without the help of Views (and likely fail - unless you’re willing to write your own SQL), is to create a front page listing of content where the top-most item is less than 2 weeks old and has an average star rating of 4.5 or higher. This is what is presented in this video - using Views, of course.

So, maybe you’re like me, and you’ve waited and waited until you think you absolutely have to start using Views before you take that first step.

Well, here’s a great chance. In this Drupal video about the Views module, I’ve opted not to create a new custom view from scratch. I won’t insult your intelligence by assuming you don’t know what Fields are in a database. Rather, I walk through the various settings which Views provides and attempt to help you get familiar with its various pieces.

There are simply so many things you can do with Views, that it pays to know how things go together. If there’s one thing you take from this video, I hope it’s the knowledge that your imagination may be the only limiting factor.

The video covers the various settings for a ‘view’ and introduces what I think of as ‘subviews’ (officially called displays - think, “display’s of a view”). I cover the various display types, highlight ‘view display styles’ and end up with a front page which has more character than what comes with your standard Drupal. Views is definitely a module you want to know about!

In the video I made reference to a few other resources. Here they are.

I haven’t been able to get any of the GotDrupal.com videos to play. Please make them available for subscription via RSS feed & Miro.

Firefox 3.0.6 with Quicktime viewer 7.6 didn't work for me but videos played fine in IE7.

90% of the time it only works with IE.

On the screencast -> good introduction. Thx.

But really cool would be an advanced Views screencast. Most of the screencast I have watched are about more or less basic stuff. Well I mastered filters, fields and sortcriteria but things like Arguments are a mystery to me. I would be really glad if anybody would create an usefeul introduction to this "deeper" stuff.

For the rest of the vids -> Good stuff!

I've been watching my logs, and for those of you posting about not being able to see the videos I'm having a hard time tracking things down. I'm using Firefox 3.0.6 and QT 7.6 myself (on a Mac - not Windows) and not having issues (other people are too) For some people, there were problems with some of the Agents being used and my mod_security rules were stopping some clients.

For other things, I've been looking at the logs for the actual movies and the vast majority of people connecting are able to view the videos. If you are having problems then please send me as many details as you can. Send them to matt /at/ gotdrupal.com.

Thanks

I've just tested with Firefox on Windows and this seems to be the problem with the site. I'll have to look into the code and see if something is not working the way it should be.

Looks like it was an issue with the jquery.media plugin that jQuery Media module uses (which is used on this site). I found the issue on this drupal node. Thanks to user mattez for making it easy to find.

I've posted a patch file to the issue queue for jquery_media module for anyone who's interested.

The problem is not with the browser or jquery or whatever. It's with Quicktime being a proprietary format. QuickTime player is only available for Mac and Windows. And I'm running GNU/Linux. Can you please convert your videos to some open standard, like mpeg?

Quicktime Videos have lots of problems with Windows and Linux Users, Flash Video is much more portable especially for Websites, if you have to use a website that uses Quicktime use the VLC media player with Firefox Media Player Plugin. Linux users will probably run into the most problems with this format. And Windows users who don't like downloading quicktime (many)

Flash isn't convenient either but what's wrong with OGG theora? open and VLC is multi-platform.

I truly appreciate the large format videos. They play fine on my Ubuntu 9.10 and Konqueror. Firefox is fine too.

Currently, I've not found anything out there in module land that does a clean implementation of adding an RSS enclosure to the RSS feed - at least not for Drupal 6. Anyone else coming across this?

WARNING: Developer speak coming next...

Views supports the default nodeapi for Drupal when it parses through the op = "rss item". Therefore, it would be ideal to have something that would simply add the enclosure if you're using something like fieldfield and cck. So, I'm working on a module that will do this (part time that is) and should have this one solved so the videos will be included into the RSS feed, whether a default Drupal feed or using Views.

Video doesn't play for me in IE7 or Chrome on XP.

That was a great video.

But when I try it out the nodes with a high rating is showing twice on my frontpage...?

/Jens

The trick to troubleshooting views is to use the live preview it provides at the bottom of the views interface. Look at the SQL query generated. If you don't fully understand it, then you may need to post it and ask for review. Drupal forums or even on this site might be where you can get some help with it.

It might be that you need to set the distinct value, which will limit the results if any given node can potentially be returned more than once (typically, however, this applies to a query that has a join condition).

You really have to test all your views to make sure they return the results you want. Views is ALWAYS going to return exactly what you specify based the query it creates. It helps when you have at least a bit of understanding about SQL and how it works.

How can we set the items per page to a view, programatically?
The similar code we are using in drupal 5 is as follows:
$view = views_get_view('visual_articles');
print (views_build_view('embed', $view, array(0 => '1', 6 => $key[1), $view->use_pager, $view->nodes_per_block));

Can u please give me the corresponding code in druapal 6
Thanks in advance.
 Cibi

like this straight forward style of tutorials ! best i've seen yet.

Thanks for it!

btw. had also problem to see the video , passes threw it by clicking the view tag.

Thanks for the nice tutorial, you did a great job explaining it. You could put some tags on the video of "digg" "reddit", etc, because it's similar to how those sites are made, and seems like a lot of people these days want a "digg-like" site.

I was actually in the middle of Chapter 4 in "Using Drupal" about Product Reviews, so this video was a perfect companion to that chapter. It was nice seeing it live working the way you did it.

Keep up the great work!

Very useful lines of code to embed "Views 2" views into your nodes. Works almost as the old

views_build_view

in Drupal 5 but in Drupal 6. This is also a way to embed views programatically into your pages and nodes.

I found useful info here:
http://pedroposada.com/blog/embed-views-2-nodes.html

Thanks so much for these videos and all of the work you're putting into them. They are extremely well done, and very helpful.

I have a question about this one that isn't exactly about Views. Pretty close to the end, you see a "ghost menu" (Edit Export Clone in white) that I've been getting on my site as well. I wondered if you knew where it comes from and how to get rid of it.

http://www.flickr.com/photos/cookwood/3468972868/

thanks!

Liz

Liz, you'll find that these only show for users who have access the administer views permission. It's a convenience feature (which you'll find useful at some point) for moving back and forth between editing a View and previewing it.

When editing a View, click the link to view the current View Display you are working on (it's up to the right of the Export and Clone links - at the top-right of the View settings). Once you are previewing the way the View is presented, if you want to tweak, then click this "ghost menu" and you'll be taken back to edit. The next time you click Save you'll be returned to the last destination, which is the actual view of the View. It essentially allows you to move back and forth between the real display of the View and editing it.

Hope this helps out and makes sense.

I'm not sure how to disable, because I've never wanted to. The menu doesn't show on your site for normal users, only admins.

Matt

OK, that makes sense. I've just started experimenting so I haven't been going around so much as a visitor and didn't realize it was dependent on my being an admin. Sounds like it'll be useful.

Would you ever be willing to answer a few more questions, perhaps via email? I'm doing a lot of reading and experimenting, but it would help so much if I could just check in with someone to say, is this right?

best,
 Liz

Great video, thank you very much!

Another thank you here Matt. It's my first week with drupal and I was rather intimidated with the content of this video as the views 2 module is complicated. So I was surprised and pleased to get the end results as you were demonstrating. So many new things are interdependant yet required that when starting out with drupal that to get this degree of function is amazing to me and you covered most everything so well it made it possible. Thanks.

I did find a number of new terms and concepts and had to backtrack for a correction exactly where you warned people would go wrong: at the Override vs. Update Default Display choices!

I wish to help others as new to this as me. I could not get the Relationship added the way you (quickly) described it. One must select Defaults for the "display" and then you get the + button that allows a choice of adding the "Node: Voting results" type.

Hope this helps a little...Randy.

One more thing, you will get duplicate posts if you do not add one more filter to those in the video. You need ..
Node: Promoted to front page No ...don't worry, they go on the front page as attachments without being promoted in the normal way!
This filter is for the Attachment display. Without it when you promote any page that also passes the attachment filters you will get duplicates. I experienced triplicates for some content.

Hey thanks a lot, great video. I have a few question with the applications of the Views module. I am trying to have Views create a page for me to list all the terms in a certain vocabulary. But I can't figure out how to do it.

I added a Vocabulary called "Classified", and underneath it, I added all the terms in a hierarchical fashion. For example: For Sale >> Electronics, Clothes, Books, etc. Jobs >> Accounting, Finance, etc. All I want to do is have all these terms listed on a page so users can see different categories, click on them, then see all the postings other users have made. I used the Views module to list all the terms but it won't work. I set it to create a page, and for the Fields, I put in Taxonomy All Terms...

Had the same issue. Put in a whole list and it would stick for some reason. I finally broke down and had my friend look at it, not sure what he did but the list finally did appear like it was supposed to.

I copied this from Pro Drupal Development by John VanDyk. I hope they don't have a problem with me publishing their copyrighted material. Sry. You will need two arguments is views (I haven't actually done this but I image that it might work this way), the first argument is the term and the second argument the depth of terms to be included as explained below.

Specifying Depth for Hierarchical Vocabularies
In the previous examples, we’ve been using an implied parameter. For example, the URL
http://example.com/?q=taxonomy/term/5
is really
http://example.com/?q=taxonomy/term/5/0
where the trailing 0 is the number of levels of hierarchy to search when preparing the result
set for display; all would designate that all levels should be included. Suppose you had the
hierarchical vocabulary shown in Table 14-3.
Table 14-3. A Geographical Hierarchical Vocabulary (Child Terms Are Indented Below
Their Parent)
Term ID Name
1 Canada
2 British Columbia
3 Vancouver
4 Ontario
5 Toronto
The first level of hierarchy is the country, Canada; it has two children, the provinces British
Columbia and Ontario. Each province has one child, a major Canadian city where Drupal development
is rampant. Here’s the effect of changing the depth parameter of the URL.
All nodes tagged with Vancouver will share the following URL:
http://example.com?q=taxonomy/term/3 or http://example.com?q=taxonomy/term/3/0
To display all nodes tagged with British Columbia (but none tagged with Vancouver), use
this URL:
http://example.com?q=taxonomy/term/2
334 CHAPTER 14 n WORKING WITH TAXONOMY
The following URL applies to all nodes tagged with British Columbia and any British
Columbian city (note that we’re setting the depth to one level of hierarchy):
http://example.com?q=taxonomy/term/2/1
All nodes tagged with Canada or with any Canadian province or city will be displayed if
you use this one:
http://example.com?q=taxonomy/term/1/all
nNote The result set is displayed as a regular node listing. If you want to have the node titles and/or
teasers displayed hierarchically, you’d need to write a custom theme function that does this or use the
views module (http://drupal.org/project/views).

Yeah, as some of the other commenters have posted, the problem is not the site, it's the codec or format of the video that you are using. It appears that the version of QT that you are using is too "new" -- it hasn't been ported to opensource players. On my windows machine, neither VLC or Mplayer can play this video properly. Can you please post it using some other format, like flash or ogg? Thanks ... it's an otherwise great video (I was able to view it on another drupal site -- where it was in flash).

When I preview the Page and the Attachment views in Views, both show the 5 starred story, but when I actually go to my "frontpage", the 5 starred story doesn't show up! any idea why? I tripled checked to make sure all my settings (in frontpage views and subviews, site information, etc) matched the video. The only two differences I found were that my attachment settings call "Voting API results" just "Vote results" and that when I List all my Views, the frontpage view is stored in "Default" instead of in "Override":
*Default Node view: frontpage (default) Edit | Export | Clone | Disable
Path: frontpage
Feed, Page

thank you!

here's the query (i took out the -14 days query to simplify):
SELECT node.nid AS nid,
node.sticky AS node_sticky,
node.created AS node_created
FROM node node
INNER JOIN votingapi_cache votingapi_cache_node_percent_vote_average ON node.nid = votingapi_cache_node_percent_vote_average.content_id AND (votingapi_cache_node_percent_vote_average.content_type = 'node' AND votingapi_cache_node_percent_vote_average.value_type = 'percent' AND votingapi_cache_node_percent_vote_average.tag = 'vote' AND votingapi_cache_node_percent_vote_average.function = 'average')
WHERE (node.status <> 0) AND (votingapi_cache_node_percent_vote_average.value >= 90)
ORDER BY node_sticky DESC, node_created DESC

Here are my attachment settings:
Attachment
Basic settings
Name: Attachment
Title: The most popular story
Change settings for this styleStyle: Unformatted
Change settings for this styleRow style: Node
Use AJAX: Yes
Items to display: 1
Distinct: No
Access: Unrestricted
Caching: None
Link display: Page
Exposed form in block: No
Header: None
Footer: None
Empty text: None
Theme: Information
Attachment settings
Inherit arguments: Yes
Inherit exposed filters: No
Position: Before
Attach to: Page
Relationships
Node: Vote results
Arguments
None defined
Fields
The style selected does not utilize fields.
Sort criteria
Node: Sticky desc
Node: Post date desc
Filters
Node: Published Yes
Vote results: Value >= 90

This was a great tutorial as many of I found on your site. I especially love your logical and pragmatic rather than "I just tell you all I know" approach. Good quality of video as well. Very well done, keep it up! Here, have a donation from me to continue screencasting =)

You rock!
Thanks for the video. It helps me a lot.

Really appreciate the vid,

You went a good pace, not too slow, not too fast and covered relevant needs for most people trying to learn views, well I guess I can't speak for all, but it was spot on for me.

Thanks again,
 kraymer

I have watched this video a couple of times and I continue to learn more. Thanks for taking your time and explaining the various parts of the Views interface. Very helpful. Keep up the good work.

Definitely a service to the community - thank you very much

Try as I might I could never get the "sub-theming" on the video to work. I noticed some differences between the UI on the vid and what I have on my machine. Looks like I'm using Views 2 datestamp = "1259799377", so that might be the issue. I did get everything working as it should by modifying the default settings and will go with that for the time being (during development)

There was also a hitch getting ANYTHING to work error-free though as long as I had the 5-star module enabled. Once I disable that I could work ok... got the view set up and turned 5-star back on and everything was kosher. Just thought I'd throw that little tidbit out for anyone else that was having this problem.

In any case thanks loads for the video! Even though I couldn't get my setup to work "as advertised" you saved me hours, possibly days!

Awesome videos, thanks for putting the time and effort into sharing it with us.

I've installed the views and views UI module along with the advanced help module. It seems like everything is there, but I think I'm missing something. See here: http://images.tolleycoder.com/views2.png

I'm I missing something, or am I simply using the views module wrong?

Thanks in advance