gpt4 book ai didi

orchardcms - 向 Orchard CMS 媒体库添加自定义操作

转载 作者:行者123 更新时间:2023-12-01 13:42:40 25 4
gpt4 key购买 nike

我看到媒体库能够将形状附加到导航和操作。但是,我正在尝试弄清楚如何向这些 Action 添加一个 Action 形状,以便我可以将一个新按钮添加到媒体库中以调用我的模块中的一个 Action 。

来自媒体库 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 仍然有点太新了,但在我对使用形状和放置它们的理解上感觉像是一个洞。我认为呈现按钮的形状不需要涉及某个部分,因为没有要存储的内容?

最佳答案

我已经设法解决了这个问题。首先在 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());
}
}

然后放在Actions区

<Placement>
<Place Parts_MediaLibraryExplorer_MyActionShape="Actions:6" />
</Placement>

然后为带有按钮的形状创建模板 (Views/Parts/MediaLibraryExplorer.MyActionShape.cshtml) 以调用模块 Controller 操作:)

@Html.ActionLink(T("Click Me").Text, "Index", "Admin", new { area = "Orchard.MyModule" }, new { id = "click-me-link", @class = "button" })

这有多简单?!

关于orchardcms - 向 Orchard CMS 媒体库添加自定义操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38627957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com