Friday, October 8, 2010

Displaying Popular Content In Drupal

The list of popular content is not a new feature in websites nowadays. By using the list of popular content in your website, you and your visitors will know which articles are read mostly by the visitors. In Drupal, displaying the popular content can be done relatively easy. You just need the Statistics and Views modules. The Statistics module is already bundled with Drupal and the Views module can be downloaded from http://drupal.org/project/views.

Prepare The Modules

You can follow these steps to prepare the required modules.
  1. Download Views module from http://drupal.org/project/views.
  2. Extract it to to sites/all/modules/ or sites/default/modules/.
  3. Log in to your Drupal website as administrator, then click menu Administer - Site Building - Modules.
  4. Enable the Statistics, Views, and Views UI modules, then save your configuration.
  5. Configure the Statistics module by clicking menu Administer - Reports - Access log settings.
  6. Enable the Count content views option, then save the configuration.

    Node counter
Build The View

You can follow these steps to build and customize the view.

  1. Click menu Administer - Site Building - Views.
  2. Enable the popular view.

    Enable popular view
  3. This view is ready to use now. But, I want to make some modification from its default setting. So, I click on the Edit link.
  4. I want to modify the Popular (block), this block will display list of popular content all this time, so I click the Popular (block) tab.

    Edit popular block
  5. In the Basic settings part, I click on the Use pager value (in picture below the value is Yes).

    Edit basic setting

    Scroll down the page. In this form, I choose No because I don't want to use pager. Then, I click the Update button.

    Edit pager
  6. I also change the Items to display to 10 and More link to No. The way to do this is same like the previous step.
  7. I don't want to display the total views number in the list. So, I click on the Node statistics: Total views from the Fields part.

    Edit fields

    Scroll down the page. In this form, I give a check on Exclude from display then, I click the Update button.

    Exclude field
  8. I only want to display the node with type blog. So, in the Filters part, I click on the + (plus) sign.

    Edit filters

    Scroll down the page. In the form like this, I give a check on Node: Type option then, I click the Add button.

    Filter by node type

    Then, the form like this will appear. I choose the Is one of option and check the blog checkbox. After that I click the Update default display button.

    Choose node type
  9. Click Save button. Now, this view is already customized just like what I want.
 Display The Block

Now, we just need to display that view as a block.


  1. Click menu Administer - Site building - Block.
  2. Scroll down the page and search for Popular content block. There might be two blocks named Popular content. Only one of them is the view that we have created before, and the other one is the block from the Statistics module. You can check it by enabling both of them. The one we have created before has no "All time :" letters in its content.

 

No comments:

Post a Comment