FlorianA

How to implement Doodle on PW?

Recommended Posts

For my website, I need to implement a feature similar to Doodle: A table with a list of events as columns and a list of users as rows. The inner table cells show for each PW user at which events he can participate (btw. this "participate" need not to be simply a boolean flag, but can also be a selection (yes/no/maybe), a number or a string, along with a comment).

In a classical relational database, this would be easy to implement as a many-to-many relation. With PW, I couldn't find a really satisfying solution so far.

My current approach is to insert a page for each "participate" cell whose template has references to both a user and an event page. However, I think it's not really efficient to have a whole page for each cell.

  • The pages will never be needed as an isolated unit but only as parts of other pages. There may be many thousands of these pages which would mess up the page tree in the backend.
  • Each page has several additional fields in the underlying database which will never be needed but increase considerably the needed storage space: name, publish date etc.

Maybe this implementation will nevertheless run smoothly in practice, but it simply feels quite cumbersome compared to the plain MySQL implementation of my previous website, so my hope is that there's a smarter PW solution for this. Can anybody give me some hints?

Share this post


Link to post
Share on other sites

Would be a task for

You can save the data in that field and create one page per doodle/poll so you have a clean pagetree.

---doodles
-----doodle1 (Matrix field with users and 3 columns for your entries, maybe some additional fields for title, descriptions and everything else)
-----doodle2
...

regards mr-fan

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot for showing me. Looks really nice on first glance, but unfortunately it doesn't meet my requirements completely, since the Matrix can only contain one string in each cell, but in order to port my current solution to PW, I also need for each cell (at least)

  • a second string which holds an optional comment on just that single value
  • a change date for the cell.
  • A more specific type for the actual input value (boolean, number, selection), along with an appropriate backend editor would also be nice, but not essential, since the values could be stored as strings as well, and for editing I'll probably need a more user-friendly front-end solution anyway.

After all, a page for each cell might be a not so bad solution. Maybe I can user something like the URL Shortener module in order to keep the names short at least ...?

Share this post


Link to post
Share on other sites

Url can stay clean...

---doodles
-----doodle1 (visible template that collects the entries for the doodle/poll ->url)
--------entry1 (hidden page or no template - just a datacontainer with all fields you need)
--------entry2 ....

no changes everyone can reach a doddle via one link your-site.com/doddles/doddle1/   where you can show the existing entries and put a form for new ones...

regards mr-fan

  • Like 1

Share this post


Link to post
Share on other sites
On 19.6.2017 at 8:11 AM, mr-fan said:

Url can stay clean...

---doodles
-----doodle1 (visible template that collects the entries for the doodle/poll ->url)
--------entry1 (hidden page or no template - just a datacontainer with all fields you need)

No template? But a page without template isn't possible, is it? Currently I'm setting the 'entry' page's name to it's ID in order to avoid generated names (timestamps) which seem to be longer.

Share this post


Link to post
Share on other sites

https://processwire.com/docs/tutorials/but-what-if-i-dont-know-how-to-code/part-1-pages-templates-fields-files/page2

Quote

When you create a new page you have to select a template. And that template has all the information that the page needs to know about what fields it should have and some other useful bits which we will worry about much later.

Now, I am going to confuse you in a minute and tell you that ProcessWire has templates and template files, and though they are related to each other, they are not the same thing. So when you use the term template, you have to be certain that you are talking about the right thing.

you could use a template without a file...just as kind of datacontainer....and collect/view/edit this data in a other template/file like /doodle1/ shows all data from its childpages/entries...

templates without files are not visible in the frontend, but you could use the API to get them where you wanna show them...;)

  • Like 1

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.