0

I'm looking to re-invent the wheel to some extent and am inquiring how best to go about it.

I'd like to replicate the read/unread functionality of forum software (Not EE but IPB). Thats to say lets say we have 5 entries and I've only read/landed on entry#1, the other 4 would somehow be marked as "unread".

Using entries/comments instead of forums because I want the entire site in my control.

My thinking would be soon as an entry is posted, its ID is recorded in every members "profile" (or a new table mapped to members ID). If a comment is posted, it to is recorded to all members profile (or new table mapped to members ID) not the comment ID but the entry_id it belongs to.

So entry 4-5 could be recorded like a JSON/array [entry_id2], [entry_id3], [entry_id4], [entry_id5] - don't need comment ID as the comments live on the same page as the entry.

Soon as a member lands on a page with an entry_id listed in their profile (or table) it would delete the corresponding ID - making it 'read'.

On a "view latest entries" summary page, we could then mark item#1 as read (because its not in the users list of unread ID's) and we could then mark the remaining 4 as unread (because it is in their list of unread ID's).

If you made it this far - great. Now, can I source an approach on what I'll need to know to accomplish this. I know I'll need to do create something module/accessory or plugin but NFI on just how.

As a note, there will be about 30-50 members, with about 5-20 posts per day - so not huge but could be – so query/server load will be a factor.

  • Just curious, why would you choose to record each entry's ID and then remove it when it's viewed, rather than simply recording the IDs only when they are viewed. That way when a new entry or comment is published you don't have to update all those tables with a new ID. Nothing needs to change unless that user has viewed the entry or comment. – Benek Lisefski Jun 23 '14 at 7:16
  • Because if I've viewed entry_id1 (it would record 'entry_id1') and thereafter - someone has posted a comment, I need to tell the user that the entry has been updated. I'm trying to wrap my head around all this so happy to have any thoughts at this stage. – stuartmcd69 Jun 23 '14 at 10:51
1

Why not to used :visited pseudo selectors and fragment identifiers on the links to comments?

On the list of entries:

{exp:channel:entries channel="news" limit="10"}
    [...]
    <a href="{title_permalink="channel/archives"}#{recent_comment_date format="%Y-%m-%d"}">link</a>
    [...]
{/exp:channel:entries}

On the comments:

{exp:comment:entries sort="asc" limit="20"}
    on <time id="{comment_date format="%Y-%m-%d"}">{comment_date format="%Y %m %d"}</time>
    {comment}
{/exp:comment:entries}

On your CSS, you can use something like:

a:link {
    font-weight: bold;
}
a:visited {
    font-weight: normal;
}

I know this can't survive to a change of browser, but... It's simple and easy. And can be used together with a server side solution.

Or together with a JavaScript solution! Save on localStorage which entries was read. You can suppose, on your CSS, all entries as unread until the JS be loaded and mark the right ones.

| improve this answer | |
  • Familiar with the css, looking more to a robust, server-side solution, thx. – stuartmcd69 Jun 23 '14 at 22:26
  • @stuartmcd69, you can, of course, code a custom module and sync the list of topics on localStorage with the database, via AJAX or JSON. Since isn't vital information to the user, better to load them by this way, than make the performance suffer. If you load this info by JS, you can even cache the same page for several users. – Robson Sobral Jun 23 '14 at 22:49
  • Hmmm, still struggling to visualise how I can record what entries are unread or if an entry contains unread comments and record that to all users. – stuartmcd69 Jun 24 '14 at 1:17
  • @stuartmcd69, on window.onload of each entry pages, run a JS and record the entry_id or url_title of the entry and the timestamp of the access to it. On the list of entries page, run a different JS that loads an JSON and look for link to the every entry and compared the date of last access to the date of last comment. – Robson Sobral Jun 24 '14 at 1:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.