Search code examples
orchardcmsorchardcms-1.6orchardcms-1.8orchard-modulesorchardcms-1.9

Create New Page in Orchard Module


How do I create a new page in orchard module? I have one page and controller in orchard, but how to add a new page in the route module?

        public IEnumerable<RouteDescriptor> GetRoutes() {
        return new[] {
            new RouteDescriptor {
                Priority = 5,
                Route = new Route(
                    "BlogX", // this is the name of the page url
                    new RouteValueDictionary {
                        {"area", "BlogX"}, // this is the name of your module
                        {"controller", "Home"},
                        {"action", "Index"}
                    },
                    new RouteValueDictionary(),
                    new RouteValueDictionary {
                        {"area", "BlogX"} // this is the name of your module
                    },
                    new MvcRouteHandler())
            }
        };
    }

Solution

  • This should be easy. Inject an instance of Orchard.ContentManagement.IContentManager to your controller and then simply call ContentManager.New("YourContentType"). Also have a look at the other methods available for the content manager like Publish() which you may need to call also.