Jump to content

Sorting pages without editing rights on parent page


torf
 Share

Recommended Posts

I know this topic has been addressed several times before, but has anyone a solution in 2025?
As for my site manual sorting of the child pages is crucial for some users, but they are not supposed to touch the parent page. Can I achieve this somehow?

Thanks
Torf

Link to comment
Share on other sites

This might be a band aid but:

If you don't have a huge amount of pages to sort, one possibility is to create a separate page with page reference field, add the pages there and base the sorting on the ordering of this field. Admittedly this is a good solution in some cases and sometimes it's far too inconvinient to do it like this.

It's how I usually do web pages main navigation.

  • Like 1
Link to comment
Share on other sites

It seems to work if you allow edit access on the parent template in the normal way via the PW admin...

image.png.c87ab7f9b1033e16903c49483604e8fe.png

...and then disallow editing on the parent template in a hook to Page::editable()

$wire->addHookAfter('Page::editable', function(HookEvent $event) {
	/** @var Page $page */
	$page = $event->object;
	$user = $event->wire()->user;
	// Return early if PW has already determined that the user is not allowed to edit
	if(!$event->return) return;
	// Don't allow users with the "editor" role to edit pages with the "colours" template
	if($page->template == 'colours' && $user->hasRole('editor')) $event->return = false;
});

image.gif.3fc0b791e91a2da1f8f520fe76cfe5d0.gif

  • Like 4
Link to comment
Share on other sites

@MSP01 Thanks - that's an interesting approach, but it's too late for this time - I'd have to rewrite half of the templates.

@Robin S That worked. It's still a bit of coding, since in my case it's more then a dozen templates, but it works. Changed the last line to make it a bit easier when working on numerous parent templates:

$arr_of_templates = ["parent_1","parent_2","parent_3"]; // and so on
if((in_array($page->template, $arr_of_templates)) && ($user->hasRole('editor'))) $event->return = false;

Thank you very much

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

×
×
  • Create New...