I have set up a hook.
That works so far good. But when i try to click on the 3 point or try to adding a new post.
It shows “Dropdown is empty” - It’s cause im restricting the panel that user only can access there own post - and all other pages redirect to the site.yml
I just tried it with /dropdowns/‘.$page->panel()->url(true).’?view=list&delete=true&sort=false’ but that does not work.
Maybe some has a hint for me?
'hooks' => [
'panel.route:before' => function($route, $path, $method) {
$allowed = [];
$user = kirby()->user();
if(!$user || !$path) return;
$currentRole = $user->role()->name();
if($currentRole == 'organizer') {
$userPost = site()->find('company/products')->childrenAndDrafts()->filterBy('author', '- '.$user );
foreach($userPost as $page) {
$allowed[] = [
'title' => $page->title()->value(),
'path' => $page->panel()->url(true)
];
$allowed[] = [
'title' => $page->title()->value().'_dropdown',
// Just a test - not working
'path' => '/dropdowns/'.$page->panel()->url(true).'?view=list&delete=true&sort=false'
];
};
$allowed[] = [
'title' => 'Site',
'path' => '/site'
];
$allowed[] = [
'title' => 'Account',
'path' => '/account'
];
$allowed[] = [
'title' => 'Logout',
'path' => '/logout'
];
$allowedPaths = A::pluck($allowed, 'path');
$currentPath = '/'. $path;
if(!in_array($currentPath, $allowedPaths)) {
Panel::go($allowedPaths[0]);
}
}
}
]