adrian

Restrict Tab View

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

Share this post


Link to post
Share on other sites

Please publish this new module.  Thanks and here's another useful tool you have developed.

  • Like 2

Share this post


Link to post
Share on other sites

Thank you! I want to encourage you to keep on going with those super usefull modules you always come up with. I do not vote for your modules every time I download them just to keep my ip from being banned.

  • Like 3

Share this post


Link to post
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

Share this post


Link to post
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.

  • Like 2

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

How could I've missed this? Thanks ProcessWire Weekly #46 and of course adrian for again making a gem. These tools come in very handy.

  • Like 1

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hi Adrian, found a little issue on line 111.

When the page has no title, a fatal error is thrown,

Never the less, thanks lot the module.

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

  • Like 2

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Nope, LanguageTabs are a different kind of animal. The fieldsets mentioned are WireTabs.

  • Like 1

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

@arjen: why don't just hide them using custom css and admincustomfiles module?

Share this post


Link to post
Share on other sites

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 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot:

    • By MoritzLost
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By adrian
      This module provides a way to rapidly generate Page fields and the required templates and pages for use as a drop down select (or any other Page field type).
      This module will let you create a full page field setup in literally a few seconds 
      To use, run Page Field Select Creator from the Setup Menu
      Enter a Field Title, eg: Room Types Select Options - These will become the child pages that will populate the page field select options. There are two different options.
       
      Option 1. TITLE FIELD ONLY - enter one option per line, eg:
       
      Single
      Double
      Suite
       
       
      Option 2. MULTIPLE FIELDS - the first line is used for the field names and the first field must be 'Title'. Subsequent lines are the values for the fields, eg:
       
      Title, Number of Beds, Number of People, Kitchen Facilities
      Single, 1, 1, Fridge Only
      Double, 2, 2, Fridge Only
      Suite, 3, 6, Full Kitchen
        Choose the parent where the page tree of options will be created, eg a hidden "Options" parent page Select a "Deference in API as" option depending on your needs Choose the input field type Check whether "Allow new pages to be created from field?" should be enabled. As an example, if you entered "Room Types" as the field title, you would end up with all of the following automatically created:
      a fully configured page field called: room_types MULTIPLE FIELDS OPTION - 3 additional fields - number_of_beds, number_of_people, kitchen a parent template called: room_types a child template called: room_types_items (with either just a title field, or with the 3 additional fields as well) a parent page called: Room Types a series of child pages named and titled based on the per line entries in the Select Options textarea The templates are configured such that the "room_types_items" child template can only have the main "room_types" template as a parent, and vice versa.

      Then all you have to do is add the newly created page field to any template you want and you're ready to go!
       
      You can grab it from:
       
      Modules directory: http://modules.processwire.com/modules/process-page-field-select-creator/
      Github: https://github.com/adrianbj/ProcessPageFieldSelectCreator
       

    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://github.com/BernhardBaumrock/RockFinder
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/