0
votes

Is it possible to make sitecore experience editor ribbon button trigger .aspx page in pop up window? It was possible before speak-ui was introduced by assigning a command to the button's click field.

There is a lot of tutorials describing how to use XML controls (e.g. http://jockstothecore.com/sitecore-8-ribbon-button-transfiguration/) but I can't find any information about triggering .aspx page.

My command looks like this: <command name="item:showDashboard" type="Sitecore.Starterkit.customcode.Reports, MyProject" />

1

1 Answers

2
votes

In the tutorial you posted I will just modify the code snippets to reflect what you need to do. (Considering you have done everything else). In the part Spell Two

In the command class you should do something like this (if you need to wait for postback):

        public override void Execute(CommandContext context)
        {
          Assert.ArgumentNotNull((object) context, "context");
          Context.ClientPage.Start((object) this, "Run", context.Parameters);
        }

        protected static void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull((object) args, "args");

            SheerResponse.ShowModalDialog(new UrlString("/YOURURL.aspx").ToString(), true);
            args.WaitForPostBack();          
        }

If you just want to show something :

        public override void Execute(CommandContext context)
        {

            Assert.ArgumentNotNull((object)context, "context");
            if (context.Items.Length != 1)
                return;
            Item obj = context.Items[0];
            UrlString urlString = new UrlString("/YOURURL.aspx");
            urlString["fo"] = obj.ID.ToString();
            urlString["la"] = obj.Language.ToString();
            urlString["vs"] = obj.Version.ToString();
            string str = "location=0,menubar=0,status=0,toolbar=0,resizable=1,getBestDialogSize:true";
            SheerResponse.Eval("scForm.showModalDialog('" + (object)urlString + "', 'SitecoreWebEditEditor', '" + str + "');");
        }

For the javascript:

define(["sitecore"], function (Sitecore) {
    Sitecore.Commands.ScoreLanguageTools = {
        canExecute: function (context) {
            return true; // we will get back to this one
        },
        execute: function (context) {
            var id = context.currentContext.itemId;
            var lang = context.currentContext.language;
            var ver = context.currentContext.version;

            var path = "/YOURURL.aspx?id=" + id + "&lang=" + lang + "&ver=" + ver;

            var features = "dialogHeight: 600px;dialogWidth: 500px;";

            Sitecore.ExperienceEditor.Dialogs.showModalDialog(
                path, '', features, null, 
                function (result) {
                    if (result) {
                        window.top.location.reload();
                    }
                }
            );
        }
    };
});