This project is read-only.

Orchard CMS rendering parts outside of admin section.

Topics: Core, Customizing Orchard
Apr 15, 2016 at 6:24 AM
I am working on a module. The one change I want to do is, rendering the product creation outside of admin module. So I created ProductListController like this
public class ProductListController : Controller
 public ActionResult Index() {
        return Content("This is index");
    public ActionResult Create()
        var model = "...");
        return View(model);
and my custom element view i have added like this
@using Orchard.Utility.Extensions
@using Orchard.Layouts.Helpers
@model ProductList.Models.ProductList

    <label class="sub" for="Sku">@T("Sku")</label><br />
    @Html.TextBoxFor(m => m.Sku, new { @class = "text" })<br />
    <label class="sub" for="Price">@T("Price")</label><br />
    @Html.TextBoxFor(m => m.Price, new { @class = "text" })
Now it throws an error saying
System.InvalidOperationException: The model item passed into the dictionary is of type 'Orchard.UI.Zones.ZoneHolding', but this dictionary requires a model item of type 'ProductList.Models.ProductList'.
Thanking you.
Apr 15, 2016 at 8:22 PM
What's the model type that you pass into the view? Sounds like it is not a ProductList.
Apr 18, 2016 at 5:38 AM

Actually i have two DB's, 1st one is Orchard DB and 2nd one is our main DB. 2nd one is containing our all product details. So i need to show all the data from 2nd DB to Orchard element view.

In previously i have done like, created new cshtml view for ProductList under Views->ProductList->ProductList and added Route in routes.cs like
namespace ProductList
    public class Routes : IRouteProvider
        #region Implementation of IRouteProvider

        public IEnumerable<RouteDescriptor> GetRoutes()
            return new[] {
                new RouteDescriptor {
                    Route = new Route(
                        new RouteValueDictionary {
                            {"area", "ProductList"},
                            {"id", UrlParameter.Optional}
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "ProductList"}
                        new MvcRouteHandler())

        public void GetRoutes(ICollection<RouteDescriptor> routes)
            foreach (var descriptor in GetRoutes())

and created one new element under Views->Elements->ProductListElement and loaded ProductList view to ProductListElement view through jQuery like
@using Orchard.Utility.Extensions
@using Orchard.Layouts.Helpers
@using ProductList.Elements

    var element = (ProductListElement)Model.Element;
    Session["productListPageName"] = element.PageName;

<div id="productListElementPartialView"> </div>

@using (Script.Foot())
        $(document).ready(function () {
Now i need to load that data directly to element view without ProductList.cshtml