-
-
Save josedigital/3177586 to your computer and use it in GitHub Desktop.
Revisions
-
somatonic created this gist
May 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ <?php /** * ProcessWire Module Template * * Demonstrates the Module interface and how to add hooks. * * ProcessWire 2.x * Copyright (C) 2010 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://www.processwire.com * http://www.ryancramer.com * */ class ModuleName extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'ModuleName', 'version' => 100, 'summary' => '', 'href' => '', 'singular' => true, 'autoload' => true ); } public function init() { // add a hook after each page is rendered and modify the output $this->addHookAfter('Page::render', $this, 'example2'); } public function example2($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; // add a "Hello World" paragraph right before the closing body tag $event->return = str_replace("</body>", "<p>Hello World!</p></body>", $event->return); } }