diff options
Diffstat (limited to 'user_guide/libraries/config.html')
-rw-r--r-- | user_guide/libraries/config.html | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/user_guide/libraries/config.html b/user_guide/libraries/config.html new file mode 100644 index 000000000..c173f5690 --- /dev/null +++ b/user_guide/libraries/config.html @@ -0,0 +1,158 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>Code Igniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../scripts/nav.js"></script>
+<script type="text/javascript" src="../scripts/prototype.lite.js"></script>
+<script type="text/javascript" src="../scripts/moo.fx.js"></script>
+<script type="text/javascript">
+window.onload = function() {
+ myHeight = new fx.Height('nav', {duration: 400});
+ myHeight.hide();
+}
+</script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='Code Igniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>Code Igniter User Guide Version 1.4.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Full Table of Contents</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">Code Igniter Home</a> ›
+<a href="../index.html">User Guide Home</a> ›
+Config Class
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="www.codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>Config Class</h1>
+
+<p>The Config class provides a means to retrieve configuration preferences. These preferences can
+come from the default config file (<samp>application/config/config.php</samp>) or from your own custom config files.</p>
+
+<p class="important"><strong>Note:</strong> This class is initialized automatically by the system so there is no need to do it manually.</p>
+
+
+<h2>Anatomy of a Config File</h2>
+
+<p>By default, Code Igniter has a one primary config file, located at <samp>application/config/config.php</samp>. If you open the file using
+your text editor you'll see that config items are stored in an array called <var>$config</var>.</p>
+
+<p>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 <dfn>config</dfn> folder.</p>
+
+<p><strong>Note:</strong> If you do create your own config files use the same format as the primary one, storing your items in
+an array called <var>$config</var>. Code Igniter 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).</p>
+
+<h2>Loading a Config File</h2>
+
+<p><strong>Note:</strong> Code Igniter automatically loads the primary config file (<samp>application/config/config.php</samp>),
+so you will only need to load a config file if you have created your own.</p>
+
+<p>There are two ways to load a config file:</p>
+
+<ol><li><strong>Manual Loading</strong>
+
+<p>To load one of your custom config files you will use the following function within the <a href="../general/controllers.html">controller</a> that needs it:</p>
+
+<code>$this->config->load('<var>filename</var>');</code>
+
+<p>Where <var>filename</var> is the name of your config file, without the .php file extension.</p>
+
+</li>
+<li><strong>Auto-loading</strong></li>
+
+<p>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 <strong>autoload.php</strong> file, located at <samp>application/config/autoload.php</samp>, and add your config file as
+indicated in the file.</p>
+</li>
+</ol>
+
+
+<h2>Fetching Config Items</h2>
+
+<p>To retrive an item from your config file, use the following function:</p>
+
+<code>$this->config->item('<var>item name</var>');</code>
+
+<p>Where <var>item name</var> is the $config array index you want to retrieve. For example, to fetch your language choice you'll do this:</p>
+
+<code>$lang = $this->config->item('language');</code>
+
+<p>The function returns FALSE (boolean) if the item you are trying to fetch does not exist.</p>
+
+<h2>Setting a Config Item</h2>
+
+<p>If you would like to dynamically set a config item or change an existing one, you can so so using:</p>
+
+<code>$this->config->set_item('<var>item_name</var>', '<var>item_value</var>');</code>
+
+<p>Where <var>item_name</var> is the $config array index you want to change, and <var>item_value</var> is its value.</p>
+
+
+<h2>Helper Functions</h2>
+
+<p>The config class has the following helper functions:</p>
+
+<h2>$this->config->site_url();</h2>
+<p>This function retrieves the URL to your site, along with the "index" value you've specified in the config file.</p>
+
+<h2>$this->config->system_url();</h2>
+<p>This function retrieves the URL to your <dfn>system folder</dfn>.</p>
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic: <a href="calendar.html">Calendaring Class</a>
+ ·
+<a href="#top">Top of Page</a> ·
+<a href="../index.html">User Guide Home</a> ·
+Next Topic: <a href="database/index.html">Database Class</a>
+<p>
+<p><a href="http://www.codeigniter.com">Code Igniter</a> · Copyright © 2006 · <a href="http://www.pmachine.com">pMachine, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file |