Open Tom-Pich opened 1 month ago
Added hooks in init()
$this->addHookAfter('AdminThemeUikit::renderBreadcrumbs', $this, "hookAfterRenderBreadcrumbs");
$this->addHookAfter('Process::breadcrumb', $this, "hookAfterBreadcrumbs"); // for basic UI
Hook callback for UiKit
public function hookAfterRenderBreadcrumbs(HookEvent $event)
{
foreach ($this->restricted_roles as $r) {
if ($this->user->hasRole($r) && $this->hide_breadcrumbs) {
$event->return = false;
}
}
}
Hook callback for Default theme
public function hookAfterBreadcrumbs(HookEvent $event)
{
foreach ($this->restricted_roles as $r) {
if ($this->user->hasRole($r) && $this->hide_breadcrumbs) {
$process = $event->object;
$process->wire('breadcrumbs')->removeAll();
}
}
}
@Tom-Pich Hello Thomas. Not to worry, this is pretty simple, I'll take care of this one.
Great! Thank Steve.
Le dim. 12 mai 2024 à 22:26, Steve @.***> a écrit :
@Tom-Pich https://github.com/Tom-Pich Hello Thomas. Not to worry, this is pretty simple, I'll take care of this one.
— Reply to this email directly, view it on GitHub https://github.com/netcarver/PW-AdminRestrictPageTree/issues/3#issuecomment-2106365335, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3IBCWNR5WU426R35ZODJJLZB7F7BAVCNFSM6AAAAABHS5QAJ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWGM3DKMZTGU . You are receiving this because you were mentioned.Message ID: @.***>
@Tom-Pich Please could you try out the ng branch and let me know if that works for you.
@netcarver Sorry for the dumb question, mate, but I only used GitHub for personal use until now, never on a team dev. So what do you expect from me? 😅
Hi Thomas,
If you could make a copy of your existing AdminRestrictPageTree.module file somewhere, then follow the link I posted above. Now, copy the new version of that file and overwrite your existing installation of AdminRestrictPageTree.module file with that. Refresh your modules in the admin and navigate to the configuration page and adjust the new settings as needed, then check it still works the way you are expecting when visiting the page tree/breadcrumbs.
Please let me know if anything breaks etc.
Thank you.
Done. Didn’t notice any bug, everything works fine. Thank you.
Clicking on a breadcrumb link while editing a page may result in a confusing experience (→ display a page with a title saying "Login" and a button "Edit Profile"). So in some case, some developers may choose to hide the breadcrumb. I added two hooks after
AdminThemeUikit::renderBreadcrumbs
andProcess::breadcrumb
to hide the breadcrumb, and on checkbox on module setting to activate the option.Please note that, when adding a page in default admin theme, the breadcrumb still shows. I couldn’t figure how to prevent it’s rendering in this case.
PS: do I need to create a fork and make a PR on this fork?