Jump to content

How to modify/add the templates setting


Recommended Posts

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.module

If you need more specific help post it here. :)
 

Edited by LostKobrakai
fixed path
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...