This is something we’ve had kicking about at Nine Four for a while and I’ve not yet got around to putting it up on GitHub so thought I’d drop a copy here for a couple of people that have shown interest. It basically keeps a record of a visitors recently viewed entries using their session ID.
Implementation is pretty basic, include the following on any page where you want to track entries to the recently viewed list:
{exp:recently_viewed:add_entry weblog="weblog_short_name" entry_id="{entry_id}"}You could also pull the entry_id from a segment in the URL to negate the need to place this in between the weblog:entries tag. Then use the following to spit out details of the entries they have recently viewed:
{exp:weblog:entries weblog="weblog_short_name" parse="inward" fixed_order="{exp:recently_viewed:get_entries weblog='properties' distinct='off'}"}{title}{/exp:weblog:entries}Download here: http://ninefour.co.uk/labs/recently-viewed/
That’s it! Enjoy! 😊
@Euan Make sure you upload the language file to the language directory in system.
I can’t seem to get this to work - I have this in my view template near the top
{exp:recentlyviewed:add_entry weblog="adventure" entry_id="{entry_id}"}and this in my sidebar
{exp:weblog:entries weblog="adventure" parse="inward" fixed_order="{exp:recentlyviewed:get_entries weblog='adventure' distinct='off'}"}{title}{/exp:weblog:entries}But it’s not returning anything - any ideas?
I was having problems showing recently viewed results until I remembered that I needed to include extra bits into the weblog parameters, so in my case it looks like:
{exp:weblog:entries weblog="courses" status="open|adult" show_future_entries="yes" parse="inward" fixed_order="{exp:recentlyviewed:get_entries weblog='courses' distinct='off'}"}
{title}
{/exp:weblog:entries}Is there some means of limiting how long the session data is stored? I looked at the database to see what was stored and there were a lot of records. So I’m concerned that the volume of data could get enormous.
I am trying it on an outdoor activity booking site where it shows visitors which individual activities they have viewed so far.
Hi all, I’ve made some adjustments to this module over the weekend to prevent against data bloat! You can grab the revised version here (http://ninefour.co.uk/labs/recently-viewed/). I’ve adjusted the module file names so you’ll have to uninstall the previous version and then install this new version for the changes to take effect. The tags have also been adjusted slightly to reflect this and the docs have been updated to take account of this. 😊
Basically the module now limits the number of entry views that it tracks for any given user to 5 by default, however you can tweak this setting in the mod.recently_viewed.php file yourself to any figure. This will be added as a control panel setting in a future release.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.