mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #5169 from Cheddam/patch-1
DOCS Update 'Extend CMS Interface' documentation
This commit is contained in:
commit
f28dcdbb2e
@ -190,14 +190,42 @@ We can also easily create new drop-up menus by defining new tabs within the
|
|||||||
Empty tabs will be automatically removed from the `FieldList` to prevent clutter.
|
Empty tabs will be automatically removed from the `FieldList` to prevent clutter.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
New actions will need associated controller handlers to work. You can use a
|
|
||||||
`LeftAndMainExtension` to provide one. Refer to [Controller documentation](../../controllers)
|
|
||||||
for instructions on setting up handlers.
|
|
||||||
|
|
||||||
To make the actions more user-friendly you can also use alternating buttons as
|
To make the actions more user-friendly you can also use alternating buttons as
|
||||||
detailed in the [CMS Alternating Button](cms_alternating_button)
|
detailed in the [CMS Alternating Button](cms_alternating_button)
|
||||||
how-to.
|
how-to.
|
||||||
|
|
||||||
|
### Implementing handlers
|
||||||
|
|
||||||
|
Your newly created buttons need handlers to bind to before they will do anything.
|
||||||
|
To implement these handlers, you will need to create a `LeftAndMainExtension` and add
|
||||||
|
applicable controller actions to it:
|
||||||
|
|
||||||
|
:::php
|
||||||
|
class CustomActionsExtension extends LeftAndMainExtension {
|
||||||
|
|
||||||
|
private static $allowed_actions = array(
|
||||||
|
'sampleAction'
|
||||||
|
);
|
||||||
|
|
||||||
|
public function sampleAction()
|
||||||
|
{
|
||||||
|
// Create the web
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
The extension then needs to be registered:
|
||||||
|
|
||||||
|
:::yaml
|
||||||
|
LeftAndMain:
|
||||||
|
extensions:
|
||||||
|
- CustomActionsExtension
|
||||||
|
|
||||||
|
You can now use these handlers with your buttons:
|
||||||
|
|
||||||
|
:::php
|
||||||
|
$fields->push(FormAction::create('sampleAction', 'Perform Sample Action'));
|
||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
In a few lines of code, we've customized the look and feel of the CMS.
|
In a few lines of code, we've customized the look and feel of the CMS.
|
||||||
|
Loading…
Reference in New Issue
Block a user