I have a fairly simple structure field, with a pages field as one column (with multiple: false set) and a date field as another. So only one page can be selected per entry. This is the blueprint:
found:
label: Found statues
type: structure
empty: No statues found yet
fields:
statue:
type: pages
multiple: false
label: Statue
image: false
query: site.index.filterBy('template','gingerbread')
scanned:
type: date
time:
time: true
display: HH:mm:ss
step:
unit: second
size: 1
label: Scanned
help: This is the date and time the entrant scanned the statue
display: DD/MM/YYYY
I also have a collection of pages.
I need to step through the collection of pages, and check each page to see if it appears in the pages in the structure, and if so to style it differently.
I am aware of the has() method, and am planning on using it like this:
<?php
foreach($collectionPages as $collectionPage):
if($structurePages->has($collectionPage):
// Different styling
else:
// Standard styling
endif;
endforeach;
?>
However I am not sure how to get a pages object out of the structure field to work with.
If you could offer any guidance that would be great.
Thanks for the quick reply and the pointer. I am focussing on the second method, as I am using a controller and it would be good to have it saved out as a variable.
But that is outputting an empty pages object (the user in question has 3 entries in the structure). When I remove the pages() I get an empty array, so something isn’t quite right.