I recently had a requirement where I wanted to reuse a ProcessWire Page Reference field across pages and templates. I wanted the field in each case to list its children. Here's how I accomplished it (add this hook to your admin.php.
wire()->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
$page = $event->arguments('page');
// Don't run on admin as it causes an error when you try to access template override settings
if ($page->template->name != 'admin' && $event->object->hasField == 'dynamicPageReference') {
$event->return = $page->children('template=dynamic-page-reference-option'); // Do any $page work you like here
}
});
Tim Bennett is a freelance web designer from Leeds. He has a First Class Honours degree in Computing from
Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.