Jump to content

unread status


Roberts R
 Share

Recommended Posts

I can't figure this out if it is possible to make in PW natively :^) .

How do you make unread posts/message/page for each user and make them marked as read for specific user when they view the page?

I guess idea would be to create db where you save user ids and page ids and do the checks that way. Maybe someone has done other approaches. 

Ideas or advises are welcome.

Link to comment
Share on other sites

Create a page field on the page's template that links (Parent of Selectable Pages) to the "users" parent page. That way you can populate this list with all the users that have read the page using the API when the page is viewed.

$page->of(false);
$page->viewed->add($user);
$page->save('viewed');
$page->of(true);

Then you can make use of that field to check to see if the current user is listed in the "viewed" field.

  • Like 2
Link to comment
Share on other sites

would you use page field as check box? So in a backend admin can see who has viewed page.

Depends on how many users you have - checkboxes or ASM select will be ok up to a point, but won't work well if you have hundreds/thousands of users.

  • Like 1
Link to comment
Share on other sites

I understand theoretical part of how to do but fail to make it work. 

page field that have parent set as "Users" already contain all users under it and how do check if it have (I assume $field->get($user)). Or I miss something.

EDIT: Ok it seems you can select for all users. With $item->viewed->add($user) you actually add them. As long as I don't touch viewed in backend - added ones are only ones who you get from $item->viewed->get($user)  call

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...