Jump to content

Trash for all: does it work?


theo
 Share

Recommended Posts

Now I see. It does not show, because I have moved the 404 page under "admin", as suggested by kongondo.

If I reparent the 404 Page under "home" again the trashcan is showing for my "editor".

Strange. Would you say it's a bug? Shall I report it?

Thank you.

  • Like 2
Link to comment
Share on other sites

It's strange that the location of the 404 page would affect the trash.

An alternative way to hide the 404 page instead of moving it is to hook Page::listable()

$wire->addHookAfter('Page::listable', function(HookEvent $event) {
	if($this->wire('user')->isSuperuser()) return;
	$page = $event->object;
	if($page->id === 27) $event->return = false;
});

I actually like to go a bit further than this, and say that if a page is in the top level and is hidden and the user doesn't have edit access for the page then it is of no concern to them and they don't need to see it in Page List:

$wire->addHookAfter('Page::listable', function(HookEvent $event) {
	if($this->wire('user')->isSuperuser()) return;
	$page = $event->object;
	if($page->parent->id === 1 && $page->isHidden && !$page->editable) $event->return = false;
});

In my case I give the 404 page a dedicated template that non-superusers do not have edit access for, and so it is hidden in Page List.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

But still, I'm not happy.

I've closed the bug report, but afterwards I have found out, that it is not only a problem if I move 404 under admin, but also, if I hide it like this.

$wire->addHookAfter('Page::listable', function(HookEvent $event) {
	if($this->wire('user')->isSuperuser()) return;
	$page = $event->object;
	if($page->id === 27) $event->return = false;
});

 

So there seems to be no way the let the "editor" see the trashcan AND not see the 404 page in the backend.

What do you think? Shall I reopen the bug report?

Thank you!

  • Like 1
Link to comment
Share on other sites

5 hours ago, theo said:

not see the 404 page in the backend.

One easy option to hide it is to install @tpr's AdminOnSteroids module, which – among others – adds the CSS class role-superuser to <body> so you can also use its Admin CSS feature:

body:not(.role-superuser) .PageListID27 { display: none; }

 

Edited by szabesz
typo
  • Like 2
Link to comment
Share on other sites

5 hours ago, theo said:

What do you think? Shall I reopen the bug report?

I think so - even if the CSS approach works, it' really strange to me that the 404 page affects trash for all - sounds like there is still a bug there somewhere.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...