herr rilke Posted September 9, 2023 Share Posted September 9, 2023 Hello all, I am thinking about the following requirement: there are documents (pages) and users. the user should now be able to mark a document as "read" by pressing a button. when he then calls up the document again, he finds a "read" marking - so he knows that he has done everything here. do i now create a new subpage via API, which only has the fields "pageID" and "userID" for that? and would that be an extra query on each page load to see if the combination of userID and pageID already exists to display a marker? Link to comment Share on other sites More sharing options...
bernhard Posted September 9, 2023 Share Posted September 9, 2023 1 hour ago, herr rilke said: there are documents (pages) and users. How many documents? How many users? If you only have a limited number then a simple page reference field would be all you need. Just add a field "readby" to your documents page and add users to that field via API. You just need to make sure that you don't have too many pages stored in the page reference field. So if you have many documents but just a few users add the page field to documents. If you have many users but just a few documents add the page field to the user template and add read documents to the field. If you have many documents and many users go with the custom table solution that I showed here: 3 Link to comment Share on other sites More sharing options...
herr rilke Posted September 10, 2023 Author Share Posted September 10, 2023 thank you, bernhard, that was very enlightening! I think the third approach (with an own table) is the most suitable for me. i also understood better how i can implement such an approach. 1 Link to comment Share on other sites More sharing options...
MarkE Posted September 10, 2023 Share Posted September 10, 2023 On 9/9/2023 at 9:31 AM, bernhard said: So if you have many documents but just a few users add the page field to documents. If you have many users but just a few documents add the page field to the user template and add read documents to the field. Alternatively do both and use @Robin S’s ConnectPageFields module. Then you can access the link in either direction without a foreach loop. Link to comment Share on other sites More sharing options...
herr rilke Posted September 11, 2023 Author Share Posted September 11, 2023 wunderful! thanks for the hint! that does the job exactly as otherwise done with SQL Link to comment Share on other sites More sharing options...
bernhard Posted September 11, 2023 Share Posted September 11, 2023 Note that this does NOT help with scalability issues. Quite the contrary. It will keep two page fields in sync but it will store the data twice. So if you have lots of pages, you'll make your issues even worse. Link to comment Share on other sites More sharing options...
herr rilke Posted September 11, 2023 Author Share Posted September 11, 2023 ok, good to know! thanks for sharing! there are approximatley 100 documents and > 200 users. so i think i'm heading to the SQL solution. Link to comment Share on other sites More sharing options...
bernhard Posted September 11, 2023 Share Posted September 11, 2023 If you compare both approaches it would be interesting if you share your findings. https://processwire.com/blog/posts/debugging-tools-built-in/ (Debug::timer) might be helpful and memory usage could also be interesting. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now