Is there a way to add custom settings for website

Vote:
 

I would like to add some custom settings for websites which I want to manage in website management. Is this possible? 

  • I can add custom object in SiteDefiniton Items as key value, but that has to be in code and I cannot change them by going to CMS admin.
  • I would like it to be like settings we add in StartPage. I cannot use StartPage for storing the settings because when I need these settings, StartPage will not be instantiated before that. 
  • I have multiple websites. Each of them needs these settings. Settings values will be different.
#227535
Sep 07, 2020 11:22
Vote:
 

Hi Himadri,

You can refer to this article-

https://devblog.gosso.se/2020/09/sitesettings-for-your-epi-site/

Or another way to create an admin controller and use DDS to store anything that you want and retrieve them based on your need.

#227536
Sep 07, 2020 11:30
Scott Reed - Sep 07, 2020 12:45
I would not use the DDS for anything, it's got known performance issues that can cause the whole thing to crash out if you have too much data plus it's slow. I would always recommend people to create their own custom tables and use entity framework (or whatever database ORM) to access the data.
Vote:
 

What code are you calling that doesn't have the ability to access the ContentLoader data? You should normally be able to access items directly by code even in things like Initialization Modules or startup files. Often the CotentReference.StartPage isn't set but you can pull the startpage from the SiteDefinition repository

#227540
Sep 07, 2020 12:48
Vote:
 

Thanks for all the replies. Ravindra S. Rathore Thanks for the article link. It is interesting way of injecting SiteSeetings from StartPage. But, it doesn't solve my issue. The issue found to be constructor injection of a service in ActionFilter that I am using to call an API. This action filter was initialized by GlobalFilters.Filters.Add. It is too early in the MVC pipeline and StartPage was not built yet. Once I removed service initialization from contructor, I could read settings using following code.

var contentLoader = ServiceLocator.Current.GetInstance<EPiServer.IContentLoader>();
var siteSettings = contentLoader.Get<StartPage>(SiteDefinition.Current.StartPage, LanguageSelector.AutoDetect());

#227541
Sep 07, 2020 13:07
Scott Reed - Sep 07, 2020 15:08
Great, that's what I was expecting was the issue. Glad you resolved it.
Vote:
 

Hello Himadri

Episerver Foundation uses content as settings. Example of the implementation can be found here: https://github.com/episerver/Foundation/tree/develop/src/Foundation/Features/Settings and here: https://github.com/episerver/Foundation/tree/develop/src/Foundation.Cms/Settings

David

#227542
Sep 07, 2020 14:29
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.