【问题标题】:Override Orchard Setup view in Orchard CMS在 Orchard CMS 中覆盖 Orchard 设置视图
【发布时间】: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


    【解决方案1】:

    所以,这并不完全是我想要达到的目标,但它确实是。要覆盖在 Orachard 设置过程中使用的 IShellContextFactory,您可以使用 Host.config 文件。 示例:

       <autofac>
            <components>
                <component instance-scope="single-instance" type="YourModuleNamespace.ShellBuilders.CustomContextFactory, YourModuleName" service="Orchard.Environment.ShellBuilders.IShellContextFactory, Orchard.Framework" />
            </components>
       </autofac>
    

    至少您不必更改 Orchard 来源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-27
      • 1970-01-01
      相关资源
      最近更新 更多