What is best way to access global site settings value ?
I Have site setting Document type with Add at root node is set , I am creating one page with that which is added at root level , now i want to access that page data throughout my all views and macro . Please suggest me which is best way to do it ?
No there is no extra assembly for ContentManager. This is one of my custom classes which contains a few helper methods I created a speed things up for me. Same for MediaManager. Just ignore this. I copied and pasted straight out of one of my projects.
In my example that line of code is just calling this method.
a little late but I mostly go with having a content picker on my root page with which I select the settings page and then get it by the selected id.
This can then also be done recursivly.
What is best way to access global site settings value ?
I Have site setting Document type with Add at root node is set , I am creating one page with that which is added at root level , now i want to access that page data throughout my all views and macro . Please suggest me which is best way to do it ?
Hi,
For site settings I follow the same path as you. Add a node at the root of the site.
The second half of the puzzle I create a class to store all my settings values.
E.g
Then whenever in need the site settings either in my backend or my razor script I just call.
SiteSettings siteSettings = new SiteSettings();
Quick and easy. You can probably improve it by adding your own caching but I think Umbraco caches this stuff pretty well already.
Oh and here is the helper method I created to get the siteSettings node
Hope this helps
Kind Regards
David
Thanks for your help.
initially i was trying to create model but i cant inherit it to view.
but now
i am using your approach , is there any extra assembly need for same for "ContentManager"
Hi,
No there is no extra assembly for ContentManager. This is one of my custom classes which contains a few helper methods I created a speed things up for me. Same for MediaManager. Just ignore this. I copied and pasted straight out of one of my projects.
In my example that line of code is just calling this method.
Thanks David it work for me . :)
Hi,
a little late but I mostly go with having a content picker on my root page with which I select the settings page and then get it by the selected id. This can then also be done recursivly.
Regards David
is working on a reply...