2015-03-24 54 views
1

我有一个Sitecore中的页面编辑器的自定义体验按钮,它引用了自定义命令。从这个上下文中打开SPEAK对话框的正确方法是什么?应该如何设置对话框的宽度/高度?从WebEdit命令打开时,Sitecore设置SPEAK UI对话框大小

我有以下命令代码:

public class MySpecialCommand : Sitecore.Shell.Applications.WebEdit.Commands.WebEditCommand 
{ 
    public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context) 
    { 
     var parameters = new NameValueCollection(); 
     //add various parameters etc 
     Context.ClientPage.Start((object) this, "Run", parameters); 
    } 

    protected void Run(ClientPipelineArgs args) 
    { 
     if (!args.IsPostBack) 
     {   
      string url = "/sitecore/client/your%20apps/somespeakdialog?sc_lang=en&someParam" + args.Parameters["someParam"]; 
      SheerResponse.ShowModalDialog(url, "100", "200", string.Empty, true); 
      args.WaitForPostBack(); 
     } 
     else if (args.HasResult) 
     { 
      //not got this far yet... 
     } 
    } 
} 

,我发现对话框的大小没有任何相似之处到widthheight参数传递给SheerResponse.ShowModalDialog。我也尝试传递后缀为“px”的值,但这没有帮助。

+0

您使用的是什么版本的Sitecore?我刚刚在8中试过了你的代码,它正确地呈现了Sheer对话框,并且它的高度为 – 2015-03-25 20:00:45

+0

。我目前在7.5上,但由于这只是一个概念证明,所以我可以考虑升级到8.我注意到你提到过纯粹的对话框 - 我正在使用SPEAK UI对话框,所以这里可能有一些区别? – 2015-03-25 20:28:54

+0

您正在使用SheerResponse.ShowModalDialog,因此它是纯粹的,Sitecore仍然部分地使用Sheer和SPEAK,这是其中一个实例。如果它是一个概念验证,它会为您节省8个麻烦 – 2015-03-25 21:26:57

回答

3

没有现成的能力来设置宽度和高度为基础SPEAK的对话框中Sitecore的7.5(它在8.0可用)

但是,你可以自定义\ Sitecore的\壳\控制\ jQueryModalDialogs.html文件。只要找到并更新以下if声明:

if (isSpeakDialog) { 
    createdDialog.dialog('option', 'width', size.width); 
    createdDialog.dialog('option', 'height', size.height); 
} 

在Sitecore的8.0的新方法已经被添加:

public static ClientCommand ShowModalDialog(ModalDialogOptions options) 

SheerResponse.ShowModalDialog(url, "100", "200", string.Empty, true);

SheerResponse.ShowModalDialog(new ModalDialogOptions(url) 
{ 
    Width = "100", 
    Height = "200", 
    Response = true, 
    ForceDialogSize = true 
}); 

说明ForceDialogSize属性:

获取或设置一个值,该值指示SPEAK对话框是否将采取 acount <请参阅cref =“Width”/ >和<请参阅cref =“Height”/ >。