我看到媒体库能够将形状附加到导航和动作。但是,我试图找出如何为动作添加动作形状,以便我可以在媒体库中添加一个新按钮来调用我的模块中的动作。
来自媒体库AdminController.cs:
// let other modules enhance the ui by providing custom navigation and actions
var explorer = Services.ContentManager.New("MediaLibraryExplorer");
explorer.Weld(new MediaLibraryExplorerPart());
var explorerShape = Services.ContentManager.BuildDisplay(explorer);
var viewModel = new MediaManagerIndexViewModel {
CustomActionsShapes = explorerShape.Actions, // <-- I need to have my shape that is rendered as a button in here
};
Orchard还是太绿了,但感觉就像是我对使用形状和放置它们的理解中的漏洞。我不认为某个部分需要参与渲染按钮的形状,因为没有任何东西需要存储?
答案 0 :(得分:3)
我设法解决了这个问题。首先在MediaLibraryExplorerPartDriver中为MediaLibraryExplorerPart返回一个新形状
public class MediaLibraryExplorerPartDriver : ContentPartDriver<MediaLibraryExplorerPart> {
protected override DriverResult Display(MediaLibraryExplorerPart part, string displayType, dynamic shapeHelper) {
return ContentShape("Parts_MediaLibraryExplorer_MyActionShape", () => shapeHelper.Parts_MediaLibraryExplorer_MyActionShape());
}
}
然后放入动作区域
<Placement>
<Place Parts_MediaLibraryExplorer_MyActionShape="Actions:6" />
</Placement>
然后使用按钮创建模板(Views / Parts / MediaLibraryExplorer.MyActionShape.cshtml)以调用模块控制器操作:)
@Html.ActionLink(T("Click Me").Text, "Index", "Admin", new { area = "Orchard.MyModule" }, new { id = "click-me-link", @class = "button" })
那有多容易?!