Using CreateModulePage instead of CreatePageFromConfiguratio

Posted by Community Admin on 04-Aug-2018 19:01

Using CreateModulePage instead of CreatePageFromConfiguration

All Replies

Posted by Community Admin on 12-Oct-2011 00:00

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);

               
My Second attempt was this:
App.WorkWith().Module(pageInfo.Parameters["ModuleName"].ToString()).Install().CreateModulePage(pageInfo.PageId, pageInfo.Name);

pageInfo.Parameters["ModuleName"] is being set prior to this line.
      


Posted by Community Admin on 17-Oct-2011 00:00

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.

Best wishes,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 02-Feb-2012 00:00

I believe it's because it's impossible to set the parameter in the facade.
pageInfo.Parameters["ModuleName"] = ProductsModule.ModuleName;

Can you please look into it team. I need it urgently.

G

Posted by Community Admin on 02-Feb-2012 00:00

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.

Regards,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed