Skip to content

Plugins

Timot Tarjani edited this page Jan 17, 2017 · 15 revisions

###Plugin structure

Plugins are in the plugins dir. The plugin dir should be PSR-2 compatible, because the system loads the plugin by namespace. The plugin should contain a theme_info.xml file and Register.php file.

You always have to install the plugin to be able to use it. The installer will run the plugin migration and seeding from the plugin's database folder. Plugins are executed only if their status is active.

###Plugin Register file. In the Register.php file you can specify components that the system should load automatically.

####Extending the menu In Register.php create a public static method called navigation. It must return an array with the menu items information.

For example:

public static function navigation(){
		return [
			'googlemaps' => [
					'label' => 'Google Maps',
					'url' => 'admin/plugin/run/googlemaps',
					'submenu_of' => 'pages'
					]
		];
}

####Hooking

Laravel eventing is so powerful. HorizontCMS grabs this tool to be able to extend the core functions with plugins. You can register listeners for any of the events.

Example:

public static function eventHooks(){
		return [
			'ExampleEvent' => [
				          'Plugin\GoogleMaps\App\Listeners\ExampleListener@exampleMethod',
			        ]
		];
}

Clone this wiki locally