Disable/enable multiple pages via panel.page.read

Just updated and browsing though the cheatsheets for the new permissions.

and i am wondering how to enable panel.page.read to multiple template pages all at once. whatever i try, i seem to be able to only disable all but one template.

e.g. putting up a specific page which is readable with all it’s children…

Is it normal that when access is denied, that the debug error page is loaded?

What is your code inside the role file?

No, that’s actually two bugs: You a) shouldn’t see the page at all in overviews/be able to click on it and b) should get a nicer error message. @bastianallgeier?

Yes, unfortunately seems to be a bug. In an ideal world, such stuff would turn up in betas, but I guess that’s just how it is :slight_smile: Could you post an issue on Github? We will fix this for 2.4.1

My question is also this: “i am wondering how to enable panel.page.read to multiple template pages all at once. whatever i try, i seem to be able to only disable all but one template.”

Still no answer?

	'panel.page.read' 		=> function() { // Permission to access/read a page in the panel
		return $this->target()->page()->template() !== 'home';
	},

Which pages do you want to hide from editors?

This will hide all pages but the one with template “home”:

<?php
return [
  'name'        => 'Editor',
  'default'     => false,
  'permissions' => [
    '*'               => true,
    'panel.page.read' => function() {
      if($this->target()->page()->template() === 'home') {
        return true;
      };
    }
  ]
];
1 Like

@bastianallgeier I’m on 2.4.1 but can still see pages in the pages widget that aren’t allowed for a certain user role. :pensive:

@Targoran That’s weird. Could you please post your code? Have you made sure you are logged in with the correct user role :innocent:?

Yes sure, I’m logged in with the right user role. And any other permission setting is working as expected.
I tried your exact code example but it doesn’t work – the pages do all show up and for the ones which are restricted it throws an error, as described by @carstengrimm further above.

I think it just haven’t been fixed, or is at least not working in the stable version?

I tested it in a current starterkit before I answered your question, with exactly the code I posted above. And all I see in the pages widget in the dashboard - when logged in as my editor role test user - is the home page, as you can see in the screenshot:

Edit: have you made sure to remove all role settings from your config.php file?

I have lost quite a bit of time figuring out why this didn’t work neither (with the same symptoms). Turns out it was

pages: false

inside site.yml blueprint. When I changed it into true it worked as expected. :disappointed_relieved: