Joe Posted October 7, 2013 Share Posted October 7, 2013 Hi everyone!Is it possible to eliminate access for a non-superuser to the "Settings", "Delete" and "View" tabs on a specific page?It is a site-settings page without a template file and it really doesn´t make any sense and is confusing to the users if they can rename it etc. Thanks Link to comment Share on other sites More sharing options...
Joe Posted October 8, 2013 Author Share Posted October 8, 2013 Answering my own question: So I´ve succeeded, though it was kind of tedious and I consider it a hack only: In \site\templates-admin\default.php: detect the page´s headline $trigger = strip_tags($this->fuel->processHeadline ? $this->fuel->processHeadline : $page->get("title|name")); If the headline is my site-settings page´s, set the relevant list items style to "display: none;": if( $trigger == "Site Settings"): $content = str_replace("<li class='Inputfield InputfieldWrapper Inputfield_ ui-widget' id='ProcessPageEditSettings' title='Settings'>", "<li style = \"display: none;\">", $content); $content = str_replace("<li class='Inputfield InputfieldWrapper Inputfield_ ui-widget' id='ProcessPageEditDelete' title='Delete'>", "<li style = \"display: none;\">", $content); $content = str_replace("<li class='Inputfield InputfieldMarkup Inputfield_ ui-widget InputfieldWrapper' id='ProcessPageEditView' title='View'>", "<li style = \"display: none;\">", $content); endif; That does it. But like I said, I think it´s just a hack. So I will not set the topic to "solved", maybe there is a better way to do it. Link to comment Share on other sites More sharing options...
Soma Posted October 8, 2013 Share Posted October 8, 2013 Hi Joe. A simple search via google (processwire.com hide settings tab) found my thread a while ago: http://processwire.com/talk/topic/3159-hide-settings-tab-in-page-edition/ Here's another example doing it differently: // in a autoload module like HelloWorld.module public function init(){ $this->addHookAfter("ProcessPageEdit::buildForm", $this, "buildFormHook"); } public function buildFormHook(HookEvent $event){ // get page edited by ProcessPageEdit $page = $event->object->getPage(); // conditions if(wire("user")->hasRole("superuser")) return; if($page->id == 1039) { // the form InputfieldWrapper returned by ProcessPageEdit::buildForm() $form = $event->return; // find the desired InputfieldWrapper's and remove them from the form $fieldset = $form->find("id=ProcessPageEditSettings")->first(); $form->remove($fieldset); $fieldset = $form->find("id=ProcessPageEditDelete")->first(); $form->remove($fieldset); } } This works fine in PW. 4 Link to comment Share on other sites More sharing options...
Joe Posted October 9, 2013 Author Share Posted October 9, 2013 Hi Joe. A simple search via google (processwire.com hide settings tab) found my thread a while ago: http://processwire.com/talk/topic/3159-hide-settings-tab-in-page-edition/ Thank you! As described there I used that module to hide "Who can access this page"? in the settings tab for users with the editor role. Works well. Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 4, 2015 Share Posted January 4, 2015 Just want to leave a note for others: This doesn't work currently. The form still gets changed, but the tabs will stay, as Ryan changed the tab generation part. I've opened a github issue regarding this one: https://github.com/ryancramerdesign/ProcessWire/issues/847 Link to comment Share on other sites More sharing options...
kiennguyen1101 Posted April 16, 2016 Share Posted April 16, 2016 A search to hide "delete" tab brought me here. Thanks soma for the code. Just want to leave a note for others: This doesn't work currently. The form still gets changed, but the tabs will stay, as Ryan changed the tab generation part. In order to hide the tab(s), you have to add another hook to edit form: $this->addHook('ProcessPageEdit::getTabs', $this, 'hookEditFormTabs'); public function hookEditFormTabs($event) { // logic check // if ($this->user->isSuperuser()) return; // if ($this->page->id != 29) return; $tabs = $event->return; unset($tabs['ProcessPageEditDelete']); $event->return = $tabs; } 2 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