Nvim Posted October 8, 2018 Share Posted October 8, 2018 Everything is a page in PW so how do I convert this relational data into pages in PW? TABLE: STUDENTS | ID | Name | Age | ---------------------------------- | 00 | Heather | 10 | ---------------------------------- | 01 | Rachel | 10 | ---------------------------------- | 02 | Jimmy | 11 | ---------------------------------- | 03 | Lola | 10 | ---------------------------------- TABLE: PETS | ID | Type | Pet Name | --------------------------------- | 00 | Dog | Rex | --------------------------------- | 01 | Cat | Thomas | --------------------------------- | 02 | Cat | Fluff | --------------------------------- | 03 | Dog | Kimba | --------------------------------- Table: PETS-STUDENTS | Pet ID | Owner ID | --------------------- | 00 | 00 | --------------------- | 01 | 00 | --------------------- | 02 | 01 | --------------------- | 03 | 02 | --------------------- | 01 | 03 | --------------------- Link to comment Share on other sites More sharing options...
BitPoet Posted October 8, 2018 Share Posted October 8, 2018 Each students and pets table is its own template, each row a page. For a limited set of repeating information like your pet type, a page reference field is most often the way to go. The "pet type" pages can live anywhere in the page tree and can optionally have a PHP template to list all pets of that type. The pets-students relationship can be defined as a page reference field linking from the pet to the student, from the student to the pet or, if you plan to implement complex selectors later on, using the Connect Page Fields module also both ways. The page reference fields can be limited to only show pages with a certain template (student, pet, pet type). Names and age should be regular (text, integer) fields. You could re-use the mandatory title field for the student and pet name and just change the label for it in the individual template's settings. I'd probably also create a "pets" and "students" template (plural) under which the individual entries live in the backend to keep things sorted and allow outputting lists. Home (or another common parent page) Students Heather Rachel ... Pets Rex Thomas ... Pet Type Dog Cat ... 8 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