Marcel Stäheli Posted September 30, 2018 Posted September 30, 2018 I have a car template that contains dozens of fields. The collection of cars is growing and now I have different configurations for the same car type. To save work and time I created a "general" car page for every car where I enter data that fits every car configuration. Both the general car page and the car configuration have the same template and identical fields. The idea is that for every car I start with the general page and if a field is empty I get the data from the corresponding car configuration field. Is there a way to loop through every field of a page? I don't want to write a compare function for every single field.
BitPoet Posted September 30, 2018 Posted September 30, 2018 You can iterate over the fieldgroup property of the page's template. Edit: perhaps starting with a copy of the general page and emptying/setting a few fields that need to be different might also be an option. 2
Marcel Stäheli Posted September 30, 2018 Author Posted September 30, 2018 Thanks using the term fieldgroup I also found it in the new doc http://processwire.com/api/ref/page/ under the advanced section. I didn't check that part, my bad.
adrian Posted September 30, 2018 Posted September 30, 2018 Surely this is the simplest approach, or maybe I am misunderstanding? foreach($page->fields as $f) { echo $page->$f; } 2
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