renobird Posted March 22, 2017 Share Posted March 22, 2017 For ages I used an admin helper module to do this. I finally decided to try this module, and whaddya know — works like a charm. Thanks Adrian! 3 Link to comment Share on other sites More sharing options...
netcarver Posted July 4, 2018 Share Posted July 4, 2018 Hi @adrian, Very useful module (as always.) Question though, is there any reason to use Inputfield::collapsedYes rather than collapsedHidden for the _pw_page_name field when removing the settings tab? (Reference line 114 of module code.) I'd have thought it would be more natural to hide all the fields from the settings tab if the module were setup to hide the Settings tab, not just move the _pw_page_name field into the start of the content tab. Link to comment Share on other sites More sharing options...
adrian Posted July 4, 2018 Author Share Posted July 4, 2018 2 hours ago, netcarver said: I'd have thought it would be more natural to hide all the fields from the settings tab if the module were setup to hide the Settings tab, not just move the _pw_page_name field into the start of the content tab. It used to work like that, but it wasn't working for multi-language page names. This change happened in this commit (https://github.com/adrianbj/RestrictTabView/commit/9316082a26315a42d5036481da9d136eb5d4c42e). You could use an older commit, or if you can find a way to make it work while being hidden, I'd love to know. Maybe it needs to be hidden (or positioned off screen) via CSS instead? 1 Link to comment Share on other sites More sharing options...
netcarver Posted July 4, 2018 Share Posted July 4, 2018 @adrian Thanks for the reply. That seems strange - I would have thought the collapsedHidden status would have included it in the form as a hidden input. For now, I'll just use a hook in my site/ready.php to hide the unneeded tabs as I don't want have any module updates remove changes. Thanks! 1 Link to comment Share on other sites More sharing options...
Robin S Posted July 4, 2018 Share Posted July 4, 2018 9 hours ago, adrian said: Maybe it needs to be hidden (or positioned off screen) via CSS instead? Yes, I think the module should do this (or offer an option for it). Because the name field is normally on the Settings tab, and if you are removing that tab for a role then you probably don't want the role seeing any of the fields normally on that tab. You probably know this but it was new to me... you can add styles to an inputfield without needing to include a CSS file with the module: $if = $wrapper->getChildByName('_pw_page_name'); $if->wrapAttr('style', 'display:none;'); 4 Link to comment Share on other sites More sharing options...
adrian Posted July 5, 2018 Author Share Posted July 5, 2018 Great idea @Robin S - I do know about wrapAttr but I must admit that I often forget about it in situations like this - thanks for the reminder. I have implemented like this and it seems to be working well now. @netcarver - if you decide to revert to using this module, let me know how it goes for you. 2 Link to comment Share on other sites More sharing options...
matjazp Posted July 5, 2018 Share Posted July 5, 2018 What about the Restore tab? I'm looking at the ProcessPageEdit.module and in ___BuildFormContent() is: if($this->page->template->nameContentTab) { // add InputfieldPageName ... } But in ___BuildFormSettings() the condition is different: if(($this->page->id > 1 || $this->hasLanguagePageNames) && !$this->page->template->nameContentTab) { // add InputfieldPageName ... } Why? 1 Link to comment Share on other sites More sharing options...
netcarver Posted July 5, 2018 Share Posted July 5, 2018 @adrian That seems to work well for my purposes. Thanks to you and @Robin S! 1 Link to comment Share on other sites More sharing options...
adrian Posted July 5, 2018 Author Share Posted July 5, 2018 @matjazp - I'll take a look at the new Restore tab - thanks for the reminder. As for the difference between those two conditions - that's a good question - I am not sure really - you'd think the check for homepage and languagePageNames would be relevant on the content tab as well. I guess maybe because you have to explicitly check the "Display 'name' field in content tab?" option for the home template it's up to you as the dev to decide if you want the name on the Content tab. Link to comment Share on other sites More sharing options...
adrian Posted July 5, 2018 Author Share Posted July 5, 2018 The "Restore" tab is now supported. I have also added a new option that lets you display the name field in the Content tab if you have hidden the Settings tab - default is not to show it though. 3 Link to comment Share on other sites More sharing options...
netcarver Posted July 9, 2018 Share Posted July 9, 2018 Hi @adrian I'm seeing an error - apparently due to this module - when trying to add a Repeater item on a page where tabs have been hidden and I'm not logged in as a super-user (all ok when logged in as a Super.) Fatal error: Uncaught Error: Call to a member function wrapAttr() on null in /site/modules/RestrictTabView/RestrictTabView.module:117 Stack trace: #0 site/modules/RestrictTabView/RestrictTabView.module(79): RestrictTabView->removeTabs('Settings', Object(ProcessWire\HookEvent)) #1 /wire/core/Wire.php(383): RestrictTabView->afterBuildForm(Object(ProcessWire\HookEvent)) #2 /wire/core/WireHooks.php(825): ProcessWire\Wire->_callMethod('afterBuildForm', Array) #3 /wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageEdit), 'buildForm', Array) #4 /wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module(531): ProcessWire\Wire->__call('buildForm', Array) <snip> This causes ajax loaded repeater items to fail. Guarding the call seems to fix it... if ($pn instanceof Inputfield) { $pn->wrapAttr('style', 'display:none;'); } 1 Link to comment Share on other sites More sharing options...
vincent Posted July 10, 2018 Share Posted July 10, 2018 Hello @adrian and @netcarver I think I have the same issue here. When I try to hide the tab "Settings", I can't add a new repeater field item on a page if I'm logged in as a non-superuser. With other choices ("Children", "Restore", etc) there is no conflict. 1 Link to comment Share on other sites More sharing options...
netcarver Posted July 10, 2018 Share Posted July 10, 2018 @vincent Yes, sounds like the same problem. If you edit the .module file and make the change I posted above, your problem should be resolved. I cloned the repo and added the change. Can you try my version from here and let me know if that fixes it for you. If so, I'll send a PR over to Adrian. 1 Link to comment Share on other sites More sharing options...
vincent Posted July 11, 2018 Share Posted July 11, 2018 @netcarver your version fixes the conflict in my installation. Thank you ! 2 Link to comment Share on other sites More sharing options...
netcarver Posted July 11, 2018 Share Posted July 11, 2018 Ok, @vincent I've submitted a pull request to get this change into the master repository. Thanks for checking. 1 Link to comment Share on other sites More sharing options...
adrian Posted July 16, 2018 Author Share Posted July 16, 2018 Thanks @netcarver and @vincent for finding this issue and getting a fix in place and tested. PR has been merged and the module updated! Sorry for the delay - was away last week. 2 Link to comment Share on other sites More sharing options...
netcarver Posted July 17, 2018 Share Posted July 17, 2018 Great to have you back, Adrian. Thanks for pulling in the change. 1 Link to comment Share on other sites More sharing options...
adrian Posted June 9, 2020 Author Share Posted June 9, 2020 Hi all, I just added the ability to restrict access to custom FieldsetTabs which makes it easier to block certain user roles from having edit access to entire sets of fields (in the selected tabs). I also added a new "Exempt Roles" setting that makes it easy to make sure certain roles are not affected by this module - particularly useful if you use the "View" permissions approach. 3 Link to comment Share on other sites More sharing options...
MarkE Posted February 13, 2021 Share Posted February 13, 2021 (edited) I've been using this for a while with no problems, but have just run into a slight issue. I have a checkbox field 'override' which is in a tab 'system'. The 'system' tab is only allowed for superuser. However, another field in an unrestricted tab uses a visibility condition "override!=1". It seems that, when a non-superuser is logged in, the visibility condition returns false when it should be true, presumably because override cannot be accessed. There are no restrictions on the override field itself. Any ideas @adrian? I tried a work-round with a hook, assuming that the API would work even if the tab was hidden. The one below is after renderReadyHook, but I also tried a before hook. In each case, the value is applied, but it seems like the form is unchanged. $this->addHookAfter('Inputfield::renderReadyHook', function(HookEvent $event) { $input = $event->arguments(0); if ($input and $input->id == 'Inputfield_fieldset_minimal') { bd($input, 'input'); $input->showIf = (wire()->page->overide!=1); } $event->arguments(0, $input); $event->return; }); Edited February 15, 2021 by MarkE Additional info Link to comment Share on other sites More sharing options...
adrian Posted February 19, 2021 Author Share Posted February 19, 2021 Hi @MarkE Sorry I've been so long to respond - way too busy here at the moment. I don't have a fully working solution for you (I couldn't quite get there as quickly as I need to), but here are some starting points. The first one is hacky. The second is where you want to end up, but you'll probably want to do a $f->addClass('hidden') or something like that. I also didn't want to use a Markup inputfield but it seemed like there were issues with overriding the main "override" field. Also, using $p->override isn't actually working because it's preventing you from changing the value that is already in the system but if you set it to 0 or 1, you'll see that the approach has merit in that it will change the visibility of your other field. Sorry it's not fully working, but hopefully gets you there. Remember the key thing is that showIf conditions work via JS, so the values need to be available that way, not just via $page->override like you were trying. $this->addHookAfter('Page::render', function(HookEvent $event) { $p = $event->object; $event->return = str_replace("</body>", '<input type="hidden" id="Inputfield_override" name="override" value="'.$p->override.'"></body>', $event->return); }); $this->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event) { $p = $event->object->getPage(); bd($p->override); $form = $event->return; $f = $this->modules->get("InputfieldMarkup"); $f->attr('id+name', 'override'); $f->attr('value', '<input type="hidden" id="Inputfield_override" name="override" value="'.$p->override.'">'); //$f->collapsed = Inputfield::collapsedHidden; $form->insertAfter($f, $form->title); $event->return = $form; }); 1 Link to comment Share on other sites More sharing options...
MarkE Posted February 20, 2021 Share Posted February 20, 2021 9 hours ago, adrian said: Sorry I've been so long to respond - way too busy here at the moment. No worries - thanks for the help 9 hours ago, adrian said: The first one is hacky This one works fine ? 9 hours ago, adrian said: The second is where you want to end up I suspect I need to mod this a bit to get it working. Ta muchly! Link to comment Share on other sites More sharing options...
adrian Posted February 20, 2021 Author Share Posted February 20, 2021 Just now, MarkE said: This one works fine ? Make sure you limit it to the PageEditor interface in the admin - you don't want that checkbox appended everywhere back and frontend ? 1 Link to comment Share on other sites More sharing options...
MarkE Posted February 20, 2021 Share Posted February 20, 2021 11 hours ago, adrian said: Make sure you limit it to the PageEditor interface in the admin Sure. In fact, I was wrong to say that it works fine - I needed to make a small adjustment, which also enables more checking. The page object in the hook has the admin template - so we need to get the actual page being edited in order to get the override field. $this->addHookAfter('Page::render', function(HookEvent $event) { $p = $event->object; if ($p->template == 'admin') { $pId = wire()->input->get->int('id'); $page = wire('pages')->get($pId); if ($page and $page->template == 'BookingForm') { $event->return = str_replace("</body>", '<input type="hidden" id="Inputfield_override" name="override" value="' . $page->override . '"></body>', $event->return); } } }); 1 Link to comment Share on other sites More sharing options...
SebastianP Posted April 4, 2023 Share Posted April 4, 2023 Hi @adrian, thank you for providing this helpfull module! I've found a strange behaviour in my backend: when the "tab-view-hide"-permission is set for a role, the image or file upload fails. Please have a look at my post. Thank you, best regards Sebastian 2 Link to comment Share on other sites More sharing options...
adrian Posted April 7, 2023 Author Share Posted April 7, 2023 @SebastianP - fixed in the latest version - thanks to @flydev 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