Walkthrough for most viewed nodes
Introduction
This is a walkthrough for the most viewed nodes list, consisting of defining a profile in Radioactivity and a view for it. This is intended for the 6.x version, but the 5.x version of the module works similarly. All the required steps are presented with bold font in ordered lists, so the impatient can skip the rest.
Required modules
- Radioactivity core and Node Radioactivity. Download the Radioactivity package here
- Views and Views UI from the Views package
The walkthrough
The prequisites
- Make sure that the required modules are enabled.
- Make sure that your cron is running regularly. The decay calculations are performed in cron runs. Hourly crons are probably the minimum. For better accuracy, run cron every 10 minutes or so or even once per minute.
Creating the radioactivity profile
Radioactivity settings are stored into profiles. The profiles are independent of each other, enabling you to create different settings to different use cases. For example, you could have separate profiles for most voted or most commented nodes, but here we're going to creat a profile for most viewed nodes. To do that:
- Go to Administer › Site configuration › Radioactivity and select 'New Profile' tab
- Choose a short label, e.g. 'most viewed nodes today'. This label is used to distinguish different profiles in UI.
Optionally, you can also set
- Half-life period — Half-life period defines the rate of decay so that the energy of the node is halved after every half-life period. Use shorter periods for quicker list changes, but don't go below the cron interval.
- Set the cut-off energy. Nodes that have less than this amount of energy (absolute comparison) will have their energy information deleted in the next cron run. This is used to control the size of the information stored to database for this profile. The default is probably just fine unless you have a big and busy site.
- Fine-tune energy settings — The default is to give 1 point of energy per node view (see section energy settings for node). You can also define node type specific amount of energy for viewing. This can be used to favour or block out certain types of nodes. The exact set of settings available depends on what plugin modules you have enabled.
Finally,
- Remember to save the profile
To verify your settings, you can now navigate to Administer > Site configuration > Radioactivity and choose 'Decay profiles' tab
Creating the view
Now that we have a radioactivity decay profile, we create a view to sort nodes by radioactive energy.
- Go to Administer › Site building › Views and select 'Add' tab
- Give view a name, e.g., most_viewed_today
- Make sure that view type is 'Node'
- Click 'Next'
Now that we've defined the view basics, it's time to add some fields, sorts and optionally some filters.
- Add some fields. For debugging purposes, try 'Node: Nid', 'Node: Title' and 'Radioactivity (most viewed nodes today): Node energy'. Radioactivity provides a field for every profile (profile label in parenthesis) as node can have different energy values in different decay profiles
- Add sort criteria 'Radioactivity (most viewed nodes today): Node energy' and choose 'Descending' option for sort order..
- Optionally you can also choose between left join or inner join type. With left join the view considers all nodes, even if some nodes don't have energy information at all. Inner join type discards all nodes without energy information. Inner join should be somewhat faster if you've got lots of nodes in your site.
- Preview the view. There should be some nodes listed in decreasing energy order. If all node energies are blank, you need to visit some node pages (i.e. /node/NNNN) to give the nodes some initial energy.
- Optionally, fine-tune your view layout. Note that you don't actually need the node energy field. Remember to save the view and you've completed this walkthrough.
