Enh: Add Snippets documentation

Add a few examples of snippets for the docs later can be changed however.
This commit is contained in:
Sarah Tsumayoi 2018-06-07 11:06:58 +09:00 committed by GitHub
parent 490bbaeedc
commit a72a928853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,58 @@
Snippets
=================
Snippets are self contained panels which can be added to the sidebar of for exaple the space or dashboard layout.
Snippets are self contained panels which can be added to the sidebar, for example the space, directory, or dashboard layout.
(TBD)
### Dashboard Layout
Adding the following in your module's `config.php` file will enable the view of your snippet on your dashboard.
```php
namespace humhub\modules\yourmodule;
use humhub\widgets\BaseMenu;
return [
'id' => 'yourmodule',
'class' => 'humhub\modules\yourmodule\Module',
'namespace' => 'humhub\modules\yourmodule',
'events' => [
['class' => humhub\modules\dashboard\widgets\Sidebar::className(), 'event' => BaseMenu::EVENT_INIT, 'callback' => ['humhub\modules\yourmodule\Module', 'onDashboardSidebarInit']],
],
];
```
### Space Layout
Adding the following in your module's `config.php` file will enable the view of your snippet in your Spaces.
```php
namespace humhub\modules\yourmodule;
use humhub\widgets\BaseMenu;
return [
'id' => 'yourmodule',
'class' => 'humhub\modules\yourmodule\Module',
'namespace' => 'humhub\modules\yourmodule',
'events' => [
['class' => humhub\modules\space\widgets\Sidebar::className(), 'event' => BaseMenu::EVENT_INIT, 'callback' => ['humhub\modules\yourmodule\Events', 'onSpaceSidebarInit']],
],
];
```
### Directory Layout
Adding the following in your module's `config.php` file will enable the view of your snippet in your Directory.
```php
namespace humhub\modules\yourmodule;
use humhub\widgets\BaseMenu;
return [
'id' => 'yourmodule',
'class' => 'humhub\modules\yourmodule\Module',
'namespace' => 'humhub\modules\yourmodule',
'events' => [
['class' => humhub\modules\directory\widgets\Sidebar::className(), 'event' => BaseMenu::EVENT_INIT, 'callback' => ['humhub\modules\yourmodule\Events', 'onDirectorySidebarInit']],
],
];
```