Add button or action link to backend edit page

Posted by Community Admin on 04-Aug-2018 21:05

Add button or action link to backend edit page

All Replies

Posted by Community Admin on 16-Apr-2015 00:00

I need to add a button (next to publish button) or in the actions menu of the edit document page in the back end that performs a publish along with site syncing that document ("Publish and Sync"). I have the code to work the the FluentAPI and sync the document through SIteSync, but I am confused on how to add the button/link and perform the action.

I believe I found how to add the button/link in the back end (please see screenshot attached), but need to know exactly how it should be setup so it displays the button or link, and so I can perform the appropriate action when it is clicked.

 

Any help would be appreciated. Thanks.

Posted by Community Admin on 20-Apr-2015 00:00

Hi Anthony,

To add additional button in the actions menu, you can use this article:

www.sitefinity.com/.../extend-the-sitefinity-back-end-forms-grid-and-include-an-action-to-display-subscribers

Then in the service you can use the SiteSync API to schedule sync for the document.

Please try this and get back to us if you have any problems with it.

Posted by Community Admin on 20-Apr-2015 00:00

Hi Bonny, thanks for the response.

 We were told by Sitefinity Support that Documents is the one content type that cannot have an action added to it in the Document List grid in the back end; so I don't think that solution will work for Documents. Is that true?

 Additionally, while it would be great to also have the ability to add a link to the actions on the grid view, the client also wants to be able to add a button on the edit document screen next to the Publish and Save as Draft buttons. Is there a guide on how to be able to add an additional button to this section? (in the screenshot in my original post)

Posted by Community Admin on 22-Apr-2015 00:00

Hi Anthony,

Here are the steps you need to follow:

1. Using this article to extend the default media content workflow called "AnyMediaContentApprovalWorkflow.xamlx" and using the workflow editor in ContentApproval->Default add new decision activity called "Sync" with command name "sync" (you can just copy and paste the preview activity). Check out this video.

2. When you go to the edit screen you will see an additional button called "Sync". Now we need to handle the command from this button. I have ​prepared the script that handles it - you can use it:

$(window).load(function ()
    if (detailFormView._widgetBarIds)
        var wLength = detailFormView._widgetBarIds.length;
        for (var wCounter = 0; wCounter < wLength; wCounter++)
            var widget = $find(detailFormView._widgetBarIds[wCounter]);
            if (widget !== null)
                widget.add_command(function (sender, args)
                    if (args._commandName == "sync")
                        var dataItem = detailFormView.get_dataItem();
                        // call some service to publish and sync the item using the API.
                    
                );
            
        
    
);

Register the script in Settings>Advanced>Libraries>Controls>DucumentsBackend>Views>DocumentsBackendEdit>Scripts. Remember to set the "Name of the load method" to "OnDetailViewLoaded".

The workflow modification will display the "Sync" button and the script will handle it. You can create a service that you can call to publish and sync the item.

Please tell me if there are any problems with this approach.

This thread is closed