i 'm writing a hook for repeater labels
$this->addHookAfter('InputfieldRepeater::renderRepeaterLabel', function(HookEvent $event) {
// Get the object the event occurred on, if needed
$InputfieldRepeater = $event->object;
// An 'after' hook can retrieve and/or modify the return value
$return = $event->return;
// Get values of arguments sent to hook (if needed)
$label = $event->arguments(0);
$cnt = $event->arguments(1);
$page = $event->arguments(2);
// Your code here, perhaps modifying the return value
// just a simple test:
$return = "LABEL " . $page->getForPage()->template();
// Populate back return value, if you have modified it
$event->return = $return;
});
this hook function works (e.g. if i return a constant string) as long as i don't use '->getForPage()'
the error message is '...... Page::getForPage does not exist or is not callable in this context'
The hook is in 'ready.php'. it seems the events setting especially "$page" property is not complete within context?
i want to set the repeater labels only if the parent of pages has a special template.
(i m using Version 3.0.210)
What i am doing wrong? Who can help?
Thank You