[Page save hook] #processwire #hooks
<?php
/**
* This will hook after any page save
*
*/
$this->addHook('Pages::saved', function(HookEvent $event) {
$page = $event->arguments[0];
if($page->template == "home") {
$this->warning($page->template->name);
}
});
// Auto-publish all pages having template "foo"
$wire->addHookAfter("Pages::saveReady('template=foo,id=0'), function($event) {
$event->arguments(0)->status = 1;
});
/**
* Page Save Hook
*
*/
public function init() {
$this->pages->addHookAfter('save', $this, 'exampleMethod');
}
public function exampleMethod($event) {
$page = $event->arguments[0];
$this->message("You just saved page: {$page->url}");
}