- 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”
};
-
Once you want to get the custom setting what do you do?
-
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:
- getSettings(‘siteinfo’).siteName
or
- 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#