2

我在 Orchard 和主页上创建了一个主题,我想从一个模块呈现一个视图。

将要呈现的视图由两个模块确定。如果后者在 Orchard 中启用,则一个“默认”模块和另一个覆盖默认路由的模块。所以我最好想做的是在我的主题主页中以某种方式指定路由/url,并根据启用的模块呈现返回的视图依赖项。这可以在果园做吗?

我可以使用 AJAX 在加载时动态呈现视图,或者使用<iframe>指定的 url,但我宁愿使用“纯”Orchard 解决方案。

有什么建议么?

4

1 回答 1

1

Okey so I came up with the following solution thanks to Bertrand's comment.

@{
    try
    {
        Html.RenderAction("Register", new { controller = "Home", area = "Invites" });
    }
    catch (InvalidOperationException inviteException)
    {
        try
        {
            Html.RenderAction("Register", new { controller = "Home", area = "Users" });
        }
        catch (InvalidOperationException userException)
        {
            @Display(New.DownloadLink());
        }
    }
}

So first I try to render a registration form from Invites and if that module is disabled I try to render a registration form form Users. In the case that both modules are disabled a simple download link is displayed.

于 2012-09-12T08:58:14.300 回答