We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Module: Recently Viewed Entries

Development and Programming

nathanpitman's avatar
nathanpitman
531 posts
16 years ago
nathanpitman's avatar nathanpitman

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! 😊

       
Jim Pannell's avatar
Jim Pannell
187 posts
16 years ago
Jim Pannell's avatar Jim Pannell

Taking it for a spin now Nathan - many, many thanks for being so responsive!

UPDATE: I’m very pleased to report that this works a treat and is EXACTLY what I was after! If you don’t ask, you don’t get 😊

Many thanks Nathan. I definitely owe you one.

       
nathanpitman's avatar
nathanpitman
531 posts
16 years ago
nathanpitman's avatar nathanpitman

No worries, let me know of any issues or ideas for improvements. 😊

       
NKT com's avatar
NKT com
124 posts
16 years ago
NKT com's avatar NKT com

Great. Have a project coming up to try this on. Thanks!

       
Sean C. Smith's avatar
Sean C. Smith
3,818 posts
16 years ago
Sean C. Smith's avatar Sean C. Smith

Will likely use this on my current project.

       
Euan's avatar
Euan
214 posts
16 years ago
Euan's avatar Euan

Uploaded the files, went to the Modules tab and got…

Error Unable to load the following language file: /lang.recentlyviewed.php
       
gamma911's avatar
gamma911
51 posts
16 years ago
gamma911's avatar gamma911

@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?

       
nathanpitman's avatar
nathanpitman
531 posts
16 years ago
nathanpitman's avatar nathanpitman

Could you post the complete template content perhaps? It may be that the exp:recentlyviewed:add_entry tag is not within a weblog:entries tag pair…

       
Paul Frost (orienteer)'s avatar
Paul Frost (orienteer)
389 posts
16 years ago
Paul Frost (orienteer)'s avatar Paul Frost (orienteer)

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}
       
leeaston's avatar
leeaston
634 posts
16 years ago
leeaston's avatar leeaston

Any chance of an EE2 version?

All the best Lee

       
nathanpitman's avatar
nathanpitman
531 posts
16 years ago
nathanpitman's avatar nathanpitman

Possibly, I’ve not tried migrating any of our add ons yet but this would be a nice simple one to start with. 😊

       
leeaston's avatar
leeaston
634 posts
16 years ago
leeaston's avatar leeaston

Many thanks for getting back to me, I’ll watch out for it just in case it happens on day.

       
Paul Frost (orienteer)'s avatar
Paul Frost (orienteer)
389 posts
16 years ago
Paul Frost (orienteer)'s avatar Paul Frost (orienteer)

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.

       
nathanpitman's avatar
nathanpitman
531 posts
16 years ago
nathanpitman's avatar nathanpitman

Hi Paul, not at present no but it’s certainly something we need to add! I’ll post back here as soon as it’s done!

       
nathanpitman's avatar
nathanpitman
531 posts
16 years ago
nathanpitman's avatar nathanpitman

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.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.