Creating custom Extension For Groundhogg

You can create a custom extension for Groundhogg using custom extension template. You can download your copy of a template by clicking following link. The template contains various files which can be useful to build an extension.

groundhogg-extension

Groundhogg-extension is the main file of your extension. This file used to load all the loaders and setup all the essential path for the development of the plugin. This file also initializes loader. This file is well documented In case you want to change the name and define a custom path.

PlugIn Class

Plugin class is the most important class for the extension this is where initialization of the classes happens. This is an only class which is loaded by the main extension file. This class inherits Extension class of the Groundhogg and overwrites methods of the main class to hook custom code inside Groundhogg.

You can create an object of your custom class inside init_components method which gets called during the initialization process of extension.

This class also create an instance of autoloader class which is responsible for loading all files for the classes declared in the plugin file.

Autoloader Class

Autoloader class is another important class of extension. This class is responsible for loading all files which contain classes. Autoloader uses namespace structure for loading file Thus, implementation of namespaces is inevitable for custom development. Files are loaded when the object of the class gets created.

To cite an example: If you want to load contact file available in follwing location.

then namespace declaration for contact file looks like follows.

NOTE: Autoloader support dashes and lowercase file name only. If your file name does not satisfy this condition or you don’t have class in your file then you can manually load a file using includes method of Plugin Class.

Other Classes

Groundhogg extension contains templates for other classes which you can use to further integrate your extension with Groundhogg. You can create updater for your extension which inherits the Updater class of Groundhogg, You can also Implement installer which deals with the initial installation process. Apart from that, you can also create custom roles for the marketers and sales manager using roles class as well.

Was this article helpful to you? Yes No

How can we help?