0

I have been working with 2sxc alongside DNN (Dot Net Nuke) for some time now.

In previous versions of 2sxc I have been able to use the following code to nest a 'Content Block' item within the text editor field of another app.

So essentially nesting an app within an app!

Using this code as an example: @ToSic.Sxc.Blocks.Render.All(modal, field: "Apps", merge: modal.Body)

Also with creating the 'Apps' as a separate field in the 2sxc app directly below the field I would like to nest the apps inside of.

However, this seems to create an error in the new recommended version of 2sxc.

Error code: Error: System.NullReferenceException: Object reference not set to an instance of an object. at ToSic.Sxc.Edit.EditService.EditService.ConnectToRoot(IDynamicCodeRoot codeRoot) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Edit\EditService\EditService.cs:line 26 at ToSic.Sxc.Blocks.RenderService.GetEdit(DynamicEntity parent) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\Renderers\RenderService.cs:line 112 at ToSic.Sxc.Blocks.RenderService.All(DynamicEntity parent, String noParamOrder, String field, String apps, Int32 max, String merge) in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\Renderers\RenderService.cs:line 93 at ToSic.Sxc.Blocks.Render.All(DynamicEntity parent, String noParamOrder, String field, String apps, Int32 max, String merge) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Core\Compatibility\Sxc\ToSic.Sxc.Blocks.Render.cs:line 73 at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at ASP._Page_Portals_0_2sxc_LayoutApp__LayoutApp_cshtml.Execute() in c:\inetpub\wwwroot\little-seed-dnn\Portals\0\2sxc\LayoutApp_LayoutApp.cshtml:line 44 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at ToSic.Sxc.Engines.RazorEngine.Render(TextWriter writer) in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Razor\Engines\Razor\RazorEngine.cs:line 117 at ToSic.Sxc.Engines.RazorEngine.RenderTemplate() in C:\Projects\2sxc\2sxc\Src\Dnn\ToSic.Sxc.Dnn.Razor\Engines\Razor\RazorEngine.cs:line 128 at ToSic.Sxc.Engines.EngineBase.Render() in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Engines\EngineBase.cs:line 135 at ToSic.Sxc.Blocks.BlockBuilder.RenderInternal() in C:\Projects\2sxc\2sxc\Src\Sxc\ToSic.Sxc\Blocks\BlockBuilder_Render.cs:line 186

Any help would be greatly appreciated, I may be simply missing a using statement.

Thanks in advance.

2 Answers2

0

The code is different now, instead of Blocks or Factory the new way is IRenderService. There is an example of simply rendering the whole output of a module in to the theme (ascx user control) here.

I think a lot of what you need to convert or adapt is covered here:

Fix Breaking Change in static Render in v13

Important note: if you spot code examples with GetService() it is now final as GetScopedService() and you should use the latter.

Jeremy Farrance
  • 740
  • 6
  • 11
0

Please also make sure you don't confuse the One(...) with the All(...) render methods.

  • One(...) will expect to get a specific thing to render
  • All(...) will take an entity which has Inner Content

So I'm just guessing, but you probably want One. All is basically for WYSIWYG setups, where the editor manually adds any app they want into a WYSIWYG field.

Check the blog app to see it in action.

iJungleBoy
  • 5,325
  • 1
  • 9
  • 21