Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update widgets.md #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 81 additions & 3 deletions extend/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,13 +18,93 @@ 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'
];
}


Comment on lines +21 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a descriptive name.. QuickLinks?

{

/**
* @var string A unique alias to identify this widget.
*/
protected $defaultAlias = 'PluginName';

public function render()
{
$this->prepareVars();

return $this->makePartial('partials/quicklinks');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be quicklinks/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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here quicklinks/quicklinks.blade.php


You can then display any html code you like.

<a href="MyLink"> My Link in my Widget </a>



You can now go to your Dashboard and select your widget from the drop down.

### Dashboard widget properties

### Dashboard widget registration

## AJAX handlers

##
##