-
Notifications
You must be signed in to change notification settings - Fork 20
Plugins
For plugin development, we recommend to use DeveloperKit plugin. It can be downloaded from HCMS Store on the plugin page.
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 plugin_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.
Composer can be used for plugins too. The system's main composer has a merge plugin. You just have to run update on the main composer.json and all of the dependencies will be installed.
However it's recommended to set the plugin's vendor path to the system's vendor and run composer inside the plugin.
In the Register.php file you can specify components that the system should load automatically.
In Register.php
create a public static
method called navigation
. It must return an array
with the menu items information.
Example:
public static function navigation(){
return [
'googlemaps' => [
'label' => 'Google Maps',
'url' => plugin_link('google-maps/start/index'),
'submenu_of' => 'pages'
]
];
}
Laravel eventing is 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',
]
];
}
You can register frontend widgets. Than you can resolve them with {[plugin_name]}
shortcode from a single page. You can return blade views and strings too.
Example:
public static function widget(){
return view('plugin::widget.widget',[
'locations' => \Plugin\GoogleMaps\App\Model\Location::all(),
'api_key' => \Settings::get('gmaps_api_key'),
'zoom' => \Settings::get('gmaps_zoom'),
'type' => \Settings::get('gmaps_type'),
'animation' => 'BOUNCE',
]);
//return "Try mee too!";
}
You can inject JavaScript into the theme with the following code in the
section: <head>
....
<?php Website::jsPlugins(); ?>
</head>
Project started in 2015