2
votes

I have created a theme in Orchard and on the homepage I want to render a view from a module.

The view that is going to be rendered is determined by two modules. One "default" module and another one that overrides the routes of the default one if the latter is enabled in Orchard. So what I preferably want to do is to somehow specify the route/url in the homepage of my theme and render the returned view dependend on the enabled module. Is this possible to do in Orchard?

I could use AJAX to dynamically render the view upon loading or use an <iframe> and specficy the url but I would rather use a "pure" Orchard solution.

Any suggestions?

1
@BertrandLeRoy That sort of works but wouldn't I have to specify the controller and area then? Like @{ Html.RenderAction("Register", new {controller = "Home", area = "Users"}) } or @{ Html.RenderAction("Register", new {controller = "Home", area = "Invites"}) } dependent on which registration form that I want to use? What I would want is to get/push a registration form from/into the homepage. The form from Invites should be used if that module is enabled, otherwise the form from Users should be used.Mattias
Yes, so? Some code, somewhere is going to have to know what you want. It can't magically read what you have in mind. Sooner or later, you'll have to be specific about what exactly you want to render.Bertrand Le Roy

1 Answers

1
votes

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.