orchard_create_page
Orchard Create Page
public int UpdateFrom2() { // Create Foo page and attach to menu. var fooPage = _contentManager.Create("Page"); fooPage.As<TitlePart>().Title = "Foo"; fooPage.As<BodyPart>().Text = @"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mauris magna, varius vel vulputate eget, bibendum id magna.</p>"; fooPage.As<CommonPart>().Owner = _orchardServices.WorkContext == null ? null : _orchardServices.WorkContext.CurrentUser; var fooRoute = fooPage.As<AutoroutePart>(); fooRoute.DisplayAlias = _autorouteService.GenerateAlias(fooRoute); _autorouteService.PublishAlias(fooRoute); var menu = _menuService.GetMenu("Main Menu"); if (menu == null) throw new Exception("Could not get the menu. Please the name of the menu is correct."); fooPage.As<MenuPart>().Menu = menu; fooPage.As<MenuPart>().MenuText = "Article"; fooPage.As<MenuPart>().MenuPosition = "10"; _contentManager.Publish(fooPage); // Create Foo layer var fooLayer = _widgetsService.CreateLayer("Foo", "The widgets in this layer will be displayed on the Foo page", "url('~/Foo')"); _contentManager.Publish(fooLayer.ContentItem); return 3; }
orchard_create_page.txt · Last modified: 2017/01/01 20:05 by 127.0.0.1