Measure node completion in Drupal, part 1

Peter Vanhee
5 Apr 2010
4 Comments
Peter Vanhee
5 Apr 2010
4 Comments
Peter Vanhee, 5 Apr 2010 - 4 Comments

Measure node completion in Drupal, part 1

Introducing Content Complete, A CCK-based Drupal module

Ever needed to measure the completeness of your Drupal nodes? Or wanted to motivate your users to complete their content until it reaches a 100%? In this post, I'll outline the basic configuration of Content Complete, a new Drupal module that does exactly that. Content Complete started as a simple module to show completeness of nodes, but over time has included Rules support to manage complex user flows, dynamic caching and Views integration. In this first post, I'll guide you through the steps to configure the module, output the percentage of completeness and show you how to theme the percentage bar. In the second post of this series, I'll show you how to output all this data using Views.

To start, you need to download and install the module from the download page or directly via Drush.

Configuring the module

Screen_shot_2010-04-05_at_17.40.17.png

Completeness of nodes is measured per content type. For each content type, you need to select the fields you want to be included in the percentage. For example, you have a content type "Artist" with the fields "Title", "Release Date", "Label" and "Website". You want all of those fields to be completed by your users, such that the node is at 100%. If, for example, a user only fills in a value for "Title" and "Website", the completeness will be at 50%.

To activate content completion checks, go to Administer > Content Management > Content types, and click 'edit' on the content type you wish to have checked. Enable the checks, save the content type and reload the page to find the fields you can check for completeness, as shown in Figure 1.

If you are using the Content Profile module to manage user profiles, the module will figure out the profile node that belongs to the logged in user.

Displaying completeness

Screen_shot_2010-04-05_at_18.32.52.png

Content Complete provides various ways to display data like the percentage, a percentage bar and the next field to be completed. These are the different blocks provided by the module:

  • Content Complete: current node: show completeness for the current node. Can be shown only at the node page.
  • Content Complete: Album (first node): show completeness for the first node it finds of the specified content type and for which the logged in user has edit permissions. Can be shown at any page. Use this only if you have one node of that content type, for example, the associated profile node of that user.
  • Views. Will be reviewed in the next post of this series.

To enable a block, go to Administer > Site building > Blocks and drag and drop Content Complete: current node to the region you want to display the block at. Then, navigate to your node to see the block appear (see Figure 2). You can also configure the block to be hidden when 100% is reached.

Who gets to see what: configuring permissions

Screen_shot_2010-04-05_at_18.53.13.png

The completeness block will be shown to every user including the anonymous user. Often, you will want to provide this block only to users who can edit the content. You can change the permissions at Administer > User management > Permissions.

Theming

Screen_shot_2010-04-05_at_19.06.11.png

The module provides several CSS classes and ids for the themer. For example, you can use '.cck-complete-percent-bar-leq-25' to style the appearance of the percent bar if the percent is lower or equal (leq) to 25. Likewise, there are classes for leq-50, leq-75 and leq-100. Absolute numbers can be styled using .cck-complete-percent-bar-x (with x replacing the actual percentage). Here is an example we used in one of our projects:

.content-complete-percent-bar-wrapper {
  background: #333333;
  border:1px solid #666666;
  padding:1px;
  margin: .5em 0;
}
.content-complete-percent-bar {
  height: 5px;
  background-color: #8CC101;
}

What's next

In the second part of this series, I will show you how to use Views to set up different views on the completeness of your nodes.

Comments

Comments

Anonymous
29 Jun 2010

Hello,

I have tried searching on drupal but i cant seem to find an answer. For some reason the Content Complete block is not appearing. I assign the block to avrious regions, and on various themes.. but each time it does not display. I try with different users as well, but nothing appears. I ran through the steps above, but i can seem to find what i am missing to get the block to display. Please could you assist.

Hello,

I have tried searching on drupal but i cant seem to find an answer. For some reason the Content Complete block is not appearing. I assign the block to avrious regions, and on various themes.. but each time it does not display. I try with different users as well, but nothing appears. I ran through the steps above, but i can seem to find what i am missing to get the block to display. Please could you assist.

Anonymous, 29 Jun 2010

Hello,

I have tried searching on drupal but i cant seem to find an answer. For some reason the Content Complete block is not appearing. I assign the block to avrious regions, and on various themes.. but each time it does not display. I try with different users as well, but nothing appears. I ran through the steps above, but i can seem to find what i am missing to get the block to display. Please could you assist.

Anonymous, 29 Jun 2010
Anonymous
30 Jun 2010

I didnt realised it wasnt dynamic, and that you had to create the node first for it to reflect, and display some information. Is it possible to have such a feature, where the user can see in real time what stages have been filled out, through Jquery and ajax.

I didnt realised it wasnt dynamic, and that you had to create the node first for it to reflect, and display some information. Is it possible to have such a feature, where the user can see in real time what stages have been filled out, through Jquery and ajax.

Anonymous, 30 Jun 2010

I didnt realised it wasnt dynamic, and that you had to create the node first for it to reflect, and display some information. Is it possible to have such a feature, where the user can see in real time what stages have been filled out, through Jquery and ajax.

Anonymous, 30 Jun 2010
Rich
2 Jul 2010

Maybe a bit off topic, but I came across Content Complete as I was trying to find the best way to have such completion percentage in a custom module that handles a user's profile. I've been trying to figure out how to turn Content Complete into a program that instead of looking at a node's CCK, it looks at a module's hook_scheme to get the fields it populates for a user (must have a uid column), then let admin select which ones are needed for completeness, and then show completeness meter in blocks.

Anyway, has anyone thought of doing this? Any other such projects going on? Thought I would write here and also on drupal.org.

Maybe a bit off topic, but I came across Content Complete as I was trying to find the best way to have such completion percentage in a custom module that handles a user's profile. I've been trying to figure out how to turn Content Complete into a program that instead of looking at a node's CCK, it looks at a module's hook_scheme to get the fields it populates for a user (must have a uid column), then let admin select which ones are needed for completeness, and then show completeness meter in blocks.

Anyway, has anyone thought of doing this? Any other such projects going on? Thought I would write here and also on drupal.org.

Rich, 2 Jul 2010

Maybe a bit off topic, but I came across Content Complete as I was trying to find the best way to have such completion percentage in a custom module that handles a user's profile. I've been trying to figure out how to turn Content Complete into a program that instead of looking at a node's CCK, it looks at a module's hook_scheme to get the fields it populates for a user (must have a uid column), then let admin select which ones are needed for completeness, and then show completeness meter in blocks.

Anyway, has anyone thought of doing this? Any other such projects going on? Thought I would write here and also on drupal.org.

Rich, 2 Jul 2010
Andrea Pescetti
23 Nov 2011

Comments are closed. You can contact Peter through his drupal.org contact form. To contact the current Nuvole team, use the contact form on this site.

Comments are closed. You can contact Peter through his drupal.org contact form. To contact the current Nuvole team, use the contact form on this site.

Andrea Pescetti, 23 Nov 2011

Comments are closed. You can contact Peter through his drupal.org contact form. To contact the current Nuvole team, use the contact form on this site.

Andrea Pescetti, 23 Nov 2011

Get your project started today!

Contact us