Using CreateModulePage instead of CreatePageFromConfiguration
I noticed when building a solution that it was warning me about CreatePageFromConfiguration being obsolete and to use App.WorkWith().Module().Install() instead. I am having trouble finding the correct way to use this.
Below are the few attempts I have used, but the error log in App_Data keeps giving me this.
Type : System.ArgumentNullException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Value cannot be null.
Parameter name: moduleName
Source : Telerik.Sitefinity
Help link :
ParamName : moduleName
Data : System.Collections.ListDictionaryInternal
TargetSite : Void .ctor(Telerik.Sitefinity.Modules.Pages.PageManager, System.String, System.Guid, Telerik.Sitefinity.Pages.Model.PageNode, System.String, TParentFacade)
Stack Trace : at Telerik.Sitefinity.Fluent.Modules.ModulePageFacade`1..ctor(PageManager pageManager, String moduleName, Guid nodeId, PageNode parentNode, String nodeName, TParentFacade parentFacade)
at Telerik.Sitefinity.Fluent.Modules.ModuleInstallFacade.CreateModulePage(Guid modulePageId, String pageName)
at MeetingScheduler.MeetingSchedulerModule.InstallPages(SiteInitializer initializer) in C:\Users\owner\Documents\Sitefinity\Projects\MeetingScheduler\MeetingSchedulerModule.cs:line 51
at Telerik.Sitefinity.Modules.GenericContent.ContentModuleBase.Install(SiteInitializer initializer)
at Telerik.Sitefinity.Services.ModuleBase.Install(SiteInitializer initializer, Version upgradeFrom)
at Telerik.Sitefinity.Services.SystemManager.InitializeModule(ModuleSettings settings, InstallContext installContext, Boolean start)
The line it is complaining about is the App.WorkWith().Module code found within the InstallPages method.
My first attempt was this:
App.WorkWith().Module().Install().CreateModulePage(pageInfo.PageId, pageInfo.Name);
App.WorkWith().Module(pageInfo.Parameters[
"ModuleName"
].ToString()).Install().CreateModulePage(pageInfo.PageId, pageInfo.Name);
pageInfo.Parameters[
"ModuleName"
]
is being set prior to this line.Hello Stacey,
Instead of directly creating pages from configuration, we now use a fluent API for module installation. It is basically self-documenting. In the Install() or InstallPages() method of your module, call App.WorkWith().Module().Install() and from there, you can use intellisense to see all available methods.
Is pageInfo.PageId different than "null"? An ArgumentException is thrown when you pass a null parameter to a function that expects something that is not null.
I believe it's because it's impossible to set the parameter in the facade.
pageInfo.Parameters["ModuleName"] = ProductsModule.ModuleName;
Hello George,
You can use this code -
var app = App.WorkWith().Module("MyModuleName").Install();
var page = app.CreateModulePage(Guid.NewGuid(), "Page");
Here you initialize the fluent façade with module name of MyModuleName and this is all you need to do. The other methods use this setting internally afterwards.