【发布时间】:2017-09-05 02:51:09
【问题描述】:
我需要从 Orchard.Setup 模块扩展 SetupViewModel 以添加一些特定于我的 Web 应用程序的选项,以便它们与标准管理员用户名等一起显示在“欢迎来到 Orchard”设置屏幕上。 我已经使用 SetupController 和扩展视图模型创建了自己的模块,但 Orchard 仍然使用标准 Orchard.Setup 模块。 到目前为止我尝试过但没有运气: 1. OrchardSuppressDependency on Controller 在我的自定义模块中 2. 在我的自定义模块中使用优先级 101 路由 我发现如果您在 ShellContextFactory CreateSetupContext 方法中更改 ShallFeature 名称,您可以轻松地使用自己的模块进行安装:
public ShellContext CreateSetupContext(ShellSettings settings) {
Logger.Debug("No shell settings available. Creating shell context for setup");
var descriptor = new ShellDescriptor {
SerialNumber = -1,
Features = new[] {
new ShellFeature { Name = "YOUR_MODULE_NAME" },
new ShellFeature { Name = "Shapes" },
new ShellFeature { Name = "Orchard.jQuery" },
},
};
var blueprint = _compositionStrategy.Compose(settings, descriptor);
var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
return new ShellContext {
Settings = settings,
Descriptor = descriptor,
Blueprint = blueprint,
LifetimeScope = shellScope,
Shell = shellScope.Resolve<IOrchardShell>(),
};
}
但似乎我无法覆盖 IShellContextFactory,即使使用 OrchardSuppressDependency 至少出于设置目的。
关于如何在不更改 CMS 代码的情况下达到预期结果的任何想法?
Orchard 版本是 1.8.1。
【问题讨论】:
标签: asp.net-mvc orchardcms orchardcms-1.8