Captain Hook

ProcessWire Hooks Cheatsheet 0.3 [infos]

Hooks

Hooks can be set anywhere in modules or template code using a simple syntax. They can be either before or after a event/method happening in PW. There's also way to using addHook to add a new property or method to an existing template variable. Look at the HelloWorld.module that ships with ProcessWire to see examples of it (HelloWorld.module)

All methods in PW that have a ___ prefix can be hooked on either before or after.

Hook in Modules:

$this->addHookBefore('ClassName::method', $this, 'yourLocalMethod');
$this->addHookAfter('ClassName::method', $this, 'yourLocalMethod');

Hook in Templates:

$object->addHookBefore('method', null, 'yourLocalMethod');
$object->addHookAfter('method', null, 'yourLocalMethod');

Where $object can be either a template variable like $page, $pages, $fields, $templates etc. Or an instance of a module you load before with $modules->get("ModuleName");

HookEvent

Instances of HookEvent are passed to Hook handlers when their requested method has been called.

public function yourLocalMethod(HookEvent $event){
  $output = $event->return;
}

Get some more info about it: HookEvent.php

Useful Links

About this

This list is generated from the latest dev branch of ProcessWire dev branch.

Files: 118 | Hooks Total: 435

/wire/core/Field.php

/wire/core/Fieldgroup.php

/wire/core/Fieldgroups.php

/wire/core/Fields.php

/wire/core/Fieldtype.php

/wire/core/FieldtypeMulti.php

/wire/core/ImageSizer.php

/wire/core/Inputfield.php

/wire/core/InputfieldWrapper.php

/wire/core/Interfaces.php

/wire/core/Module.php

/wire/core/ModuleJS.php

/wire/core/ModulePlaceholder.php

/wire/core/Modules.php

/wire/core/NullPage.php

/wire/core/Page.php

/wire/core/PageExport.php

/wire/core/Pagefile.php

/wire/core/Pagefiles.php

/wire/core/PagefilesManager.php

/wire/core/PageFinder.php

/wire/core/Pageimage.php

/wire/core/Pages.php

/wire/core/PagesType.php

/wire/core/Password.php

/wire/core/Process.php

/wire/core/ProcessController.php

/wire/core/Session.php

/wire/core/TemplateFile.php

/wire/core/Templates.php

/wire/core/Textformatter.php

/wire/core/Wire.php

/wire/core/WireLog.php

/wire/core/WireSaveableItems.php

/wire/core/WireSaveableItemsLookup.php

/wire/modules/Fieldtype/FieldtypeCache.module

/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module

/wire/modules/Fieldtype/FieldtypeComments/InputfieldCommentsAdmin.module

/wire/modules/Fieldtype/FieldtypeDatetime.module

/wire/modules/Fieldtype/FieldtypeFieldsetClose.module

/wire/modules/Fieldtype/FieldtypeFieldsetOpen.module

/wire/modules/Fieldtype/FieldtypeFieldsetTabOpen.module

/wire/modules/Fieldtype/FieldtypeFile.module

/wire/modules/Fieldtype/FieldtypeFloat.module

/wire/modules/Fieldtype/FieldtypeInteger.module

/wire/modules/Fieldtype/FieldtypeModule.module

/wire/modules/Fieldtype/FieldtypePage.module

/wire/modules/Fieldtype/FieldtypePageTitle.module

/wire/modules/Fieldtype/FieldtypePassword.module

/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module

/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module

/wire/modules/Fieldtype/FieldtypeText.module

/wire/modules/Fieldtype/FieldtypeTextarea.module

/wire/modules/Fieldtype/FieldtypeURL.module

/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module

/wire/modules/Inputfield/InputfieldButton.module

/wire/modules/Inputfield/InputfieldCheckbox.module

/wire/modules/Inputfield/InputfieldCheckboxes/InputfieldCheckboxes.module

/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module

/wire/modules/Inputfield/InputfieldEmail.module

/wire/modules/Inputfield/InputfieldFieldset.module

/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module

/wire/modules/Inputfield/InputfieldForm.module

/wire/modules/Inputfield/InputfieldHidden.module

/wire/modules/Inputfield/InputfieldImage/InputfieldImage.module

/wire/modules/Inputfield/InputfieldInteger.module

/wire/modules/Inputfield/InputfieldMarkup.module

/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module

/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module

/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelect.module

/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelectMultiple.module

/wire/modules/Inputfield/InputfieldPageName/InputfieldPageName.module

/wire/modules/Inputfield/InputfieldPassword.module

/wire/modules/Inputfield/InputfieldRadios/InputfieldRadios.module

/wire/modules/Inputfield/InputfieldSelect.module

/wire/modules/Inputfield/InputfieldSelectMultiple.module

/wire/modules/Inputfield/InputfieldSubmit/InputfieldSubmit.module

/wire/modules/Inputfield/InputfieldText.module

/wire/modules/Inputfield/InputfieldTextarea.module

/wire/modules/Inputfield/InputfieldTinyMCE/InputfieldTinyMCE.module

/wire/modules/Inputfield/InputfieldURL.module

/wire/modules/LanguageSupport/FieldtypePageTitleLanguage.module

/wire/modules/LanguageSupport/Languages.php

/wire/modules/LanguageSupport/LanguageSupport.module

/wire/modules/LanguageSupport/LanguageSupportFields.module

/wire/modules/LanguageSupport/LanguageSupportInstall.php

/wire/modules/LanguageSupport/LanguageSupportPageNames.module

/wire/modules/LanguageSupport/LanguageTranslator.php

/wire/modules/LanguageSupport/ProcessLanguageTranslator.module

/wire/modules/LazyCron.module

/wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module

/wire/modules/Markup/MarkupCache.module

/wire/modules/Markup/MarkupPagerNav/MarkupPagerNav.module

/wire/modules/PagePathHistory.module

/wire/modules/PagePaths.module

/wire/modules/PageRender.module

/wire/modules/Process/ProcessField/ProcessField.module

/wire/modules/Process/ProcessForgotPassword.module

/wire/modules/Process/ProcessHome.module

/wire/modules/Process/ProcessList.module

/wire/modules/Process/ProcessLogin/ProcessLogin.module

/wire/modules/Process/ProcessModule/ProcessModule.module

/wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module

/wire/modules/Process/ProcessPageClone.module

/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module

/wire/modules/Process/ProcessPageEditImageSelect/ProcessPageEditImageSelect.module

/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module

/wire/modules/Process/ProcessPageList/ProcessPageList.module

/wire/modules/Process/ProcessPageSearch/ProcessPageSearch.module

/wire/modules/Process/ProcessPageSort.module

/wire/modules/Process/ProcessPageTrash.module

/wire/modules/Process/ProcessPageType/ProcessPageType.module

/wire/modules/Process/ProcessPageView.module

/wire/modules/Process/ProcessProfile/ProcessProfile.module

/wire/modules/Process/ProcessTemplate/ProcessTemplate.module

/wire/modules/Session/SessionHandlerDB/ProcessSessionDB.module

/wire/modules/Session/SessionHandlerDB/SessionHandlerDB.module

/wire/modules/Session/SessionLoginThrottle/SessionLoginThrottle.module