ryan Posted November 3, 2023 Share Posted November 3, 2023 This week I've been working on various ProcessWire related projects, but haven't pushed much to the core. There was a core feature I've been working on which I decided to instead put in a module. It's one of those things that should be be really beneficial for some people, but not necessarily needed by everyone, so it makes more sense as a module. This particular module expands upon the page-lock option and permission in ProcessWire. The page-lock option (which you'll see as the "Lock" status in the Settings tab of the page editor) provides the ability to lock a page for edits. This can be really useful if you want to prevent a particular page from being modified for whatever reason. For instance, maybe you are doing a $pages->get('/some/page/'); on the API side and if the path /some/page/ got changed, it would break something in the site. So to prevent clients from breaking the site, you lock the page to prevent them from screwing it up and breaking something on the site. This is quite useful, and often a life saver. But I don't use it as much as I'd like because of one downside. That downside is that it locks the entire page so that nothing on it can be edited. So it's just too heavy of a lock. What if you just wanted to lock the page so that the name, title and parent couldn't be edited, but everything else could be? That's what this new module enables. To lock a field in the page editor, you click its header and hold until a dialog pops up asking if you want to lock it. To unlock, you do the same thing. Once a field is locked, it remains locked (non-editable) until unlocked. Only users with page-lock permission on the page can lock or unlock fields. Locks can also be managed with checkboxes in the page editor Settings tab as well, just in case that is more convenient in some contexts. While these are editor locks rather than API locks, the locks do affect contexts outside the page editor too, such as actions in the page list. For instance, if you locked "parent" then you wouldn't be able to bypass it dragging a page in the Page List. I finished developing the module today, but I've not yet written documentation for it or uploaded to GitHub, etc., so I'm going to give it another day of work and testing before releasing it next week, and will cover more details in next week's post. Thanks and have a great weekend! 20 2 Link to comment Share on other sites More sharing options...
Kiwi Chris Posted November 3, 2023 Share Posted November 3, 2023 Sounds like a useful module. Could this help with a related issue to locks I've had in that in ListerPro (or other places), I've wanted to have locked pages, but allow users to duplicate them? Imagine a scenario where someone has repeat orders and wants to make new orders that are very similar to previous ones with a few changes, so they should be able to duplicate an existing order, but not change it. I'm fine with changing the lock status via api on creation of the duplicate, but I've struggled with enabling the icon to click to allow copying a locked page. 1 Link to comment Share on other sites More sharing options...
MarkE Posted November 3, 2023 Share Posted November 3, 2023 3 hours ago, Kiwi Chris said: I've wanted to have locked pages, but allow users to duplicate them? I’ve had the same need and dealt with it via such that when a “locked” page is edited, it gives an option to create a new one like this. In my implementation it is all dealt with in a process module, rather than in the page list. I can supply more details if you want. Link to comment Share on other sites More sharing options...
Kiwi Chris Posted November 5, 2023 Share Posted November 5, 2023 21 hours ago, MarkE said: I’ve had the same need and dealt with it via such that when a “locked” page is edited, it gives an option to create a new one like this. In my implementation it is all dealt with in a process module, rather than in the page list. I can supply more details if you want. @MarkE yes that would be handy. I assumed a module would be necessary, just wasn't quite sure what to hook into. Link to comment Share on other sites More sharing options...
MarkE Posted November 6, 2023 Share Posted November 6, 2023 Hi @Kiwi Chris. I have sent you a PM with the module. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now