Do all child pages have a filled in venue field? If not, then you won’t get a page object and consequently, calling the method on a non existing page will result in the error you get.
To avoid that, you would have to wrap the code in an if statement:
<?php
foreach($page->children() as $child):
if($child->venue()->isNotEmpty()):
$venue = $child->venue();
$venuePage = page($venue);
e($venuePage, $venuePage->contact(), '');
endif;
endforeach;
?>
1 Like
Thank you very much for all your help Tex, its working now.
Hi @texnixe, would it be possible to extend this and have a sub field per option? Something like…
venue:
label: Venue
type: select
options: query
query:
page: venue
fetch: children
value: '{{uri}}'
text: '{{title}}: {{number}}'
ext_url:
type: url
label: Enter URL
No, that’s not possible. Why would you want to have this possibility? Shouldn’t the URL be part of the venue page?
1 Like