Drupal 7 Advanced Training
Illustration by John Hersey

Implementing a voting system


Drupal 7 Advanced Training

with Tom Geller

Video: Implementing a voting system

One of the best ways to encourage user participation is to set up a voting system. I will give you an example. The local baristas at the cafe in my hometown of Oberlin recently discovered that instead of just having one tip jar next the register, they now have two, labeled Ella Fitzgerald, and Billie Holiday. You vote by putting your money in the one you like better, and I hear that tips have gone way up, because people insist on voting for both. Anyway, yes, voting; Drupal does it. Let's look at some of the ways. First up is the Poll module.
Expand all | Collapse all
  1. 4m 51s
    1. Welcome
      1m 7s
    2. Planning your Drupal career
      3m 44s
  2. 25m 46s
    1. Comparing development and production environments
      6m 22s
    2. Configuring your settings.php file
      7m 10s
    3. Running multiple sites from one Drupal installation
      7m 32s
    4. Troubleshooting common issues
      4m 42s
  3. 51m 20s
    1. Understanding your Drupal site's place on the web
      2m 44s
    2. Selecting a web host
      7m 20s
    3. Using Unix's command-line interface
      8m 23s
    4. Working with your web host's access restrictions
      4m 51s
    5. Using cPanel and other graphical web host interfaces
      3m 40s
    6. Transferring files to and from your web host
      5m 49s
    7. Moving databases using phpMyAdmin
      6m 34s
    8. Moving databases using Unix commands
      6m 8s
    9. Modifying server configuration files
      5m 51s
  4. 27m 11s
    1. Learning from case studies
      3m 13s
    2. Planning your site
      4m 18s
    3. Populating your site with Devel Generate
      3m 43s
    4. Managing URL paths
      3m 20s
    5. Restricting access to downloadable files
      5m 55s
    6. Reusing site components with the Features module
      6m 42s
  5. 21m 54s
    1. Understanding and installing Drush
      5m 23s
    2. Installing Drupal using Drush
      7m 24s
    3. Building a site using Drush
      9m 7s
  6. 32m 0s
    1. Backing up with the Backup and Migrate module
      8m 17s
    2. Moderating comment spam
      6m 47s
    3. Migrating from Drupal 6
      4m 28s
    4. Migrating to Drupal 7
      12m 28s
  7. 22m 24s
    1. Letting users log in through OpenID
      5m 10s
    2. Letting users log in through Facebook, Twitter, and other services
      9m 43s
    3. Republishing posts on Facebook and Twitter
      7m 31s
  8. 1h 5m
    1. Understanding Drupal's base themes
      5m 55s
    2. Introducing base themes: Zen and subtheming
      11m 35s
    3. Introducing base themes: Fusion and extensibility
      10m 44s
    4. Introducing base themes: AdaptiveTheme and responsive design
      7m 25s
    5. Introducing base themes: Omega and mobile devices
      7m 9s
    6. Using Firebug and other theming tools
      7m 20s
    7. Modifying themes with Sweaver
      6m 59s
    8. Modifying themes with Livethemer
      8m 45s
  9. 49m 36s
    1. Understanding the Rules module
      6m 49s
    2. Demonstrating how Rules works in Drupal Commerce
      3m 53s
    3. Creating practical rules
      6m 37s
    4. Improving rules
      9m 10s
    5. Defining conditions with the Context module
      7m 51s
    6. Varying layout with the Context and Delta modules
      5m 0s
    7. Varying layout with the Panels module
      10m 16s
  10. 52m 46s
    1. Enabling social features
      9m 46s
    2. Implementing a voting system
      9m 15s
    3. Rewarding good behavior with the Userpoints module
      5m 57s
    4. Setting up Organic Groups
      6m 28s
    5. Adding content to groups
      2m 21s
    6. Seeing group activity better with views and panels
      10m 13s
    7. Making groups private
      4m 54s
    8. Letting each group have its own permissions
      3m 52s
  11. 25m 32s
    1. Understanding packaged Drupal distributions
      2m 8s
    2. Getting a head start with Acquia Drupal
      7m 28s
    3. Creating online storefronts with Drupal Commerce
      6m 53s
    4. Creating government web sites with OpenPublic
      9m 3s
  12. 1h 30m
    1. Taking the assignment
      3m 26s
    2. Planning the project
      3m 43s
    3. Preparing the infrastructure
      8m 42s
    4. Starting the design
      7m 35s
    5. Filling in the content
      7m 29s
    6. Developing the layout
      10m 27s
    7. Finishing the layout
      7m 8s
    8. Refining the CSS
      6m 32s
    9. Setting up sections for regional offices
      4m 53s
    10. Configuring regional offices
      7m 18s
    11. Connecting to social media
      5m 9s
    12. Cleaning up
      12m 32s
    13. Securing the site
      5m 56s
  13. 37s
    1. Next steps

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Drupal 7 Advanced Training
7h 50m Intermediate May 17, 2012

Viewers: in countries Watching now:

This course teaches web site designers how to take their sites to the next level with a few advanced techniques and the free and open-source Drupal software. Author Tom Geller shows how to configure the most popular add-on modules; use *nix commands and an FTP program to manage a Drupal site on a web server; change its visual appearance using the latest graphical tools; automate and speed through common tasks with Drush; integrate with social media sites; and see how "supermodules" like Panels, Context, Rules, and Features open up new worlds of code-free development.

Drupal 7 Advanced Training was designed as a follow-up to Drupal 7 Essential Training and it also dovetails nicely with our other Drupal courses, such as Drupal 7 Reporting and Visualizing Data and Create Your First Online Store with Drupal Commerce.

Topics include:
  • Moving a site from the development environment to production
  • Hosting a Drupal site
  • Moving databases with phpMyAdmin and Unix commands
  • Making site administration more efficient with Drush
  • Backing up site data
  • Moderating comments
  • Migrating from previous versions of Drupal
  • Working with themes
  • Creating variable layouts
  • Enabling social features
  • Creating an online store with Drupal Commerce
Developer Web
Tom Geller

Implementing a voting system

One of the best ways to encourage user participation is to set up a voting system. I will give you an example. The local baristas at the cafe in my hometown of Oberlin recently discovered that instead of just having one tip jar next the register, they now have two, labeled Ella Fitzgerald, and Billie Holiday. You vote by putting your money in the one you like better, and I hear that tips have gone way up, because people insist on voting for both. Anyway, yes, voting; Drupal does it. Let's look at some of the ways. First up is the Poll module.

I showed it off in the Adding Polls video in the Drupal 7 Essential Training course. But very quickly, here it is again. You first have to enable it, and you do that by going up to Modules, and finding it in the Core group. Turn it on, and save as usual. That creates a new content type called Poll. So we just Add content, select Poll, and then add our question, and then save.

You vote on it simply by viewing the node. Here I will select Option A, and Vote, and Drupal keeps track of who has voted, so now that I have voted, I can't vote again. Instead, I see the results of the poll. However, the Poll module is extremely limited; it only gives you these radio button choices. So let's move on to Contributed modules. There is a huge selection; so many that they have their own category on drupal.org. As usual, we go to drupal.org/ project/modules; Filter by compatibility, and then choose the Evaluation/Rating group, and Search.

These are sorted by popularity, so I will just go through the first few. First up is Webform, which I don't consider a voting system, per se. It's really for surveys. If you're curious about it, see the video Getting Feedback with Webforms in my Drupal Gardens Essential Training course. Next up is Voting API. It doesn't have an interface of its own; instead, it's an internal framework for all the other voting modules. We have to install it anyway, so we might as well do that now. I will open a new tab.

That URL is drupal.org/project/votingapi. Go down, and install it as usual. Although it doesn't have an interface directly, it does have some configuration options. We see them by going to Configuration, and then down to Voting API. Let's go back, and take a look at those modules. Now we move on to Fivestar, which I would consider the first real voting module we've seen in this list. I showed how to use it in the video Allowing Users to Rate Content in Drupal Gardens Essential Training.

But once again, I will give a very quick demo here. We go to the Modules homepage, which is at drupal.org/project/fivestar. Scroll down, and install it as usual. The group it's in is way down at the bottom. Then we Save configuration. To make use of Fivestar, you create a content type, and then add a field type that represents Fivestar. I will do that now. Go up to Structure, Content Types, and Add content type.

I'll call this Fivestar vote. Then I will go back, and add some fields. Really, the only one I need is a voting field; Vote for this node. The Field type is Fivestar Rating, and you have a few different options here. I will leave it on the default, and Save. And in fact, I will just take all of its default settings. Now we can create some content of that Fivestar vote type, and Save.

Now, when you take a look at that node, you can rate it from one to five stars. As you see, it has a lot of neat JavaScript tricks in here, and you can change the behavior of some of them in those settings that you saw. Some of the other settings for it are in the display section of that content type. We go there by Structure, Content types, then next to Fivestar vote, click on manage display. When you click this gear, there are your options. But let's go back to our modules.

The last one up in our quick survey is the Flag module. It's an incredibly elemental module. It just lets people flag content, but that too can be used as a simplified yea or nay voting system. So let's take a look. I will open that up in a new tab, and as you see, the URL is drupal.org/project/flag. Flag is one of the best documented modules I've seen. First of all, it integrates with several other modules, and you can see the full list by clicking this many modules link here. Look that; 162 modules integrate with it.

It also has terrific documentation. If we scroll down, you see all of these articles that are about flagging. But let's just go ahead and install it. Flag actions is worth exploring, but we'll just leave it off for now. Go to the bottom, and save. Once that's done, you can see a record of the type of flags available under Structure, and then click Flags.

When you install Flags, it comes with one type; this bookmarks kind of flag. We could go back and edit this flag, but I think I will create a new one instead. I am going to create a flag that lets people to vote on whether we should keep content, or delete it. I will name it keep_this_content, and notice that you need a machine name, not the human readable name, so it's all lowercase letters, and underscores. We'll have it affect nodes. As you can see, you can also have people flag users, which is extremely useful if you start to have problematic users or comments.

We submit, and then we can fill out a lot more options. The Title I will just have as Keep this content? This is an administrative title. I just want to talk a little about this next option: Global Flag. For any voting system, you're going to leave this off. When it's turned on, the vote is shared among all the users, so one person might click it to say yes, keep this content, and then if the next person clicks it again, that switches everybody's vote back to no, we want to delete this content. So we'll leave that unchecked. For the Flag link text, I'm going to say, I like this content and think it should stay on the site.

By the way, I noticed a bug in the version of flag that I'm using, where if you enter too short a flag link text, it actually doesn't appear correctly on Bartik. I hope and expect that that will be fixed by the time you see this video, but if not, play around with the length of this text. For the Flagged message, I will say Thank you for your vote! Unflagged, I will make very similar; I dislike this content and think it should be removed. And the Unflagged message will also be, Thank you for your vote! There are lots and lots of options here, but the most important one is which content you want to be able to flag.

I will do it for basic pages, then go down, and submit. Now let's test it by going to our front page, and finding a basic page. There's one, and as you see, there's our flag. If we go to the node itself, we see that, by default, the flag is also on the full view of the node. Well, let's say that I do like this content. I click that, and I get that message: Thank you for your vote! It also changes the flag to this, I dislike this content and think it should be removed, so obviously, you can change your vote as you go.

One last thing you should be aware of when you set up voting on your site, no matter what system you use: by default, most voting systems don't allow anyone except administrators to vote. The Flag module is unusual in that it stores permissions on a flag by flag basis, but the others store them with the site-wide permissions. So whenever you install one of these, be sure you go to People, and then Permissions, and then scroll through to see how the permissions are set. For example, there's Fivestar, there's Flag; now, for Flag, it's only administer flags, so people can still vote on a flag by flag basis, as I say.

There is Poll, and again, people aren't allowed to vote on polls by default; we only could because we were the administrator, and so on. Now, there is one kind of voting system we didn't talk about; that's the one that you build yourself. If you watched lynda.com's Drupal 7 Reporting and Visualizing Data course, you know everything you need to add a voting field to each user's profile, and then collect the results into a view. But I've found the systems you saw here to be easier to use, with features that would be hard to implement from scratch.

There are currently no FAQs about Drupal 7 Advanced Training.

Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Drupal 7 Advanced Training.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.