Using @Display(Model.ContentItems) and passing the view to use

Topics: Customizing Orchard
Sep 18, 2014 at 6:47 AM

Is there a way to pass the view you want to display with the Display(Model.ContentItems) method.

I'm working from a controller to display a list of items in the admin backend.

       public ActionResult Index()
            var list = Services.New.List();
                .Select(b =>
                    var chapter = Services.ContentManager.BuildDisplay(b, "SummaryAdmin");
                    return chapter;

            var viewModel = Services.New.ViewModel()
            return View(viewModel);

In the View I have this I would like to wrap an if around the display in order to have just that part of the page rendered differently (the bulk-actions part) remains the same.
  <fieldset class="bulk-actions">
            <label for="publishActions">@T("Actions:")</label>
            <select id="publishActions" name="Options.BulkAction">
                @Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.None, T("Choose action...").ToString())
                @Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Delete").ToString())
            @Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
            <button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
  <fieldset class="contentItems bulk-items">
Thanks for the help!
Sep 18, 2014 at 11:07 AM
Not sure what you mean. Do you want to display your Model.ContentItems in a different view?
You can use for example:
@Display.MyOtherView(Items: Model.ContentItems)
Then in a view called 'MyOtherView.cshtml' write your other stuff.
Marked as answer by RobinSoenen on 9/18/2014 at 4:20 AM
Sep 18, 2014 at 11:20 AM
Yes, thank you very much.