More in this section

Forums / Developing with Sitefinity / Best practice to add a global system setting

Best practice to add a global system setting

3 posts, 0 answered
  1. MJia
    MJia avatar
    44 posts
    09 Jun 2009
    22 Mar 2010
    Link to this post
    Hi, we need to add a new system property that works globally.  For example, "HomepageNewsID" which indicates which news should be displayed on homepage.  Administrator can login to sitefinity and set this value.  The front-end homepage will display the news based on the current setting.  After the value is changed, ppl will see different news if they refresh the page.

    I just wonder what's the best practice for setting such a global system property?
    I know it maybe the best to customize the news display control by adding a newsID property to the control, then change this property by editing the homepage.  Let's suppose this control will be used in some other pages and client doesn't want to update every page seperately.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    22 Mar 2010
    Link to this post
    Hi MJia,

    You can read "HomePageNewsID" by using ConfigurationManager.AppSettings Property . You can set a value in the web.config AppSettings node and then read it from your control

    The second option is storing the HomePageNewsID in custom table in your database.

    The third option is creating a custom property for NewsView control where you set default value for HomePageNewsID that will be used often and this value will be changed only in some cases.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    18 Jul 2012
    23 Mar 2010
    Link to this post
    the problem with using the appsettings node of web.config is that anytime you make changes to the setting, your application will reset, since you are changing the configuration file. If this is something that never changes (such as the site name, or a connection string) it makes sense, but if you're going to be changing it frequently there might be a better option...

    using a database is probably best, just add a sf_Settings table with Key and Value as fields, then you can easily create a wrapper object to retrieve and update items such as sf_Settings.GetValue("Key") or sf_Settings.Key = value.

    a simpler way is to use an xml file, for best performance just load the settings file from the file on application load, so that it's always in memory, then write back to the file only on changes to the settings. the good thing about this one is that it's easy to update manually in a notepad file (or even better a radgrid)

    any of these approaches would work it's really up to which works best to fit your specific needs.

    hope this was helpful!
Register for webinar
3 posts, 0 answered