This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
I often have the need to get the "topmost parent" of the current page like this:
home -> home
photography -> photography
photography/animals -> photography
Current implementation in a page method:
Kirby::plugin('my/plugin', [
'pageMethods' => [
'topmostParent' => function(): ?Page {
if (isset($this->topmostParent)) {
return $this->topmostParent;
}
// get the topmost parent
$topmostParent = $this->parents()->last();
// if there is no parent, the current page is already it
if ($topmostParent === null) {
$topmostParent = $this;
}
return $this->topmostParent = $topmostParent;
}
]
]);
I think this could be a good fit for a core page method.
I often have the need to get the "topmost parent" of the current page like this:
Current implementation in a page method:
I think this could be a good fit for a core page method.