I currently have a plugin that calls a custom hook from a site method. Inside that hook was a $pages->filterBy() call that runs a custom page method from another plugin.
Inside that page method is a call to another hook. Kirby prevents that hook from running more than once.
To get around that I’ve found this solution works when called from within the original hook:
"plugin.A.hook" => function () {
$pages = site()->index(); // For example.
# $pages->filterBy("myCustomMethod", true) // This only works on the first page.
foreach ($pages as $page) {
$events = kirby()->events;
call_user_func(
\Closure::bind(
function () use ($events) {
unset($events->processed["plugin.B.hook"]);
}, null, $events
)
);
// This method calls "plugin.B.hook" and is contained in another plugin.
if ($page->myCustomMethod()) {
// Do something special.
}
}
return $pages;
}
I hope I’ve explained that well enough. Whilst this works, I’m just curious is there’s a better way I haven’t though of.