Umbraco 15 - Content Tree - Looking for an example
# help-with-umbraco
m
I'm looking for an example of how to disable (or remove) an item from the right click menu on the content tree under certain conditions. Does anyone have an example of this, some code that does something similar, a package that does this somewhere, or failing that could someone point me to the internal API I need to hook into/extend/override?
s
Permissions?
And if not, then do feed this back into the discussion here, we're trying to figure out what people need and why: https://discord.com/channels/869656431308189746/1327202022373593180/1327224855476834407 Update, wrong link: https://github.com/umbraco/Umbraco-CMS/discussions/16329
m
Hey thanks @User , I wasn't sure if I needed to go the permissions route or the notifications route. I'd like to prevent the editor clicking on Sort Children for a certain node/document type only. I sort of guessed that would have been notifications in earlier versions and now permissions, but I'm really not sure.
s
You could handle that now with an notification handler yeah, but might be a good piece of feedback in that discussion anyway so the team knows what people want to do with our tree!
m
I can see Sorting, ContentSorting, Sorted & ContentSorted events, wouldn't those just give me the option of killing the event once clicked rather than removing the option from the UI?
I might be missing the point
s
Yeah you can cancel
ContentSorting
- it's not the nicest experience, you get a banner saying: sorry, couldn't complete that, you're not allowed (this is a message you provide). But no way of preventing them trying it.
m
So is there a way of removing an item from the UI under certain conditions? The same logic but at the UI level before the event fires?
Is that where the permissions would come in?
s
The permissions only apply to a user's role, there are no conditions available. So if it is: everybody can sort anything except under the Blog then this is not available as an option. However, you could subscribe to notifications to at least enforce the business rule.
m
Okay cool, thanks Seb 👍🏻
For anyone else who finds this thread and might find the following useful. I used the notification handler method that @Sebastiaan suggests. This evening I posted an article on my blog of how to implement it: https://mattbliss.uk/articles/automatic-date-time-ordered-content-in-the-umbraco-back-office/
s
@UMB.FYI tip
u
Sorry, I couldn't process this command. Please try again.
16 Views