Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
15.8k views
in Plugins by

Hi all!

Is is possible to implement a plugin that shows up if a question has been read or has a new activity, similar to forums. For example, in the question list you would see something like the image on the right.

I guess this need to keep the vast information of which user viewed which question/answer/comment. Especially it would help if there flows too many questions and answers per day, just by throwing a glance at the list.

Maybe you become the hero to do this! :)

1 Answer

+1 vote
by
So this is exactly what the All activity section displays but you also want to consider as an event that updates the question the fact that it is read? This list would be EXTREMELY dynamic and would become almost useless if "there flows too many questions" because that would mean also many users browsing questions and constantly changing the order of the list. I would stick to the All Activity section as it is today: exactly the same but does not refresh the question update timestamp when it is viewed.

Having stated my point of view, and now answering your question: yes, it is possible and not complex. Best approach would be to create a seprate table with question ids and last view dates. Then each time a question gets a view then you add its id to the table. Handle removal and updates properly and you'll be done. Obviously, use a page plugin to display the questions in descending date order from the table.
by
But isn't it true that the table should as well as include the user ids?

Because I didn't mean that the list needs update but rather the list will be the same list just providing addtionally the information to the logged-in user that if the question on the list is read by him/her or not. That's why I guess the table should include question id, user id, view-date (or a boolean?).

So, the plugin should only check whether THAT question has been viewed by THIS user or not.

By the way, the activity page becomes inpractical for a question that is not read many times ago. For example, if I have missed a question asked 3 months ago, it should always be in the list of "unread questions".
by
Well, I forgot to say that it is also another handicap in the activity page that you might miss to see a post editted many activities ago because of the flow.
by
"the list will be the same list just providing additionally the information to the logged-in user that if the question on the list is read by him/her or not"  => Oh, so you want to keep track of the questions a user has read? I gave you the solution to "bumping" questions after being read... that's a different approach, so forget about the whole answer :)

"But isn't it true that the table should as well as include the user ids?"  => YES. You will have to create a table with user ids and question ids (post ids). Each time a user reads a question it gets added to the table. Each time a user is displayed a question in a question list then you have to check if the question id for the currently logged in user id is in the table and, if it is, then apply a style to the view count box. That should be enough and should be pretty easy to do for you (based on your understanding of database modelling :)
by
Thank you for your answer and comments! I hope I could implement such a plug-in, and of course share it here.
...