Jump to content

Restrict Tab View


adrian

Recommended Posts

Hi everyone,

Here's a quick little module that I hope you'll find useful. NB It requires PW 2.5.16 (or late 2.5.15 - this is the exact commit)

It allows you can control display of the various Page Edit tabs by user permissions. So if you want to always hide the Settings tab for users of a particular role across all templates, this should come in handy.

http://modules.processwire.com/modules/restrict-tab-view/

https://github.com/adrianbj/RestrictTabView

post-985-0-64275800-1427483636_thumb.png

You can approach this from two directions - hide from all users unless they have View permission, or show to all users unless they have Hide permission.

It's up to you to create the permissions and assign them to roles.

Let me know if you have any problems or suggestions for improvements.

BTW - I am not sure how much use the Delete and View options really are in most situations, but they are there if you want them.

PS Thanks to @LostKobrakai for the code in this post: https://processwire.com/talk/topic/8836-how-to-manage-delete-tab-for-user-groups/?p=85340.

  • Like 23
Link to comment
Share on other sites

I just posted an update to this.

I noticed a major issue when hiding the settings tab when you are using the "Name format for children" on a template (to bypass the initial page creation step).  

Note that this issue will affect all of the Settings hiding scripts that have been posted on the forums recently, as well as the advanced noSettings mode. I have posted an issue and possible solution on Github (https://github.com/ryancramerdesign/ProcessWire/issues/1048). The problem is that my core solution only handles the issue when the Settings tab is hidden via the noSettings option at the template level, not when hiding it other ways, hence the needed fix to this module.

The fix checks to see if template setting: “nameContentTab” is enabled which would add the name field to the content tab. If not, then we add a hidden version of the name field so that new pages will save without error.

 
This fix may no longer be necessary depending on the outcome of the Github issue - that is if Ryan can come up with a core solution for all scenarios.
  • Like 1
Link to comment
Share on other sites

Once I disabled settings tab in a project for some users. Very cool, to have this option as module now.
I played also around with disabling the whole tab rider 'Pages'. In some special cases this could be useful. Having a really frontend save backend is placed on the top of my personal PW wishlist. Enabling, disabling all tabs and subtabs according to permissions, roles and users. Restrictive sanitization and validation of all inputs. This together with a nice admin theme ....

You did one more step in this direction. Thanks.

  • Like 2
Link to comment
Share on other sites

Thanks arjen - you didn't take long to find it, it was only put together and released on Friday :)

Glad you'll find it useful.

Looking for some feedback for those who might start using this. I am thinking of adding an option to add an UnPublish button to the Content tab when the Settings tab is hidden. I have also discussed the issue here: https://github.com/ryancramerdesign/ProcessWire/issues/1048#issuecomment-87449770

Kinda wondering if Ryan would be willing to add a core solution, but if not, I might add it to this module, because that is the one thing that I think users may still need. Most other things on the Settings tab are just noise for the average user, but Unpublish can be important.

What does everyone think?

Link to comment
Share on other sites

Ah, still I missed it adrian  :)

I would find it useful if we can adjust which fields can showed in the tabs. These days I'm running more and more into stuff clients don't really need. For me only name, hide, unpublish should be in settings. But it would be great if we can create or own lay-out. But than again, that's me and my clients  :rolleyes:  So I would find it useful if we can drag-and-drop our own Page Edit page.

Link to comment
Share on other sites

I'll later take a look at it, but this could benefit of an inputfield selector. In my use cases I wouldn't hide these tabs for all pages.

I am curious if you're thinking on a page basis, or a template basis. I like the idea of adding this option, but I don't want to overcomplicate - it could turn out to be quite a matrix of options if you wanted certain pages/templates for some roles, but different ones for other roles. 

 

I would find it useful if we can adjust which fields can showed in the tabs. These days I'm running more and more into stuff clients don't really need. For me only name, hide, unpublish should be in settings. But it would be great if we can create or own lay-out. But than again, that's me and my clients  :rolleyes:  So I would find it useful if we can drag-and-drop our own Page Edit page.

I think this is quite do-able a might be a nice addition to this module. I think I'll add this functionality, but I would also like to have the option of adding an Unpublish button to the Content tab if the Settings tab is hidden because I am also in the same situation that in almost all cases, the Status section is the only part of Settings that I normally want most site editors to see, but rarely is Hidden necessary for them. It seems like an extra complication to have the Settings tab at all for many user roles, but of course the publication status sometimes still important.

  • Like 1
Link to comment
Share on other sites

I am curious if you're thinking on a page basis, or a template basis. I like the idea of adding this option, but I don't want to overcomplicate - it could turn out to be quite a matrix of options if you wanted certain pages/templates for some roles, but different ones for other roles. 

It does indeed sound like fulfilling this need would benefit from a completely different approach: instead of being able to globally state that "in order to see the Settings tab, your role has to have the tab-settings-view permission", this could mean creating multiple rulesets, each of which defines affected roles, uses a selector field to find pages, and allows selecting visible (or hidden, either way would work) tabs separately.

Sorry, just thinking out loud.. :)

  • Like 3
Link to comment
Share on other sites

@arjen

There's always the option to remove certain fields with an own hooking module. It's just not as easy to set up. 

That is indeed an option, but some kind of drag-and-drop solution would be great. The reason I didn't investigate it futher is because currently there is one Page Edit view and how do you manage a drag-and-drop solution? On a page basis or template basis? What if you make a small change and you have to change 24 other templates as well. I myself don't really see how to abstract those things or how to put an extra "layer" on top of the Page Edit screen.

I think this is quite do-able a might be a nice addition to this module. I think I'll add this functionality, but I would also like to have the option of adding an Unpublish button to the Content tab if the Settings tab is hidden because I am also in the same situation that in almost all cases, the Status section is the only part of Settings that I normally want most site editors to see and I rarely is Hidden necessary for them. It seems like an extra complication to have the Settings tab at all for many user roles, but of course the publication status is still important.

Thanks adrian! Do you have any idea how to order those fields (see my comment above)?

  • Like 1
Link to comment
Share on other sites

I'm on the same page as teppo. I'd much rather see something like a repeater where one selects roles (asm select), templates / pages and limits them with the checkboxes you're using. Maybe one could use a global permission which enables the role to be selectable and so that other devs can notice that this is managed by the module  and not by the traditional permission system. 

OT: Sound quite like the dynamic roles module. Never really used it and it's quite silent about it here in the forum.

  • Like 1
Link to comment
Share on other sites

Thanks Martijn - not sure why I was using insertAfter there - just matching where it would be if it was visible, but since it's hidden it doesn't matter. I have committed a fix.

Also just so everyone knows, I will get to all your suggestions for making this more configurable - just waiting on Ryan's thoughts on some of those issues regarding a core fix or not.

  • Like 2
Link to comment
Share on other sites

Thx for this Adrian. Would it be able to work with custom tabs? 

Hey kongondo, thanks for the suggestion - already on my list of things to do :)

I would like to be able support Fieldset tabs as well as custom ones created via modules, like Nic's Page References Tab - I can see I am going to need more than one technique here :)

Was there any particular custom tab setup you were interested in being able to hide? Just good to get an idea of all the possible options.

Thanks!

  • Like 1
Link to comment
Share on other sites

Hey kongondo, thanks for the suggestion - already on my list of things to do :)

I would like to be able support Fieldset tabs as well as custom ones created via modules, like Nic's Page References Tab - I can see I am going to need more than one technique here :)

Was there any particular custom tab setup you were interested in being able to hide? Just good to get an idea of all the possible options.

Thanks!

Nothing in particular....just WireTabs and yes, Fieldset tabs, ta...

Link to comment
Share on other sites

  • 3 months later...

Does module differ superuser from non-superuser? When I hide Children, Settings and Delete tabs, they become hidden for all non-superusers (as expected). As for superuser - Children and Settings also become hidden, and Delete remains visible. I'd like superuser not be affected, e.g. all tabs should be visible. Is it a bug or feature?

PW 2.6.4 

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
×
×
  • Create New...