Skip to main content
Working from scratch, following simplicity

Popular content in Drupal with Views

A simple method to know the popularity of your own site pages is given by Drupal with statistics core module, but using Views is possible to improve the collected data, having a more defined table, subdivided in popular content and today's popular content.

Sure, you can't get the results of Google Analytics module or other commercial services, but you can obtain an useful and personalized table, that helps you to understand the taste of your visitors.

Popular content
Table: Popular contentTable: Today's popular content
Table with Popular content Tabella with Today's popular content

Prerequisites

Pannello delle impostazioni di Statistiche in Drupal 7

You have to activate the Statistics in the Core modules from here: http://my_site/admin/modules
Then select Enable access log and Count content views from here: http://my_site/admin/config/system/statistics
(on item Discard access logs older than I choose 1 day, but this is a subjective choice).

Finally check if you have installed the Views module.

First steps with Views

Come attivare la vista Popular Content in Drupal 7

Popular content view is disabled in the standard configuration of Views. You have to click on the enable button from this page: http://mio_sito/admin/structure/views. Then this button changes its name in edit and you have to click again in order to manage this view. There are many options, but for a normal use these are OK. If you want to test new setting or try new options, you can view the results below the edit page, enabling the Auto preview item.

After all if your changes are good, you have to click in the Save button, else click on Cancel button.

In this edit menu, I have changed only two Displays, at the moment I don't use the relative block displays:

  • Popular (page) --> page visible from here: http://my_sito/popular/all
  • Today (page) --> page visible from here: http://my_sito/popular/today

Settings

I have modified these following three sections:

  1. FIELDS, like suggested by the title, here you have to add or remove the fields that will appear in the final table (simply: the number of the fields corresponding to the number of the columns). If you click on the add/rearrange button in the right, you can add and order or remove the item. Otherwise if you click on the single item, you can change the settings of this one. Make attention when you apply the modifications: if you choose This page (ovverride), the settings are available only for this display, alse All displays are available for all.
  2. FILTER CRITERIA, gives the criteria to select the content. I have added only a field: Content: Type and then selected the types of content to display and count.
  3. PAGER, I have chosen All items, without any specified number of items (default is 25).

I put two useful pictures to show you my settings, and my export view code here: export_popular_content_view.txt (you can import in your Drupal site, it is sufficient to click in the import button in the Views menu page and to Paste view code here, but check the incompatibilities!)

My settings
Popular (page) settingsToday (page) settings
Display: Popular (page) settings
Today (page) settings

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Sponsored Links
Pubblicità

Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.