Prevent deletion of page node

How is it possible to prevent a certain page node from being deleted by an editor? Couldn’t find any hint.

The documentation tells about the RemoveNodePrivilege, that should suite your needs

https://docs.neos.io/cms/manual/backend-permissions/node-privileges

Thanks Soren. I searched intensively using keywords like prevent, avoid and so on. ‘intercepts’ should have done it.

I expected the implementation somewhere in the dabase model because according to my general understanding of content this would rather be a privilege property of the node than a seperate privilege definition.

Anyway. It is in general what I was looking for but not in detail. If I have a look at the “List of Node Privilege Matchers” there is no matcher that only prevents the given node from being deleted. The requirement is to prevent a page (node) from being deleted but the content (nodes) of the page should of course still be editable which doesn’t seem to work with the available matchers. Or is there a working matcher for this?

It should be possible to meet the requirements by defining a unique node type and use the “nodeIsOfType`” macther. But this doesn’t really feel natural and brings some overhead.

If you don’t want it to be deleted in general it often is easier to define it as fixed child node of its parent.
But besides that the removeNodePrivilige should do what you want. And a custom nodetype for it makes it easier.

Or take a look at Sandstorms ACL package https://github.com/sandstorm/NeosAcl

Thanks for your infos. A fixed child node doesn’t meet the requirements in detail. So the custom node type seems to be the method of choice here. I will also have a look at the ACL package later. Thx.

Is there a particular reason why there is no privilege matcher for a single (document) node?

isDescendantNodeOf actually matches the node itself too.

That’s how I read the documentation but it matches not only the node itself but also all descendant nodes.
Im wondering why the simplest matcher (for a single node) is not available. Is there a particular reason for that? Maybe because it does not match the architecture or whatever?

1 Like