cjrobe Posted June 2, 2018 Share Posted June 2, 2018 Hi all. I was wondering if there was a way to automatically set a variable inside a referenced page when you create a page that references it. For example, there might be one template for skyscrapers and another for photos. The database of all the skyscrapers in a city would already be created, and users could add photos with a field that references which skyscraper they photographed. Of course when you are viewing the skyscraper page, it is easy to have it pull the pages that reference it and display said photographs. But I would like for skyscrapers to have two boolean variables - interior photos and exterior photos. When a photo page is created that references a skyscraper and the select field is chosen as "interior", the boolean on the skyscraper page for "interior photos" is automatically updated to true. And of course the same for when a page is created where the select field is chosen as "exterior", the boolean for exterior photos" is updated to true. That way, on the front end, I can create an interface where a user can choose to either view all skyscrapers, only those with photos, only those with interior photos, or only those with exterior photos. Or if there an efficient way to avoid the booleans entirely and run page finds to show the skyscrapers as mentioned above, that might be even better. Thanks for your time. Link to comment Share on other sites More sharing options...
Robin S Posted June 2, 2018 Share Posted June 2, 2018 I think the Connect Page Fields module will be suitable for this. You would create two new Page Reference fields for your Skyscraper template: interior_photos and exterior_photos. The visibility of these fields could be set to hidden if you don't want to see them in Page Edit. Then you would connect those fields to the corresponding fields on the Photo template. In terms of matching skyscrapers with or without interior or exterior photos you would then match against the count of the Page Reference field rather than a boolean. 4 1 Link to comment Share on other sites More sharing options...
cjrobe Posted June 3, 2018 Author Share Posted June 3, 2018 Wow, that works incredibly well for this usage! You are very creative, I never would have thought to use a similar plugin for such usage. It even works flawlessly with a multi chosen page reference field. You can have multiple pages of exterior photos and the each page will successfully pop into the field. It even solves the problem of what happens when photos are removed - they are automatically removed from this select field, so if all photos of a skyscraper are removed, it successfully has a photo count of zero. Bravo. 4 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