From dc2d751587d92b70aef1d76b6b0e140dcd7288a3 Mon Sep 17 00:00:00 2001 From: James Hanna <57585482+JamesThanna@users.noreply.github.com> Date: Thu, 29 Apr 2021 23:32:30 +0100 Subject: [PATCH] Update widgets.md --- extend/widgets.md | 84 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) diff --git a/extend/widgets.md b/extend/widgets.md index 1cd4e3c..bf8a437 100644 --- a/extend/widgets.md +++ b/extend/widgets.md @@ -9,8 +9,6 @@ callout: This section is incomplete. Please help to improve it. ## Defining a generic widget -### Widget class - ## Defining a form widget ### Form widget class @@ -20,8 +18,88 @@ callout: This section is incomplete. Please help to improve it. ### Form widget registration ## Defining a dashboard widget +First Create your Extension +https://tastyigniter.com/docs/master/extend/extensions + +Extension.php +``` + public function extensionMeta() + { + return [ + 'name' => 'My Widget Extension', + 'author' => 'Docs', + 'description' => 'No description provided yet...', + 'icon' => 'fa-plug', + 'version' => '1.0.0' + ]; + } + + +public function registerDashboardWidgets() { + + return [ + 'TastyExt\PluginName\ControllerPath' => [ + 'label' => 'Name Of Widget', + 'context' => 'My Content', + ], + + + ]; + + } + ``` ### Dashboard widget class +```use Admin\Classes\BaseDashboardWidget; +class ControllerPath extends BaseDashboardWidget +{ + + /** + * @var string A unique alias to identify this widget. + */ + protected $defaultAlias = 'PluginName'; + + public function render() + { + $this->prepareVars(); + + return $this->makePartial('partials/quicklinks'); + /* This would be your blade file with to display your html */ + } + + public function defineProperties() + { + return [ + 'title' => [ + 'label' => 'Property One', + 'default' => 'test', + 'type' => 'text', + ] + ]; + } + + protected function prepareVars() + { + + $this->vars['exampleVar'] = "Some Var"; + } + +} +``` + +## Adding Content to Widget + + +Inside + partials/myblade.blade.php + +You can then display any html code you like. + + My Link in my Widget + + + +You can now go to your Dashboard and select your widget from the drop down. ### Dashboard widget properties @@ -29,4 +107,4 @@ callout: This section is incomplete. Please help to improve it. ## AJAX handlers -## \ No newline at end of file +##