Try our conversational search powered by Generative AI!

Global site data/properties

Vote:
 

Hi

I'm quite new to EpiServer and are trying to build a basic site. I have created a working set of PageData, following this pattern:

[CultureSpecific]
        [Display(Name = "Meta description",
            GroupName = SiteTabNames.SEO, Order = 200)]
        public virtual string MetaDescription { get; set; }

These can be edited for each page, and that's what I want in this case. But my question is this; what is the best practice for creating a similar set of preoperties, but not specific for each page, but rather global for the entire site (this could be contact info that goes in the footer, or other things that I want to reuse across all pages)? 

I have searched for this a while, but can't seem to find a solution anywhere, and this seems like a common feature. There's probably some obvious solution that I'm missing here, and I'd really  appreciate any help towards solving this.

(I'm on version 10.10.4)

#185023
Nov 08, 2017 13:24
Vote:
 

One solution is to add them to the startpage, since the startpage is always easy to retrieve from any page.

#185038
Nov 08, 2017 16:09
Vote:
 

Thanks a lot, logically that makes sense, and I thought I could work it out myself - but aparently not.. Would you have a simple example of how the property is declared on the startPage (if not in the way I have done it in my example), and a simple example of how to retrieve the property one the startpage from a different site (in the latest episerver version). I can get the startPage with ContentReference.StartPage, but I can't find how to retrieve the property, so I assume I'm doing either the property or the getting wrong :/ 

#185080
Nov 09, 2017 9:25
Vote:
 

Don't you have a content type for the startpage as a model? Then you just add the properties to that model, just like you added MetaDescription to your content type above. Then you retrieve the properties like this, given that your startpage's content type is StartPage:

var startPage = contentLoader.Get<StartPage>(ContentReference.StartPage);

var test = startPage.TheProperty;
#185084
Edited, Nov 09, 2017 10:20
Vote:
 

I'm obviously late to the party, but I wrote a blog post a while ago about the various models of storing global settings: https://www.epinova.no/en/blog/configuration-options-for-episerver-sites/. There are pros and cons for each one, depending on your needs.

#185217
Nov 12, 2017 20:15
Vote:
 

Thanks a lot guys, I have been a bit preoccupied, and have not been able to test this, but it seems like solid solutions. Johan, the reason I could not make it work was something else I had done wrong, so your solution is satisfactory. Arild, thank you for providing alternative solutions for alternative cases.

#185223
Nov 13, 2017 8:54
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.