I'm using Umbraco 7.5.2. I have created a doc type for my "Global Settings" and have created a Content node on top of that document type.
I have a static C# class, called SiteGlobalSettings that I use in my backend codes to handle global concerns.
I want to have SiteGlobalSettings be able to read data from my "Global Settings" content node. In SiteGlobalSettings static constructor, I have this code:
After running this code, globalSettingsContent will be null. I can see that UmbracoHelper has some constructor overloads. One of them recieves a UmbracoContext object, but it seems I cannot new it.
Can someone help me achieve this please?
Thank you.
Reading From a Settings Node
Hi,
I'm using Umbraco 7.5.2. I have created a doc type for my "Global Settings" and have created a Content node on top of that document type.
I have a static C# class, called SiteGlobalSettings that I use in my backend codes to handle global concerns.
I want to have SiteGlobalSettings be able to read data from my "Global Settings" content node. In SiteGlobalSettings static constructor, I have this code:
UmbracoHelper Umbraco = new UmbracoHelper();
dynamic globalSettingsContent = Umbraco.Content(...global setting node id...);
After running this code, globalSettingsContent will be null. I can see that UmbracoHelper has some constructor overloads. One of them recieves a UmbracoContext object, but it seems I cannot new it.
Can someone help me achieve this please? Thank you.
Hi Siavash,
Try to do it like that:
It's ok, can you share code of your view?
Also it's not perfect to use dynamics, do you know?
Thanks,
Alex
Hi Alex,
That works, thank you very much! :-)
Glad to help.
Mark topic as solved and have a nice evening!
Thanks,
Alex
is working on a reply...