Skip to main content

An introduction to the Radioactivity module

Developer
Feb 26, 2013
The Radioactivity module provides a custom field type with a special radioactivity metric that can be assigned to content types. User interaction can maintain high-level radiation or - if interaction is not significant - a cool down mechanism can kick in. It can be used as a ‘hotness’ metric, a regular view counter, and even more. I explain the principles and walk you through the setup of this highly useful module. The first time I met the Radioactivity module in a project, my task was to display the three most read articles. The basic problem was that site visitors clicking on the promoted articles would increase the number of views and therefore keep them in the most read category, while other articles didn’t have the chance to get there. This is where the Radioactivity module came into play.

Principle of operation

The module was developed by Uusi Suomi with the main goal to replace the node counter. The operating principle of the module follows the mechanisms of radioactive materials. You might be familiar with the term: half-life. This is a fixed constant of natural radioactive isotopes that denotes the time required for the measured radioactivity to fall to half its value. For example, radium has a half-life period of 1620 years. In case of the Radioactivity module, you can use this mechanism to keep track of the ‘hotness’ of different types of content. You just have to enter a starting value for radiation and a half-life time.

Installation

The module is only dependent on the ctools module, but if you want to use all of its features, you need the Views and Rules modules as well. Standard installation via Drush: drush dl radioactivity

Security settings

The first thing you can set is the salt checksum. If you want to protect the radioactivity field against scripts or bots, you need to set up the salt, a random string. Then the module can calculate a checksum for each AJAX call. The next thing to set up is flood protection. This means, you can prevent the use of the callback function to raise the radioactivity field value. The radioactivity value will be calculated more accurately, but keep in mind this setting requires more resources.

The Decay Profile

The most important fields in this section: Name: This is the profile name. You should choose a name that reflects the scope of the profile. For example, if you want to measure the views of articles and videos, you have to create separate profiles for each. Enable energy decay: By using this checkbox you can indicate if the Energy field value should automatically be reduced with time, or only by user interaction. Half life: Here you can specify (in seconds) how much time you want to have for halving the value of Radioactivity. The default value is 21600, which means six hours. For example, if you set here 3600, and the value of the field was 1000 in the beginning, after 3600 seconds (one hour later), the value of the field will be reduced to 500, and 250 an additional hour later. Energy cut off: This is the Energy level considered zero and not halved any more. Incident storage: Here you can set up how to store events. Three options are available:

  • Live storage: The field value changes directly to the field, every event affects the value in real time.
  • Deferred storage: All changes of the field value set up a temporary field. This will only change the content type’s field when running cron.
  • File storage: All changes are stored to an external PHP file.

When you are done with everything, save the profile. From this point on you are set up to start using the Radioactivity module.

Newsletter

Articles on devportals, DX and API docs, event recaps, webinars, and more. Sign up to be up to date with the latest trends and best practices.

 

Subscribe