Alexis Posted March 26, 2013 Share Posted March 26, 2013 Hi everyone, When i edit a page in the admin (logged as an editor), i would like to hide the "Settings" tab or at leat the part "Who can access this page?". Is there a simple way to do that? Thanks. Link to comment Share on other sites More sharing options...
Soma Posted March 26, 2013 Share Posted March 26, 2013 You can't do this just out of the box but with a autoload module you could easily accomplish this. Also there's useful needed features in there for an editor. At least the "Who can access this page"? Why is this a problem? It may not necessary in most cases... In PW, almost all of these things can be changed modified using hooks on what builds them in the admin. So if you really want to do it, the best way would be through a module like the /site/modules/HelloWorld.module It shows some example of hooks and is worth a look and have a play anyway. This following module hides the InputfieldWrapper "Who can access this page"? in the settings tab for user having a role "editor". <?php class AdminHelperHooks extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Admin Helper Hooks', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { // add hook to the page edit module and the method that creates the wanted fieldset $this->addHookAfter('ProcessPageEdit::buildFormRoles', $this, "removeSettings"); } function removeSettings(HookEvent $event){ // check what role the user has, if not has editor role do nothing if(!wire("user")->hasRole("editor")) return; // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // we're done } } Create a new file AdminHelperHooks.module with this code in a new folder /site/modules/AdminHelperHooks/ Install and test with editor user. 11 Link to comment Share on other sites More sharing options...
Alexis Posted March 27, 2013 Author Share Posted March 27, 2013 Thanks a lot Soma. Your code works perfectly. At least the "Who can access this page"? Why is this a problem? It may not necessary in most cases... The problem is just i don't want to give the editor (=my client) too much information. I'm building a tipical website with a few levels of options. All options are buit in the aplication and are activated according to the level the client want. This means I have specific fields permissions and roles for each level, which appears all in "who can access this page?", but doesn't match the client choice. Link to comment Share on other sites More sharing options...
gfdesign Posted June 27, 2013 Share Posted June 27, 2013 Thanks Soma. Your code works like a charm. Best regards Link to comment Share on other sites More sharing options...
blad Posted August 17, 2014 Share Posted August 17, 2014 Thanks Soma Link to comment Share on other sites More sharing options...
mrkhan Posted December 31, 2014 Share Posted December 31, 2014 Hello Soma, i am using version 2.5 of PW and trying to hide settings tab on user role webmaster (which is my defied role) i have use bellow code <?php class AdminHelperHooks extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Admin Helper Hooks', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { // add hook to the page edit module and the method that creates the wanted fieldset $this->addHookAfter('ProcessPageEdit::buildFormRoles', $this, "removeSettings"); } function removeSettings(HookEvent $event){ // check what role the user has, if not has editor role do nothing if(!wire("user")->hasRole("webmaster")) return; // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // we're done } } in site/modules/AdminHelperHooks/AdminHelperHooks.module also i install the module but when i login as user using webmaster group i can see settings tab. how i hide page setting tab for this type of user ? Thanks Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 29, 2015 Share Posted January 29, 2015 @mrkhan: There have been changes in ProcessPageEdit recently. The tabs need to be deleted manually. The code below works in 2.5.25 (dev). (don't know if thats the case for 2.5 and if so could you report this back) function removeSettings(HookEvent $event){ // check what role the user has, if not has editor role do nothing if(!wire("user")->hasRole("webmaster")) return; // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // Get the active Object (ProcessPageEdit) $process = $event->object; // Remove the Settings tab with the ID $process->removeTab('ProcessPageEditSettings'); // we're done } 3 Link to comment Share on other sites More sharing options...
formulate Posted March 14, 2015 Share Posted March 14, 2015 @mrkhan: There have been changes in ProcessPageEdit recently. The tabs need to be deleted manually. The code below works in 2.5.25 (dev). (don't know if thats the case for 2.5 and if so could you report this back) function removeSettings(HookEvent $event){ // check what role the user has, if not has editor role do nothing if(!wire("user")->hasRole("webmaster")) return; // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // Get the active Object (ProcessPageEdit) $process = $event->object; // Remove the Settings tab with the ID $process->removeTab('ProcessPageEditSettings'); // we're done } Hi Martijn, I wasn't able to get this to work with dev 2.5.22. All it does is swap the places of the delete and settings tabs. Any advice? Thanks, K. Link to comment Share on other sites More sharing options...
adrian Posted March 14, 2015 Share Posted March 14, 2015 Not sure why this hasn't been mentioned, so I am wondering if I am missing something relevant, but why not use the $template->noSettings option? Do you need to hide on a page basis, rather than per template? Anyway, if it suits your needs, turn on advanced mode in your config.php file and then you will have a Disable Settings Tab? option on the Template's System Tab. Hope that might help. 4 2 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted March 14, 2015 Share Posted March 14, 2015 There must be recent changes I guess, but this one works: oops this one is for delete tab <?php class AdminHelperHooks extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Admin Helper Hooks', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { // add hook to the page edit module and the method that creates the wanted fieldset $this->addHookAfter('ProcessPageEdit::buildFormDelete', $this, "removeDelete"); } function removeDelete(HookEvent $event){ // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // Get the active Object (ProcessPageEdit) $process = $event->object; // Remove the Settings tab with the ID $process->removeTab('ProcessPageEditDelete'); // we're done } } For settings tab <?php class AdminHelperHooks extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'My Admin Helper Hooks', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { // add hook to the page edit module and the method that creates the wanted fieldset $this->addHookAfter('ProcessPageEdit::buildFormSettings', $this, "removeSettings"); } function removeSettings(HookEvent $event){ // $event->return being the inputfield wrapper $wrapper = $event->return; // set the inputfield wrapper to hidden $wrapper->collapsed = Inputfield::collapsedHidden; // Get the active Object (ProcessPageEdit) $process = $event->object; // Remove the Settings tab with the ID $process->removeTab('ProcessPageEditSettings'); // we're done } } 3 Link to comment Share on other sites More sharing options...
adrian Posted March 27, 2015 Share Posted March 27, 2015 I just created a module that might be useful to those interested in this topic: https://processwire.com/talk/topic/9496-restrict-tab-view/ 4 Link to comment Share on other sites More sharing options...
bmacnaughton Posted April 23, 2017 Share Posted April 23, 2017 On 3/14/2015 at 2:15 PM, adrian said: Anyway, if it suits your needs, turn on advanced mode in your config.php file and then you will have a Disable Settings Tab? option on the Template's System Tab. Woohoo! Thanks. $config->advanced = true; does the trick! 1 Link to comment Share on other sites More sharing options...
bmacnaughton Posted April 23, 2017 Share Posted April 23, 2017 On 3/14/2015 at 2:21 PM, Martijn Geerts said: There must be recent changes I guess, but this one works: I'm working in version 3 and can't remove the settings tab using your example. Maybe something new has changed? But $config->advanced = true; works perfectly and is a better solution as it's already per-template. 1 Link to comment Share on other sites More sharing options...
adrian Posted April 23, 2017 Share Posted April 23, 2017 4 hours ago, bmacnaughton said: I'm working in version 3 and can't remove the settings tab using your example. Maybe something new has changed? But $config->advanced = true; works perfectly and is a better solution as it's already per-template. My module (https://processwire.com/talk/topic/9496-restrict-tab-view/) mentioned above still works fine in PW 3 if that's helpful for you. 2 Link to comment Share on other sites More sharing options...
bmacnaughton Posted April 24, 2017 Share Posted April 24, 2017 4 hours ago, adrian said: My module (https://processwire.com/talk/topic/9496-restrict-tab-view/) mentioned above still works fine in PW 3 if that's helpful for you. Thank you. I really appreciate the link and the code being on github. I learn a lot by reading code and yours is very helpful. I've solved the problem for one template but your solution is more general so when the inevitable additional template comes along, I'll most likely move to your module. Thanks for putting it together and pointing me at it. 1 Link to comment Share on other sites More sharing options...
buster808 Posted June 9, 2019 Share Posted June 9, 2019 Hi, does the settings page not have its own template somewhere. I would like to keep Name but hide everything else on the settings tab in page. Thanks Link to comment Share on other sites More sharing options...
teppo Posted June 9, 2019 Share Posted June 9, 2019 42 minutes ago, buster808 said: Hi, does the settings page not have its own template somewhere. I would like to keep Name but hide everything else on the settings tab in page. It sounds like you may be confusing pages and tabs: the settings tab (included on each page) doesn't have a template of its own. None of the tabs do -- only pages have (or, more specifically, use) templates. This thread has ideas on how to hide the settings tab with code, and if you enable the advanced mode via site/config.php, you should find settings for hiding the tab and moving name to the Content tab. More details here: 1 1 Link to comment Share on other sites More sharing options...
buster808 Posted June 9, 2019 Share Posted June 9, 2019 53 minutes ago, teppo said: It sounds like you may be confusing pages and tabs: the settings tab (included on each page) doesn't have a template of its own. None of the tabs do -- only pages have (or, more specifically, use) templates. This thread has ideas on how to hide the settings tab with code, and if you enable the advanced mode via site/config.php, you should find settings for hiding the tab and moving name to the Content tab. More details here: Excellent thanks Teppo didn't know about the advanced mode. 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