Get Custom Settings? (newbie question I know)

  1. How do you make the setting like below.
    in ColdBox.cfc

// custom settings

settings = {
siteInfo = {
siteName = “United States Navy and Marine Corps Airworthiness Office”
}
};
or

// custom settings
settings = {
siteName = “United States Navy and Marine Corps Airworthiness Office”

};

  1. Once you want to get the custom setting what do you do?

  2. Also is this the best place to put something like a website name.

Sorry for the newbie question. Thanks

Hi Nathan,

Both approaches are valid. You can store simple values and structures within settings.

You would reference each like:

  1. getSettings(‘siteinfo’).siteName

or

  1. getSettings(‘siteName’)

If you want to have a central place to store the site name and then reference throughout your site I would say yes it’s a valid place to store it. Additionally you could store within the CB cache onAppInit() and reference that way too. I like the settings approach personally.

Nolan

If I do that what should I do to get the value out in the Layout.Main.cfm I am getting errors what am I doing wrong?

#getSettings(‘siteinfo’).siteName#

#rc.getSettings(‘siteinfo’).siteName#

#event.getSettings(‘siteinfo’).siteName#

Sorry. It should be getSetting, not plural

#getSetting(‘siteinfo’).siteName#

Thanks that worked.