sosoba Posted May 16, 2013 Share Posted May 16, 2013 First of all i'd like to say hello to all the community! Me and a co-worker are fresh users of Processwire. We've been wandering trough various cms's but this is a really high quality enviroment. Both flexible and powerful. I suspect we'll use it for many sites to come... I also wanted to share the site that was created (almost finished) with this fantastic CMS. Thanks Ryan! www.concinaprata.org Sorry but only Italian content. Back to the topic, the question i need answer to is: How can i set the name field visibility to Always collapsed? I noticed that my client, when creating pages, can't resist the urge to modify that field and that will surely create problems with the seo. I tried searching in the fields page, but name isn't listed there. Even in the database i couldn't find it...and i'd prefer not to touch core files. So i apologise beforehand if it was a crystal clear thing and i didn't see it! 1 Link to comment Share on other sites More sharing options...
kongondo Posted May 16, 2013 Share Posted May 16, 2013 Hello Sosoba! I don't have an answer for you; just saying hi back and welcome to ProcessWire! Very nice site you got there! Link to comment Share on other sites More sharing options...
sosoba Posted May 16, 2013 Author Share Posted May 16, 2013 Thanks! Link to comment Share on other sites More sharing options...
Soma Posted May 16, 2013 Share Posted May 16, 2013 Wel Welcome sosoba! This would be possible by making a hook to any of the the form building methods in ProcessPageEdit.module. All methods with three underscores are hookable. All about hooks. Take the HelloWorld.module and add this hook to the init() $this->addHookAfter('ProcessPageEdit::buildFormSettings', $this, 'buildFormSettings'); And then add this function to the class. public function buildFormSettings(HookEvent $event){ $fieldset = $event->return; // get the fieldwrapper returned $field = $fieldset->get("_pw_page_name"); // get the name field $field->collapsed = Inputfield::collapsedYes; } 5 Link to comment Share on other sites More sharing options...
diogo Posted May 16, 2013 Share Posted May 16, 2013 Name is not a normal field, so it doesn't even appear when you show build-in fields. I don't think you can't do this in an elegant way. The non elegant way is with javascript. Still, I think the most elegant way of all is telling the client to leave it alone edit: there you have it, Soma to the rescue! I keep my second statement though Link to comment Share on other sites More sharing options...
kongondo Posted May 16, 2013 Share Posted May 16, 2013 I think I have leant not to say anything is impossible until Soma has said so! . Where would we be without him! 2 Link to comment Share on other sites More sharing options...
sosoba Posted May 21, 2013 Author Share Posted May 21, 2013 Welcome sosoba! This would be possible by making a hook to any of the the form building methods in ProcessPageEdit.module. All methods with three underscores are hookable. All about hooks. Take the HelloWorld.module and add this hook to the init() $this->addHookAfter('ProcessPageEdit::buildFormSettings', $this, 'buildFormSettings'); And then add this function to the class. public function buildFormSettings(HookEvent $event){ $fieldset = $event->return; // get the fieldwrapper returned $field = $fieldset->get("_pw_page_name"); // get the name field $field->collapsed = Inputfield::collapsedYes; } Thanks! I studied the page you mentioned (didn't know it) and all worked like a charm With your code the name field was correctly hided in edit page, but also wanted it to be collapsed on page creation. My solution was to transform the ProcessPageAdd::buildForm() method in a hookable one (___buildForm()) and add $this->addHookAfter('ProcessPageAdd::buildForm', $this, 'buildFormSettings'); to the init() function you provided. I know it is inelegant (and probably will create problems during update), but trying to attach the hook to the ProcessPageAdd::execute method, the only one hookable on page creation, was no good Link to comment Share on other sites More sharing options...
sosoba Posted May 21, 2013 Author Share Posted May 21, 2013 Wel Welcome sosoba! This would be possible by making a hook to any of the the form building methods in ProcessPageEdit.module. All methods with three underscores are hookable. All about hooks. Take the HelloWorld.module and add this hook to the init() $this->addHookAfter('ProcessPageEdit::buildFormSettings', $this, 'buildFormSettings'); And then add this function to the class. public function buildFormSettings(HookEvent $event){ $fieldset = $event->return; // get the fieldwrapper returned $field = $fieldset->get("_pw_page_name"); // get the name field $field->collapsed = Inputfield::collapsedYes; } 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