kreativmonkey Posted January 9, 2016 Share Posted January 9, 2016 Hi, i would like to modify the template settings pages and add some options for a notification module. How can i do that and how can i get this information back in the module? Thanks for your help! Link to comment Share on other sites More sharing options...
kixe Posted January 10, 2016 Share Posted January 10, 2016 (edited) Hi kreativmonkey, did you read the tutorials about creating modules? https://processwire.com/api/modules/or how to use hooks? https://processwire.com/api/hooks/If so, create a module which hooks in the hookable method, which you want to modify for your needs.Have a look inside: /wire/modules/Process/ProcessTemplate/ProcessTemplate.moduleIf you need more specific help post it here. Edited January 10, 2016 by LostKobrakai fixed path Link to comment Share on other sites More sharing options...
kreativmonkey Posted January 11, 2016 Author Share Posted January 11, 2016 I think i found the right hook to add some settings to the templates edit Page: protected function ___buildEditForm(Template $template) { so i can use .... addHookBefore('ProcessTemplate::buildEditForm', buildEditForm($event)) .... protectet function buildEditForm(Template $template) { $t = new InputfieldWrapper(); $t->attr('title', $this->_x('Notification', 'tab')); // $t->head = $this->_('Optional usage and placement in the page tree'); $t->attr('class', 'WireTab'); $t->attr('id', 'tab_notification'); $t->add($this->buildEditFormNotification($template)); $form->add($t); ...} protected function buildeditFormNotification(Template $template){ ....} do i need to Hook the executeSave() to save my fields? Is addHookBefore the right one ore do i need addHook ore addHookAfter?.... Thanks for your help! Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 11, 2016 Share Posted January 11, 2016 You probably want to use addHookAfter and add just your additions to the returned form object. With the other hooks you cannot modify the form, as it's created inside the function. Also make sure you're getting your hooks correct. Either use a function (without parameters) or a anonymous function. Also the function does not receive a template anymore, but the $event variable. Here you've an example using an anonymous function to add a new field into the form: https://processwire.com/talk/topic/11069-sorting-images-in-backend/?p=103687 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