From a72a9288536231025a79a597d7927ede872cd758 Mon Sep 17 00:00:00 2001 From: Sarah Tsumayoi Date: Thu, 7 Jun 2018 11:06:58 +0900 Subject: [PATCH] Enh: Add Snippets documentation Add a few examples of snippets for the docs later can be changed however. --- .../humhub/docs/guide/developer/snippet.md | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/protected/humhub/docs/guide/developer/snippet.md b/protected/humhub/docs/guide/developer/snippet.md index 966f2156fa..4e3b32389b 100644 --- a/protected/humhub/docs/guide/developer/snippet.md +++ b/protected/humhub/docs/guide/developer/snippet.md @@ -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) \ No newline at end of file +### 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']], + ], +]; +```