+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Add button or action link to backend edit page

Add button or action link to backend edit page

4 posts, 0 answered
  1. Anthony
    Anthony avatar
    11 posts
    Registered:
    05 Mar 2015
    16 Apr 2015
    Link to this post

    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.

  2. Bonny
    Bonny avatar
    3 posts
    Registered:
    03 Sep 2012
    20 Apr 2015 in reply to Anthony
    Link to this post

    Hi Anthony,

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

    http://www.sitefinity.com/blogs/sabrie-nedzhip%27s-blog/2014/10/10/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.

  3. Anthony
    Anthony avatar
    11 posts
    Registered:
    05 Mar 2015
    20 Apr 2015
    Link to this post

    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)

  4. Bonny
    Bonny avatar
    3 posts
    Registered:
    03 Sep 2012
    22 Apr 2015 in reply to Anthony
    Link to this post

    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.

4 posts, 0 answered