User Tools

Site Tools


orchard_create_page

This is an old revision of the document!


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.CurrentUser;
 
    var fooRoute = fooPage.As<AutoroutePart>();
    fooRoute.DisplayAlias = "Foo";
    _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 = "1000";
 
    _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.1420603054.txt.gz · Last modified: 2017/01/01 19:50 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki