Module installation Fluent API

Sitefinity allows you to use the Fluent API when installing a module.

This section contains the following:

Module installation facade

When using the Fluent API to install a module, you use the module install facade.

To get the module install facade, use App.WorkWith().Module(moduleName, pageManager).Install().

The ModuleInstallFacade class provides the following methods:

  • CreateModuleGroupPage - provides Fluent API for creating a new module node. The method accepts the ID and the name of the module node. It returns a module node facade that you use to create the node.

  • CreateModulePage - provides Fluent API for creating a new module page. The method accepts the ID and the name of the module page. It returns a module page facade that you use to create the page.

  • RegisterControlTemplate - registers a control template.

Module node facade

You use the module node facade to create a module node.

The ModuleNodeFacade class allows you to:

  • set the title, URL name and description of the node

  • control the visibility of the node

  • set the order and parent of the node

  • add and remove attributes

  • add child groups or pages

To add a page to the node, you use the module page facade.

Module page facade

You use the module page facade to create a module page.

The ModulePageFacade class allows you to:

  • set the title, URL name and description of the page

  • include or exclude script managers

  • control the visibility of the page

  • set the order, parent and template of the page

  • add controls to the page

Installing a module

This example installs the custom module by creating the module node and page:

protected override void InstallPages( SiteInitializer initializer )
{
    App.WorkWith()
        .Module( "MyCustomModule", initializer.PageManager )
        .Install()
            .CreateModuleGroupPage( MyCustomModulePageGroupId, "MyCustomModulePageGroupName" )
                .PlaceUnder( CommonNode.TypesOfContent )
                .SetOrdinal( 1 )
                .LocalizeUsing<MyCustomModuleResources>()
                .SetTitleLocalized( "ModuleTitle" )
                .SetUrlNameLocalized( "PageGroupNodeTitle" )
                .SetDescriptionLocalized( "PageGroupNodeDescription" )
                .AddChildPage( MyCustomModuleHomePageId, "MyCustomModuleHomePageName" )
                    .LocalizeUsing<MyCustomModuleResources>()
                    .SetTitleLocalized( "ModuleTitle" )
                    .SetUrlNameLocalized( "MyCustomModuleUrlName" )
                    .SetDescriptionLocalized( "MyCustomModuleDescription" )
                    .SetHtmlTitleLocalized( "MyCustomModuleHtmlTitle" )
                    .AddControl( myControl )
                    .Done()
                .Done()
                .RegisterControlTemplate<MasterView>( myTemplateName, myViewName );
}

You place your code in the InstallPages override method. First, you get the module installation facade. You create the module node and specify its properties and placement. Then, you create the module home page and its properties and add a control to the page. Finally, you register the control template.

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK