Config Library

The Config library provides a means to retrieve configuration preferences. These preferences can come from the default config file (application/config/ or from your own custom config files.

Note: This library is initialized automatically by the system so there is no need to do it manually.

Anatomy of a Config File

By default, revIgniter has one primary config file, located at application/config/ If you open the file using your text editor you'll see that config items are stored in a global array variable called gConfig.

You can add your own config items to this file, or if you prefer to keep your configuration items separate (assuming you even need config items), simply create your own file and save it in config folder.

Note: If you do create your own config files use the same format as the primary one, storing your items in an array called gConfig. revIgniter will intelligently manage these files so there will be no conflict even though the array has the same name (assuming an array index is not named the same as another).

Loading a Config File

Note: revIgniter automatically loads the primary config file (application/config/, so you will only need to load a config file if you have created your own.

There are two ways to load a config file:

  1. Manual Loading

    To load one of your custom config files you will use the following function within the controller that needs it:

    get rigLoadConfigFile("filename")

    Where filename is the name of your config file, without the .lc file extension.

    If you need to load multiple config files normally they will be merged into one master config array. Name collisions can occur, however, if you have identically named array indexes in different config files. To avoid collisions you can set the second parameter to TRUE and the key value pairs of each config file will be stored in an array index corresponding to the name of the config file. Example:

    # Stored in an array with this prototype: put "config" into gConfig["blogSettings"]["myIndex"]
    get rigLoadConfigFile("blogSettings", TRUE)

    Please see the section entitled Fetching Config Items below to learn how to retrieve config items set this way.

    The third parameter allows you to suppress errors in the event that a config file does not exist:

    get rigLoadConfigFile("blogSettings", FALSE, TRUE)
  2. Auto-loading

    If you find that you need a particular config file globally, you can have it loaded automatically by the system. To do this, open the file, located at application/config/, and add your config file as indicated in the file.

Fetching Config Items

To retrieve an item from your config file, use the following function:

put rigFetchConfigItem("item name") into tConfigItem

Where item name is the gConfig array index you want to retrieve. For example, to fetch your language choice you'll do this:

put rigFetchConfigItem("language") into tLang

The function returns FALSE if the item you are trying to fetch does not exist.

If you are using the second parameter of the rigLoadConfigFile() function in order to assign your config items to a specific index you can retrieve it by specifying the index name in the second parameter of the rigFetchConfigItem() function. Example:

# Loads a config file named and assigns it to an index named "blogSettings"
get rigLoadConfigFile("blogSettings", TRUE)

# Retrieve a config item named siteName contained within the blogSettings array
put rigFetchConfigItem("siteName", "blogSettings") into tSiteName

# An alternate way to specify the same item:
put rigFetchConfigItem("blogSettings") into tBlogConfig
put tBlogConfig["siteName"] into tSiteName

Setting a Config Item

If you would like to dynamically set a config item or change an existing one, you can so using:

rigSetConfigItem "itemName", "itemValue"

Where itemName is the gConfig array index you want to change, and itemValue is its value.

Use the optional third parameter to include the name of your custom configuration file in case you stored the data of your config file in an array index named after the config file as explained above, like:

rigSetConfigItem "itemName", "itemValue", "configFileName"

Where configFileName is the name of your config file, without the .lc file extension.

Use the optional fourth parameter to include the name of your module in case your module provides a configuration file, like:

rigSetConfigItem "itemName", "itemValue", , "moduleName"

Where moduleName is the name of your module, mind the empty third paramater.

Helper Functions

The config library has the following helper functions:


This function retrieves the URL to your site, along with the "index" value you've specified in the config file.


This function retrieves the URL to your system folder.