Access 2sxc App Data from outside 2sxc

Feb 22, 2016 at 5:32 PM
Hi All,

Is there a simple way to access the data stored in a 2sxc App from a normal Razor file which is NOT inheriting from ToSic.SexyContent.Razor.SexyContentWebPage.

My situation is that I have another module which supports Razor Templating and I want to pull in some data stored in a 2sxc App into that Module (Which will only work with Razor files inheriting from DotNetNuke.Web.Razor.DotNetNukeWebPage)

Thanks in advance...
Feb 24, 2016 at 10:42 AM
I'm sure it can be done, but lots of things will be missing - like AsDynamic, Data, the correct RenderPage etc.

You would have avoid these to re-include all these things, which would be quite a lot of work. it's easy, but I'm convinced it will take you a few hours to get to work, probably more than you're willing to invest.
Feb 24, 2016 at 11:22 AM
Sorry, seems I basically asked this question twice and didn't even realise... too many hours at the desk!!! Anyway...

I worked it out...

Added this to the other Razor View:
private static AppAndDataHelpers _appAndDataHelpers;
        private static AppAndDataHelpers AppAndDataHelpers
        {
            get
            {
                if (_appAndDataHelpers == null)
                {
                    var moduleInfo = DotNetNuke.Entities.Modules.ModuleController.Instance.GetModule(ModuleIdOf2xcModule, TabIdOf2xcModule, false);
                    int? appId = null;
                    if (!appId.HasValue)
                        appId = SexyContent.GetAppIdFromModule(moduleInfo);
                    var zoneId = SexyContent.GetZoneID(moduleInfo.PortalID);
                    SexyContent Sexy = new SexyContent(zoneId.Value, appId.Value, true, moduleInfo.OwnerPortalID);
                    var viewDataSource = Sexy.GetViewDataSource(moduleInfo.ModuleID, SexyContent.HasEditPermission(moduleInfo), Sexy.ContentGroups.GetContentGroupForModule(moduleInfo.ModuleID).Template);
                    _appAndDataHelpers = new AppAndDataHelpers(Sexy, moduleInfo, (ToSic.SexyContent.DataSources.ViewDataSource)viewDataSource, Sexy.App);
                }
                return _appAndDataHelpers;
            }
        }