Ok I've simplified things as suggested. I've added two repeater (widget) items to my page. Tried some more code and still have several problems. First one is that this code only retrieves the first item. My count comes back as 1 not 2.
$group = $page->widget_group;
echo 'There are [ '.count($group).' ] widgets assigned<hr>';
I also have problems with getting the right data back inside my loop. Here is that code.
foreach ($group as $item) {
echo 'Widget Title: '.$item->widget_group_name->title.'<br>'; // OK
echo 'Widget block content: '.$item->widget_group_name->block.'<br>'; // OK
echo 'Widget access: '.$item->on_device.'<br>'; // WRONG DATA RETURNED
echo 'Placement position: '.$item->widget_group_position.'<hr>'; // WRONG DATA RETURNED
}
Here is the output:
Widget Title: My First Block Widget block content: This is my first widget block content Widget access: 8 Placement position: left
Widget Title and Widget block content are correct.
Widget access returns a number 8, that input in the repeater is a select list that I created and the value that is currently selected should be 16.
Placement position is a text input in the repeater with a current value of 'sidebar', as you can see it shows 'left'.
No idea where it is getting either of these values from.
Having a hard time getting my head around how PW does things which is frustrating but I can see the great potential that it has.