From 47179fc808edc863459574172b33658bc58e8d63 Mon Sep 17 00:00:00 2001 From: Garion Date: Thu, 10 Mar 2016 01:02:28 +1300 Subject: [PATCH 1/2] Update Extend_CMS_Interface.md Resurfaces details on actually creating the required handlers for custom buttons in the CMS, which were detailed in a [past version of the docs](https://github.com/silverstripe-droptables/sapphire/blob/side-by-side/docs/en/howto/extend-cms-interface.md#extending-the-cms-actions). --- .../How_Tos/Extend_CMS_Interface.md | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md index 4aa89c14e..df83442ed 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md @@ -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. -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 detailed in the [CMS Alternating Button](cms_alternating_button) 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 { + + 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 In a few lines of code, we've customized the look and feel of the CMS. From c59cd1e59848bb4b77ba3218c1cc2428faeb3c18 Mon Sep 17 00:00:00 2001 From: Garion Date: Sun, 20 Mar 2016 13:08:23 +1300 Subject: [PATCH 2/2] Update Extend_CMS_Interface.md Add missing `private` declaration. --- .../How_Tos/Extend_CMS_Interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md index df83442ed..d08cdb388 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Extend_CMS_Interface.md @@ -203,7 +203,7 @@ applicable controller actions to it: :::php class CustomActionsExtension extends LeftAndMainExtension { - static $allowed_actions = array( + private static $allowed_actions = array( 'sampleAction' );