Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (44 sloc) 1.39 KB
<?php
/**
* HelloUserYouSaved (0.0.1)
* HelloUserYouSaved shows messages after actions in PW
*
* @author Ben Byford
*
* Hookable functions: ___helloMessage
*
* ProcessWire 2.x
* Copyright (C) 2011 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
* http://www.processwire.com
* http://www.ryancramer.com
*
*/
class HelloUserYouSaved extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => "HelloUserYouSaved",
'version' => "0.0.1",
'summary' => "HelloUserYouSaved shows messages after actions in PW",
'author' => "Ben Byford",
'href' => "https://github.com/benbyford/PW-starter-modules/tree/master/HelloUserYouSaved",
'icon' => "bell",
// use autoload if module is to be called each load, if it is only needed to setup something set to false
'autoload' => true,
'singular' => false,
'requires' => "ProcessWire>=2.5",
);
}
public function init() {
// add hook within class and point to custom function helloMessage
$this->addHookAfter("Pages::save", $this, "helloMessage");
}
public function ___helloMessage($event) {
// Get the soon to be saved page object from the given event
$page = $event->arguments[0];
// use message() to send hello alert to PW
// alert will be shown after any admin page saved
$this->message("Hello {$this->user->name}! You saved {$page->name}.");
}
}