Welcome Guest, Not a member yet? Register   Sign In
How to identify 'unviewed' or 'new' resources?
#1

(This post was last modified: 05-14-2016, 08:37 PM by PaulD.)

Suppose I have a resource, it could be a post like a forum, or a comment, or a note, or a file etc. And suppose I have a multiple users that can access those resources. When a user logs in, how do I show them or highlight new resources they have not yet viewed?

These are ways I have thought about doing it.

1. Having A Viewed Table.
I could have a table that records if a user has viewed the resource, but this seems daft to me, because I would need an entry in the table for every user and every resource. This would be an exponentially expanding table as it would be Resources x Users big.

2. Comparing to last login datetime
I could show or highlight all the items created since their last login. But you cannot record the logout time, as users might just shut down the browser. So this method, if someone logs in at say 3pm, and logs out at 5pm, they will see all the things they viewed between those times as new items. Also those items will remain permanently as not viewed, as last login time will not change.
Another big problem with comparing creation date to last login date is also that the user might not view a resource on their current visit, but if they have not viewed it, I want to highlight that fact, even on the next visit.

So method 2 does not really work, but method 1 seems to have to store an awful lot of data to achieve the task.

So is there a method that I am overlooking? At the moment I think I am going to have to go with a viewed table, so whenever you view an item, an entry gets written into the table. I just think this is going to be really clunky though unless there is a more efficient way of doing it.

Any ideas or suggestions or insights into how other people have achieved this would be gratefully received, or even just confirmation that a viewed table is the way to go.

Thanks in advance

Paul.
Reply
#2

This might help

http://stackoverflow.com/questions/10952...s-per-user
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#3

(05-14-2016, 09:47 PM)albertleao Wrote: This might help

http://stackoverflow.com/questions/10952...s-per-user

Thanks for that. I thought about checking how some forums do it but I thought it would take ages and it might be a bit misleading, as I am not making a forum. But I suppose it has to be a table for viewed items, there is just no other way of doing it.

I suspect I am conflating two issues, 'new items' and 'unread items'. Now I know new items are unread, but when you next log in, they may not be new, but may still be unread.

That means, I need to do both a creation_date/last_login_date comparison and a lookup on the viewed table Sad

Oh well. Was hoping there was some really clever way of doing it I hadn't thought of. If only CI5 was here, I am sure there was some feature in there that would have done it automatically. $this->load->library(magic_history);

Thanks again,

Paul.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB