I have a cshtml file that inherits Custom.Hybrid.Razor14. I can't change this inheritage since I need access to Kit property to update meta tags of the page. And I need to access portal name.
Dnn objects are available only within files/classes that inhering some Dnn namespace class.
I've tried to create a separate file helper in .cs file. But I didn't figure out how to access portal object from there to get its name. Documentation of 2sxc has huge amount of info but it seems useless for my case since I didn't succeed to find a missing peace of info there.
So how do I access portal name from there?
Here's my latest attempt to make it work. It's a .cs file with a helper that I was going to use in a .cshtml file that inherits Custom.Hybrid.Razor14.
using System;
using System.Globalization;
using ToSic.Razor.Blade;
using ToSic.Sxc.Data;
public class DnnHelper : Custom.Hybrid.CodeTyped//Custom.Dnn.Razor12
{
public string PortalName { get; set; }
public DnnHelper()
{
PortalName = PortalSettings.PortalName; // throws exception as it can't find PortalSettings from here
}
}
I suggest you first check out
CmsContext.Site(orMyContextinRazorTyped) to see if it has what you need.Otherwise you can just get the service
IDnnContextwhich should get you going. https://docs.2sxc.org/api/dot-net/ToSic.Sxc.Dnn.Run.IDnnContext.html`