-
Notifications
You must be signed in to change notification settings - Fork 22
Mod_Development
grangeway edited this page Jan 25, 2014
·
1 revision
Introduction There are three main goals for a mod:
Add a new page or completely replace an existing one Add a new option replace and existing one on particular pages Alter the board's functioning This page covers the basics you need to achieve each of these goals. The basic mods included with EDK give more examples on how to create mods.
Replacing a page or adding a new one Replacing a page or adding a new is as simple as adding a php file with the same name in your mod's directory. e.g. Create a directory under mod/ named "new_mod". Create a file in it named "home.php" and add these contents:
addMenuItem("caption","New Mod!"); $object->addMenuItem("link", "New View", "?a=home&view=newmod2"); } public static function addView(&$object) { $object->addView('newmod2', "newmod2::newstuff2"); } public static function newstuff2(&$object) { return ""; } } We've added two features to the home page. First is our own section in the menu with a link to our new stuff. Second is a new view that replaces the table of kills. As before, activate your new mod from your board's admin panel. Browse to your killboard's home page and you will see the new menu. (If you don't, make sure to disable page caching so that you can see your changes.) You should now see a new entry in the menu on the home page. Click on it to see the new feature. Alter the board's functioning Sometimes you want to change the way the board does something behind the scenes. You can't simply replace a page or add a new section as your changes affect the core code used by any page. What you need to do is either replace parts of the core code completely or insert your own code where needed. There are two features that you might use. First is to replace a core class with your own. Second is to use the event handler to call your code when needed. Replacing core classes Replacing a core class, assuming it hasn't already loaded, is easily accomplished. The hard part is making sure nothing outside your mod breaks, and that you keep up with changes to the core. To demonstrate replacing classes we're going to create a debug class that will tell us what tried to create a Killlist. Disable the new_mod and new_mod2 from the previous sections, if they're still active. Create a directory under mod/ named "new_mod3". Create a file in it named "init.php" and add these contents: setTitle("Public - ".$page->getTitle()); } } The event we registered for resets the page title when the page is assembled. We then put our new value for the classified period into the config. Note that 'put' is not the same as 'set'. 'put' variables are not stored permanently.