diff options
Diffstat (limited to 'user_guide/general')
28 files changed, 0 insertions, 4917 deletions
diff --git a/user_guide/general/alternative_php.html b/user_guide/general/alternative_php.html deleted file mode 100644 index a4ce418e9..000000000 --- a/user_guide/general/alternative_php.html +++ /dev/null @@ -1,147 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Alternate PHP Syntax for View Files : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Alternate PHP Syntax -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Alternate PHP Syntax for View Files</h1> - -<p>If you do not utilize CodeIgniter's <a href="../libraries/parser.html">template engine</a>, you'll be using pure PHP -in your View files. To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use -PHPs alternative syntax for control structures and short tag echo statements. If you are not familiar with this syntax, it allows you to eliminate the braces from your code, -and eliminate "echo" statements.</p> - -<h2>Automatic Short Tag Support</h2> - -<p><strong>Note:</strong> If you find that the syntax described in this page does not work on your server it might -be that "short tags" are disabled in your PHP ini file. CodeIgniter will optionally rewrite short tags on-the-fly, -allowing you to use that syntax even if your server doesn't support it. This feature can be enabled in your -<dfn>config/config.php</dfn> file.</p> - -<p class="important">Please note that if you do use this feature, if PHP errors are encountered -in your <strong>view files</strong>, the error message and line number will not be accurately shown. Instead, all errors -will be shown as <kbd>eval()</kbd> errors.</p> - - -<h2>Alternative Echos</h2> - -<p>Normally to echo, or print out a variable you would do this:</p> - -<code><?php echo $variable; ?></code> - -<p>With the alternative syntax you can instead do it this way:</p> - -<code><?=$variable?></code> - - - -<h2>Alternative Control Structures</h2> - -<p>Controls structures, like <var>if</var>, <var>for</var>, <var>foreach</var>, and <var>while</var> can be -written in a simplified format as well. Here is an example using foreach:</p> - -<code> -<ul><br /> -<br /> -<var><?php foreach ($todo as $item): ?></var><br /> -<br /> -<li><var><?=$item?></var></li><br /> -<br /> -<var><?php endforeach; ?></var><br /> -<br /> -</ul></code> - -<p>Notice that there are no braces. Instead, the end brace is replaced with <var>endforeach</var>. -Each of the control structures listed above has a similar closing syntax: -<var>endif</var>, <var>endfor</var>, <var>endforeach</var>, and <var>endwhile</var></p> - -<p>Also notice that instead of using a semicolon after each structure (except the last one), there is a colon. This is -important!</p> - -<p>Here is another example, using if/elseif/else. Notice the colons:</p> - - -<code><var><?php if ($username == 'sally'): ?></var><br /> -<br /> - <h3>Hi Sally</h3><br /> -<br /> -<var><?php elseif ($username == 'joe'): ?></var><br /> -<br /> - <h3>Hi Joe</h3><br /> -<br /> -<var><?php else: ?></var><br /> -<br /> - <h3>Hi unknown user</h3><br /> -<br /> -<var><?php endif; ?></var></code> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="managing_apps.html">Managing Applications</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="security.html">Security</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/ancillary_classes.html b/user_guide/general/ancillary_classes.html deleted file mode 100644 index fb78edaeb..000000000 --- a/user_guide/general/ancillary_classes.html +++ /dev/null @@ -1,117 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Creating Ancillary Classes : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Creating Ancillary Classes -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Creating Ancillary Classes</h1> - -<p>In some cases you may want to develop classes that exist apart from your controllers but have the ability to -utilize all of CodeIgniter's resources. This is easily possible as you'll see.</p> - -<h2>get_instance()</h2> - - -<p><strong>Any class that you instantiate within your controller functions can access CodeIgniter's native resources</strong> simply by using the <kbd>get_instance()</kbd> function. -This function returns the main CodeIgniter object.</p> - -<p>Normally, to call any of the available CodeIgniter functions requires you to use the <kbd>$this</kbd> construct:</p> - -<code> -<strong>$this</strong>->load->helper('url');<br /> -<strong>$this</strong>->load->library('session');<br /> -<strong>$this</strong>->config->item('base_url');<br /> -etc. -</code> - -<p><kbd>$this</kbd>, however, only works within your controllers, your models, or your views. -If you would like to use CodeIgniter's classes from within your own custom classes you can do so as follows:</p> - - -<p>First, assign the CodeIgniter object to a variable:</p> - -<code>$CI =& get_instance();</code> - -<p>Once you've assigned the object to a variable, you'll use that variable <em>instead</em> of <kbd>$this</kbd>:</p> - -<code> -$CI =& get_instance();<br /><br /> -$CI->load->helper('url');<br /> -$CI->load->library('session');<br /> -$CI->config->item('base_url');<br /> -etc. -</code> - -<p class="important"><strong>Note:</strong> You'll notice that the above get_instance() function is being passed by reference: -<br /><br /> -<var>$CI =& get_instance();</var> -<br /><br /> -This is very important. Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it.</p> -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="creating_libraries.html">Creating Core Libraries</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="autoloader.html">Auto-loading Resources</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/autoloader.html b/user_guide/general/autoloader.html deleted file mode 100644 index b65674fda..000000000 --- a/user_guide/general/autoloader.html +++ /dev/null @@ -1,100 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Auto-loading Resources : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Auto-loading Resources -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Auto-loading Resources</h1> - -<p>CodeIgniter comes with an "Auto-load" feature that permits libraries, helpers, and models to be initialized -automatically every time the system runs. If you need certain resources globally throughout your application you should -consider auto-loading them for convenience.</p> - -<p>The following items can be loaded automatically:</p> - -<ul> -<li>Core classes found in the "libraries" folder</li> -<li>Helper files found in the "helpers" folder</li> -<li>Custom config files found in the "config" folder</li> -<li>Language files found in the "system/language" folder </li> -<li>Models found in the "models" folder</li> -</ul> - -<p>To autoload resources, open the <var>application/config/autoload.php</var> file and add the item you want -loaded to the <samp>autoload</samp> array. You'll find instructions in that file corresponding to each -type of item.</p> - -<p class="important"><strong>Note:</strong> Do not include the file extension (.php) when adding items to the autoload array.</p> - - - - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="hooks.html">Hooks - Extending the Core</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="common_functions.html">Common Functions</a></p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/caching.html b/user_guide/general/caching.html deleted file mode 100644 index b40e770a9..000000000 --- a/user_guide/general/caching.html +++ /dev/null @@ -1,115 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Web Page Caching : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Page Caching -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Web Page Caching</h1> - -<p>CodeIgniter lets you cache your pages in order to achieve maximum performance.</p> - -<p>Although CodeIgniter is quite fast, the amount of dynamic information you display in your pages will correlate directly to the -server resources, memory, and processing cycles utilized, which affect your page load speeds. -By caching your pages, since they are saved in their fully rendered state, you can achieve performance that nears that of static web pages.</p> - - -<h2>How Does Caching Work?</h2> - -<p>Caching can be enabled on a per-page basis, and you can set the length of time that a page should remain cached before being refreshed. -When a page is loaded for the first time, the cache file will be written to your <dfn>application/cache</dfn> folder. On subsequent page loads the cache file will be retrieved -and sent to the requesting user's browser. If it has expired, it will be deleted and refreshed before being sent to the browser.</p> - -<p>Note: The Benchmark tag is not cached so you can still view your page load speed when caching is enabled.</p> - -<h2>Enabling Caching</h2> - -<p>To enable caching, put the following tag in any of your controller functions:</p> - -<code>$this->output->cache(<var>n</var>);</code> - -<p>Where <var>n</var> is the number of <strong>minutes</strong> you wish the page to remain cached between refreshes.</p> - -<p>The above tag can go anywhere within a function. It is not affected by the order that it appears, so place it wherever it seems -most logical to you. Once the tag is in place, your pages will begin being cached.</p> - -<p class="important"><strong>Warning:</strong> Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a <a href="./views.html">view</a>.</p> -<p class="important"><strong>Note:</strong> Before the cache files can be written you must set the file permissions on your -<dfn>application/cache</dfn> folder such that it is writable.</p> - -<h2>Deleting Caches</h2> - -<p>If you no longer wish to cache a file you can remove the caching tag and it will no longer be refreshed when it expires. Note: -Removing the tag will not delete the cache immediately. It will have to expire normally. If you need to remove it earlier you -will need to manually delete it from your cache folder.</p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="errors.html">Error Handling</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="profiling.html">Profiling Your Application</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/cli.html b/user_guide/general/cli.html deleted file mode 100644 index befc9994a..000000000 --- a/user_guide/general/cli.html +++ /dev/null @@ -1,150 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Running via the CLI : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Running via the CLI -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Running via the CLI</h1> - -<p> - As well as calling an applications <a href="./controllers.html">Controllers</a> via the URL in a browser they can also be loaded via the command-line interface (CLI). -</p> - - -<ul> -<li><a href="#what">What is the CLI?</a></li> -<li><a href="#why">Why use this method?</a></li> -<li><a href="#how">How does it work?</a></li> -</ul> - - -<a name="what"></a> -<h2>What is the CLI?</h2> - -<p><dfn>The command-line interface is a text-based method of interacting with computers.</dfn> For more information, check the <a href="http://en.wikipedia.org/wiki/Command-line_interface">Wikipedia article</a>.</p> - -<a name="why"></a> - -<h2>Why run via the command-line?</h2> - -<p> - There are many reasons for running CodeIgniter from the command-line, but they are not always obvious.</p> - -<ul> - <li>Run your cron-jobs without needing to use wget or curl</li> - <li>Make your cron-jobs inaccessible from being loaded in the URL by checking for <kbd>IS_CLI</kbd></li> - <li>Make interactive "tasks" that can do things like set permissions, prune cache folders, run backups, etc.</li> - <li>Integrate with other applications in other languages. For example, a random C++ script could call one command and run code in your models!</li> -</ul> - -<a name="how"></a> -<h2>Let's try it: Hello World!</h2> - -<p>Let's create a simple controller so you can see it in action. Using your text editor, create a file called <dfn>tools.php</dfn>, and put the following code in it:</p> - -<textarea class="textarea" style="width:100%" cols="50" rows="10"> -<?php -class Tools extends CI_Controller { - - public function message($to = 'World') - { - echo "Hello {$to}!".PHP_EOL; - } -} -?> -</textarea> - -<p>Then save the file to your <dfn>application/controllers/</dfn> folder.</p> - -<p>Now normally you would visit the your site using a URL similar to this:</p> - -<code>example.com/index.php/<var>tools</var>/<var>message</var>/<var>to</var></code> - -<p>Instead, we are going to open Terminal in Mac/Lunix or go to Run > "cmd" in Windows and navigate to our CodeIgniter project.</p> - -<blockquote> - $ cd /path/to/project;<br/> - $ php index.php tools message -</blockquote> - -<p>If you did it right, you should see <samp>Hello World!</samp>.</p> - -<blockquote> - $ php index.php tools message "John Smith" -</blockquote> - -<p>Here we are passing it a argument in the same way that URL parameters work. "John Smith" is passed as a argument and output is: <samp>Hello John Smith!</samp>.</p> - -<h2>That's it!</h2> - -<p>That, in a nutshell, is all there is to know about controllers on the command line. Remember that this is just a normal controller, so routing and _remap works fine.</p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="urls.html">CodeIgniter URLs</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="reserved_names.html">Reserved Names</a></p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/common_functions.html b/user_guide/general/common_functions.html deleted file mode 100644 index 65457759d..000000000 --- a/user_guide/general/common_functions.html +++ /dev/null @@ -1,125 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Common Functions : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Auto-loading Resources -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Common Functions</h1> - -<p>CodeIgniter uses a few functions for its operation that are globally defined, and are available to you at any point. These do not require loading any libraries or helpers.</p> - -<h2>is_php('<var>version_number</var>')</h2> - -<p>is_php() determines of the PHP version being used is greater than the supplied <var>version_number</var>.</p> - -<code>if (is_php('5.3.0'))<br /> -{<br /> - $str = quoted_printable_encode($str);<br /> -}</code> - -<p>Returns boolean <kbd>TRUE</kbd> if the installed version of PHP is equal to or greater than the supplied version number. Returns <kbd>FALSE</kbd> if the installed version of PHP is lower than the supplied version number.</p> - - -<h2>is_really_writable('<var>path/to/file</var>')</h2> - -<p>is_writable() returns TRUE on Windows servers when you really can't write to the file as the OS reports to PHP as FALSE only if the read-only attribute is marked. This function determines if a file is actually writable by attempting to write to it first. Generally only recommended on platforms where this information may be unreliable.</p> - -<code>if (is_really_writable('file.txt'))<br /> -{<br /> - echo "I could write to this if I wanted to";<br /> -}<br /> -else<br /> -{<br /> - echo "File is not writable";<br /> -}</code> - -<h2>config_item('<var>item_key</var>')</h2> -<p>The <a href="../libraries/config.html">Config library</a> is the preferred way of accessing configuration information, however config_item() can be used to retrieve single keys. See Config library documentation for more information.</p> - -<h2>show_error('<var>message</var>'), show_404('<var>page</var>'), log_message('<var>level</var>', '<samp>message</samp>')</h2> -<p>These are each outlined on the <a href="errors.html">Error Handling</a> page.</p> - -<h2>set_status_header(<var>code</var>, '<var>text</var>');</h2> - -<p>Permits you to manually set a server status header. Example:</p> - -<code>set_status_header(401);<br /> -// Sets the header as: Unauthorized</code> - -<p><a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">See here</a> for a full list of headers.</p> - - -<h2>remove_invisible_characters(<var>$str</var>)</h2> -<p>This function prevents inserting null characters between ascii characters, like Java\0script.</p> - - - -</div> - - -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="autoloader.html">Auto-loading Resources</a><a href="hooks.html"></a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="routing.html">URI Routing</a></p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html deleted file mode 100644 index 2d525141c..000000000 --- a/user_guide/general/controllers.html +++ /dev/null @@ -1,388 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Controllers : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Controllers -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Controllers</h1> - -<p>Controllers are the heart of your application, as they determine how HTTP requests should be handled.</p> - - -<ul> -<li><a href="#what">What is a Controller?</a></li> -<li><a href="#hello">Hello World</a></li> -<li><a href="#functions">Functions</a></li> -<li><a href="#passinguri">Passing URI Segments to Your Functions</a></li> -<li><a href="#default">Defining a Default Controller</a></li> -<li><a href="#remapping">Remapping Function Calls</a></li> -<li><a href="#output">Controlling Output Data</a></li> -<li><a href="#private">Private Functions</a></li> -<li><a href="#subfolders">Organizing Controllers into Sub-folders</a></li> -<li><a href="#constructors">Class Constructors</a></li> -<li><a href="#reserved">Reserved Function Names</a></li> -</ul> - - -<a name="what"></a> -<h2>What is a Controller?</h2> - -<p><dfn>A Controller is simply a class file that is named in a way that can be associated with a URI.</dfn></p> - -<p>Consider this URI:</p> - -<code>example.com/index.php/<var>blog</var>/</code> - -<p>In the above example, CodeIgniter would attempt to find a controller named <dfn>blog.php</dfn> and load it.</p> - -<p><strong>When a controller's name matches the first segment of a URI, it will be loaded.</strong></p> - -<a name="hello"></a> -<h2>Let's try it: Hello World!</h2> - -<p>Let's create a simple controller so you can see it in action. Using your text editor, create a file called <dfn>blog.php</dfn>, and put the following code in it:</p> - - -<textarea class="textarea" style="width:100%" cols="50" rows="10"> -<?php -class Blog extends CI_Controller { - - public function index() - { - echo 'Hello World!'; - } -} -?> -</textarea> - - - -<p>Then save the file to your <dfn>application/controllers/</dfn> folder.</p> - -<p>Now visit the your site using a URL similar to this:</p> - -<code>example.com/index.php/<var>blog</var>/</code> - -<p>If you did it right, you should see <samp>Hello World!</samp>.</p> - -<p>Note: Class names must start with an uppercase letter. In other words, this is valid:</p> - -<code><?php<br /> -class <var>Blog</var> extends CI_Controller {<br /> -<br /> -}<br /> -?></code> - -<p>This is <strong>not</strong> valid:</p> - -<code><?php<br /> -class <var>blog</var> extends CI_Controller {<br /> -<br /> -}<br /> -?></code> - -<p>Also, always make sure your controller <dfn>extends</dfn> the parent controller class so that it can inherit all its functions.</p> - - - -<a name="functions"></a> -<h2>Functions</h2> - -<p>In the above example the function name is <dfn>index()</dfn>. The "index" function is always loaded by default if the -<strong>second segment</strong> of the URI is empty. Another way to show your "Hello World" message would be this:</p> - -<code>example.com/index.php/<var>blog</var>/<samp>index</samp>/</code> - -<p><strong>The second segment of the URI determines which function in the controller gets called.</strong></p> - -<p>Let's try it. Add a new function to your controller:</p> - - -<textarea class="textarea" style="width:100%" cols="50" rows="15"> -<?php -class Blog extends CI_Controller { - - public function index() - { - echo 'Hello World!'; - } - - public function comments() - { - echo 'Look at this!'; - } -} -?> -</textarea> - -<p>Now load the following URL to see the <dfn>comment</dfn> function:</p> - -<code>example.com/index.php/<var>blog</var>/<samp>comments</samp>/</code> - -<p>You should see your new message.</p> - -<a name="passinguri"></a> -<h2>Passing URI Segments to your Functions</h2> - -<p>If your URI contains more then two segments they will be passed to your function as parameters.</p> - -<p>For example, lets say you have a URI like this:</p> - -<code>example.com/index.php/<var>products</var>/<samp>shoes</samp>/<kbd>sandals</kbd>/<dfn>123</dfn></code> - -<p>Your function will be passed URI segments 3 and 4 ("sandals" and "123"):</p> - -<code> -<?php<br /> -class Products extends CI_Controller {<br /> -<br /> - public function shoes($sandals, $id)<br /> - {<br /> - echo $sandals;<br /> - echo $id;<br /> - }<br /> -}<br /> -?> -</code> - -<p class="important"><strong>Important:</strong> If you are using the <a href="routing.html">URI Routing</a> feature, the segments -passed to your function will be the re-routed ones.</p> - - -<a name="default"></a> -<h2>Defining a Default Controller</h2> - -<p>CodeIgniter can be told to load a default controller when a URI is not present, -as will be the case when only your site root URL is requested. To specify a default controller, open -your <dfn>application/config/routes.php</dfn> file and set this variable:</p> - -<code>$route['default_controller'] = '<var>Blog</var>';</code> - -<p>Where <var>Blog</var> is the name of the controller class you want used. If you now load your main index.php file without -specifying any URI segments you'll see your Hello World message by default.</p> - - - -<a name="remapping"></a> -<h2>Remapping Function Calls</h2> - -<p>As noted above, the second segment of the URI typically determines which function in the controller gets called. -CodeIgniter permits you to override this behavior through the use of the <kbd>_remap()</kbd> function:</p> - -<code>public function _remap()<br /> -{<br /> - // Some code here...<br /> -}</code> - -<p class="important"><strong>Important:</strong> If your controller contains a function named <kbd>_remap()</kbd>, it will <strong>always</strong> -get called regardless of what your URI contains. It overrides the normal behavior in which the URI determines which function is called, -allowing you to define your own function routing rules.</p> - -<p>The overridden function call (typically the second segment of the URI) will be passed as a parameter to the <kbd>_remap()</kbd> function:</p> - -<code>public function _remap(<var>$method</var>)<br /> -{<br /> - if ($method == 'some_method')<br /> - {<br /> - $this->$method();<br /> - }<br /> - else<br /> - {<br /> - $this->default_method();<br /> - }<br /> -}</code> - -<p>Any extra segments after the method name are passed into <kbd>_remap()</kbd> as an optional second parameter. This array can be used in combination with PHP's <a href="http://php.net/call_user_func_array">call_user_func_array</a> to emulate CodeIgniter's default behavior.</p> - -<code>public function _remap($method, $params = array())<br /> -{<br /> - $method = 'process_'.$method;<br /> - if (method_exists($this, $method))<br /> - {<br /> - return call_user_func_array(array($this, $method), $params);<br /> - }<br /> - show_404();<br /> -}</code> - - -<a name="output"></a> -<h2>Processing Output</h2> - -<p>CodeIgniter has an output class that takes care of sending your final rendered data to the web browser automatically. More information on this can be found in the -<a href="views.html">Views</a> and <a href="../libraries/output.html">Output class</a> pages. In some cases, however, you might want to -post-process the finalized data in some way and send it to the browser yourself. CodeIgniter permits you to -add a function named <dfn>_output()</dfn> to your controller that will receive the finalized output data.</p> - -<p><strong>Important:</strong> If your controller contains a function named <kbd>_output()</kbd>, it will <strong>always</strong> -be called by the output class instead of echoing the finalized data directly. The first parameter of the function will contain the finalized output.</p> - -<p>Here is an example:</p> - -<code> -public function _output($output)<br /> -{<br /> - echo $output;<br /> -}</code> - -<p class="important">Please note that your <dfn>_output()</dfn> function will receive the data in its finalized state. Benchmark and memory usage data will be rendered, -cache files written (if you have caching enabled), and headers will be sent (if you use that <a href="../libraries/output.html">feature</a>) -before it is handed off to the _output() function.<br /> -<br /> -To have your controller's output cached properly, its <dfn>_output()</dfn> method can use:<br /> - -<code>if ($this->output->cache_expiration > 0)<br /> -{<br /> - $this->output->_write_cache($output);<br /> -}</code> - -If you are using this feature the page execution timer and memory usage stats might not be perfectly accurate -since they will not take into acccount any further processing you do. For an alternate way to control output <em>before</em> any of the final processing is done, please see -the available methods in the <a href="../libraries/output.html">Output Class</a>.</p> - -<a name="private"></a> -<h2>Private Functions</h2> - - -<p>In some cases you may want certain functions hidden from public access. To make a function private, simply add an -underscore as the name prefix and it will not be served via a URL request. For example, if you were to have a function like this:</p> - -<code> -private function _utility()<br /> -{<br /> - // some code<br /> -}</code> - -<p>Trying to access it via the URL, like this, will not work:</p> - -<code>example.com/index.php/<var>blog</var>/<samp>_utility</samp>/</code> - - - -<a name="subfolders"></a> -<h2>Organizing Your Controllers into Sub-folders</h2> - -<p>If you are building a large application you might find it convenient to organize your controllers into sub-folders. CodeIgniter permits you to do this.</p> - -<p>Simply create folders within your <dfn>application/controllers</dfn> directory and place your controller classes within them.</p> - -<p><strong>Note:</strong> When using this feature the first segment of your URI must specify the folder. For example, lets say you have a controller -located here:</p> - -<code>application/controllers/<kbd>products</kbd>/shoes.php</code> - -<p>To call the above controller your URI will look something like this:</p> - -<code>example.com/index.php/products/shoes/show/123</code> - -<p>Each of your sub-folders may contain a default controller which will be -called if the URL contains only the sub-folder. Simply name your default controller as specified in your -<dfn>application/config/routes.php</dfn> file</p> - - -<p>CodeIgniter also permits you to remap your URIs using its <a href="routing.html">URI Routing</a> feature.</p> - - -<h2><a name="constructors"></a>Class Constructors</h2> - - -<p>If you intend to use a constructor in any of your Controllers, you <strong>MUST</strong> place the following line of code in it:</p> - -<code>parent::__construct();</code> - -<p>The reason this line is necessary is because your local constructor will be overriding the one in the parent controller class so we need to manually call it.</p> - -<code> -<?php<br /> -class <kbd>Blog</kbd> extends CI_Controller {<br /> -<br /> - public function <kbd>__construct()</kbd><br /> - {<br /> - <var>parent::__construct();</var><br /> - // Your own constructor code<br /> - }<br /> -}<br /> -?></code> - -<p>Constructors are useful if you need to set some default values, or run a default process when your class is instantiated. -Constructors can't return a value, but they can do some default work.</p> - -<a name="reserved"></a> -<h2>Reserved Function Names</h2> - -<p>Since your controller classes will extend the main application controller you -must be careful not to name your functions identically to the ones used by that class, otherwise your local functions -will override them. See <a href="reserved_names.html">Reserved Names</a> for a full list.</p> - -<h2>That's it!</h2> - -<p>That, in a nutshell, is all there is to know about controllers.</p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="urls.html">CodeIgniter URLs</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="reserved_names.html">Reserved Names</a></p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html deleted file mode 100644 index b8917864f..000000000 --- a/user_guide/general/core_classes.html +++ /dev/null @@ -1,186 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Creating Core System Classes : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Creating Core System Classes -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Creating Core System Classes</h1> - -<p>Every time CodeIgniter runs there are several base classes that are initialized automatically as part of the core framework. -It is possible, however, to swap any of the core system classes with your own versions or even extend the core versions.</p> - -<p><strong>Most users will never have any need to do this, -but the option to replace or extend them does exist for those who would like to significantly alter the CodeIgniter core.</strong> -</p> - -<p class="important"><strong>Note:</strong> Messing with a core system class has a lot of implications, so make sure you -know what you are doing before attempting it.</p> - - -<h2>System Class List</h2> - -<p>The following is a list of the core system files that are invoked every time CodeIgniter runs:</p> - -<ul> -<li>Benchmark</li> -<li>Config</li> -<li>Controller</li> -<li>Exceptions</li> -<li>Hooks</li> -<li>Input</li> -<li>Language</li> -<li>Loader</li> -<li>Log</li> -<li>Output</li> -<li>Router</li> -<li>URI</li> -<li>Utf8</li> -</ul> - -<h2>Replacing Core Classes</h2> - -<p>To use one of your own system classes instead of a default one simply place your version inside your local <dfn>application/core</dfn> directory:</p> - -<code>application/core/<dfn>some-class.php</dfn></code> - -<p>If this directory does not exist you can create it.</p> - -<p>Any file named identically to one from the list above will be used instead of the one normally used.</p> - -<p>Please note that your class must use <kbd>CI</kbd> as a prefix. For example, if your file is named <kbd>Input.php</kbd> the class will be named:</p> - -<code> -class CI_Input {<br /><br /> - -} -</code> - - - -<h2>Extending Core Class</h2> - -<p>If all you need to do is add some functionality to an existing library - perhaps add a function or two - then -it's overkill to replace the entire library with your version. In this case it's better to simply extend the class. -Extending a class is nearly identical to replacing a class with a couple exceptions:</p> - -<ul> -<li>The class declaration must extend the parent class.</li> -<li>Your new class name and filename must be prefixed with <kbd>MY_</kbd> (this item is configurable. See below.).</li> -</ul> - -<p>For example, to extend the native <kbd>Input</kbd> class you'll create a file named <dfn>application/core/</dfn><kbd>MY_Input.php</kbd>, and declare your class with:</p> - -<code> -class MY_Input extends CI_Input {<br /><br /> - -}</code> - -<p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p> - -<code> -class MY_Input extends CI_Input {<br /> -<br /> - function __construct()<br /> - {<br /> - parent::__construct();<br /> - }<br /> -}</code> - -<p class="important"><strong>Tip:</strong> Any functions in your class that are named identically to the functions in the parent class will be used instead of the native ones -(this is known as "method overriding"). -This allows you to substantially alter the CodeIgniter core.</p> - -<p>If you are extending the Controller core class, then be sure to extend your new class in your application controller's constructors.</p> - -<code>class Welcome extends MY_Controller {<br /> -<br /> - function __construct()<br /> - {<br /> - parent::__construct();<br /> - }<br /> -<br /> - function index()<br /> - {<br /> - $this->load->view('welcome_message');<br /> - }<br /> -}</code> - -<h3>Setting Your Own Prefix</h3> - -<p>To set your own sub-class prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p> - -<code>$config['subclass_prefix'] = 'MY_';</code> - -<p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p> - - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="creating_libraries.html">Creating Your Own Libraries</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="hooks.html">Hooks - Extending the Core</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/creating_drivers.html b/user_guide/general/creating_drivers.html deleted file mode 100644 index 367755452..000000000 --- a/user_guide/general/creating_drivers.html +++ /dev/null @@ -1,100 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Creating Drivers : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Creating Drivers -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Creating Drivers</h1> - -<h2>Driver Directory and File Structure</h2> - -<p>Sample driver directory and file structure layout:</p> - -<ul> - <li>/application/libraries/Driver_name - <ul> - <li>Driver_name.php</li> - <li>drivers - <ul> - <li>Driver_name_subclass_1.php</li> - <li>Driver_name_subclass_2.php</li> - <li>Driver_name_subclass_3.php</li> - </ul> - </li> - </ul> - </li> -</ul> - -<p class="important"><strong>NOTE:</strong> In order to maintain compatibility on case-sensitive file systems, the <samp>Driver_name</samp> directory must be <var>ucfirst()</var></p> - -<!-- @todo write this! --> - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="drivers.html">Using CodeIgniter Drivers</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="core_classes.html">Creating Core System Classes</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html deleted file mode 100644 index aeec871b2..000000000 --- a/user_guide/general/creating_libraries.html +++ /dev/null @@ -1,293 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Creating Libraries : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Creating Libraries -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Creating Libraries</h1> - -<p>When we use the term "Libraries" we are normally referring to the classes that are located in the <kbd>libraries</kbd> -directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create -your own libraries within your <dfn>application/libraries</dfn> directory in order to maintain separation between your local resources -and the global framework resources.</p> - -<p>As an added bonus, CodeIgniter permits your libraries to <kbd>extend</kbd> native classes if you simply need to add some functionality -to an existing library. Or you can even replace native libraries just by placing identically named versions in your <dfn>application/libraries</dfn> folder.</p> - -<p>In summary:</p> - -<ul> -<li>You can create entirely new libraries.</li> -<li>You can extend native libraries.</li> -<li>You can replace native libraries.</li> -</ul> - -<p>The page below explains these three concepts in detail.</p> - -<p class="important"><strong>Note:</strong> The Database classes can not be extended or replaced with your own classes. All other classes are able to be replaced/extended.</p> - - -<h2>Storage</h2> - -<p>Your library classes should be placed within your <dfn>application/libraries</dfn> folder, as this is where CodeIgniter will look for them when -they are initialized.</p> - - -<h2>Naming Conventions</h2> - -<ul> -<li>File names must be capitalized. For example: <dfn>Myclass.php</dfn></li> -<li>Class declarations must be capitalized. For example: <kbd>class Myclass</kbd></li> -<li>Class names and file names must match.</li> -</ul> - - -<h2>The Class File</h2> - -<p>Classes should have this basic prototype (Note: We are using the name <kbd>Someclass</kbd> purely as an example):</p> - -<code><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -<br /><br /> -class Someclass {<br /> -<br /> - public function some_function()<br /> - {<br /> - }<br /> -}<br /><br /> -/* End of file Someclass.php */</code> - - -<h2>Using Your Class</h2> - -<p>From within any of your <a href="controllers.html">Controller</a> functions you can initialize your class using the standard:</p> - -<code>$this->load->library('<kbd>someclass</kbd>');</code> - -<p>Where <em>someclass</em> is the file name, without the ".php" file extension. You can submit the file name capitalized or lower case. -CodeIgniter doesn't care.</p> - -<p>Once loaded you can access your class using the <kbd>lower case</kbd> version:</p> - -<code>$this-><kbd>someclass</kbd>->some_function(); // Object instances will always be lower case -</code> - - - -<h2>Passing Parameters When Initializing Your Class</h2> - -<p>In the library loading function you can dynamically pass data as an array via the second parameter and it will be passed to your class -constructor:</p> - -<code> -$params = array('type' => 'large', 'color' => 'red');<br /> -<br /> -$this->load->library('Someclass', <kbd>$params</kbd>);</code> - -<p>If you use this feature you must set up your class constructor to expect data:</p> - -<code><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');<br /> -<br /> -class Someclass {<br /> -<br /> - public function __construct($params)<br /> - {<br /> - // Do something with $params<br /> - }<br /> -}<br /><br /> -?></code> - -<p class="important">You can also pass parameters stored in a config file. Simply create a config file named identically to the class <kbd>file name</kbd> -and store it in your <dfn>application/config/</dfn> folder. Note that if you dynamically pass parameters as described above, -the config file option will not be available.</p> - - - - - - - -<h2>Utilizing CodeIgniter Resources within Your Library</h2> - - -<p>To access CodeIgniter's native resources within your library use the <kbd>get_instance()</kbd> function. -This function returns the CodeIgniter super object.</p> - -<p>Normally from within your controller functions you will call any of the available CodeIgniter functions using the <kbd>$this</kbd> construct:</p> - -<code> -<strong>$this</strong>->load->helper('url');<br /> -<strong>$this</strong>->load->library('session');<br /> -<strong>$this</strong>->config->item('base_url');<br /> -etc. -</code> - -<p><kbd>$this</kbd>, however, only works directly within your controllers, your models, or your views. -If you would like to use CodeIgniter's classes from within your own custom classes you can do so as follows:</p> - - -<p>First, assign the CodeIgniter object to a variable:</p> - -<code>$CI =& get_instance();</code> - -<p>Once you've assigned the object to a variable, you'll use that variable <em>instead</em> of <kbd>$this</kbd>:</p> - -<code> -$CI =& get_instance();<br /> -<br /> -$CI->load->helper('url');<br /> -$CI->load->library('session');<br /> -$CI->config->item('base_url');<br /> -etc. -</code> - -<p class="important"><strong>Note:</strong> You'll notice that the above get_instance() function is being passed by reference: -<br /><br /> -<var>$CI =& get_instance();</var> -<br /> -<br /> -<kbd>This is very important.</kbd> Assigning by reference allows you to use the original CodeIgniter object rather than creating a copy of it.</p> - - -<h2>Replacing Native Libraries with Your Versions</h2> - -<p>Simply by naming your class files identically to a native library will cause CodeIgniter to use it instead of the native one. To use this -feature you must name the file and the class declaration exactly the same as the native library. For example, to replace the native <kbd>Email</kbd> library -you'll create a file named <dfn>application/libraries/Email.php</dfn>, and declare your class with:</p> - -<code> -class CI_Email {<br /><br /> - -}</code> - -<p>Note that most native classes are prefixed with <kbd>CI_</kbd>.</p> - -<p>To load your library you'll see the standard loading function:</p> - -<code>$this->load->library('<kbd>email</kbd>');</code> - -<p class="important"><strong>Note:</strong> At this time the Database classes can not be replaced with your own versions.</p> - - -<h2>Extending Native Libraries</h2> - -<p>If all you need to do is add some functionality to an existing library - perhaps add a function or two - then -it's overkill to replace the entire library with your version. In this case it's better to simply extend the class. -Extending a class is nearly identical to replacing a class with a couple exceptions:</p> - -<ul> -<li>The class declaration must extend the parent class.</li> -<li>Your new class name and filename must be prefixed with <kbd>MY_</kbd> (this item is configurable. See below.).</li> -</ul> - -<p>For example, to extend the native <kbd>Email</kbd> class you'll create a file named <dfn>application/libraries/</dfn><kbd>MY_Email.php</kbd>, and declare your class with:</p> - -<code> -class MY_Email extends CI_Email {<br /><br /> - -}</code> - -<p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p> - - -<code> -class MY_Email extends CI_Email {<br /> -<br /> - public function __construct()<br /> - {<br /> - parent::__construct();<br /> - }<br /> -}</code> - - -<h3>Loading Your Sub-class</h3> - -<p>To load your sub-class you'll use the standard syntax normally used. DO NOT include your prefix. For example, -to load the example above, which extends the Email class, you will use:</p> - -<code>$this->load->library('<kbd>email</kbd>');</code> - -<p>Once loaded you will use the class variable as you normally would for the class you are extending. In the case of -the email class all calls will use:</p> - - -<code>$this-><kbd>email</kbd>->some_function();</code> - - -<h3>Setting Your Own Prefix</h3> - -<p>To set your own sub-class prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p> - -<code>$config['subclass_prefix'] = 'MY_';</code> - -<p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="libraries.html">Using CodeIgniter Libraries</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="drivers.html">Using CodeIgniter Drivers</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/credits.html b/user_guide/general/credits.html deleted file mode 100644 index 2785e7f25..000000000 --- a/user_guide/general/credits.html +++ /dev/null @@ -1,87 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Credits : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Credits -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Credits</h1> - -<p>CodeIgniter was originally developed by <a href="http://www.ellislab.com/">Rick Ellis</a> (CEO of -<a href="http://ellislab.com/">EllisLab, Inc.</a>). The framework was written for performance in the real -world, with many of the class libraries, helpers, and sub-systems borrowed from the code-base of -<a href="http://www.expressionengine.com/">ExpressionEngine</a>.</p> - -<p>It is currently developed and maintained by the ExpressionEngine Development Team.<br /> -Bleeding edge development is spearheaded by the handpicked contributors of the Reactor Team.</p> - -<p>A hat tip goes to Ruby on Rails for inspiring us to create a PHP framework, and for -bringing frameworks into the general consciousness of the web community.</p> - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="../changelog.html">Change Log</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="../installation/downloads.html">Downloading CodeIgniter</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/drivers.html b/user_guide/general/drivers.html deleted file mode 100644 index d0e4a1f1b..000000000 --- a/user_guide/general/drivers.html +++ /dev/null @@ -1,104 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Using CodeIgniter Drivers : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Using CodeIgniter Drivers -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Using CodeIgniter Drivers</h1> - - -<p>Drivers are a special type of Library that has a parent class and any number of potential child classes. Child classes have access to the parent class, but not their siblings. Drivers provide an elegant syntax in your <a href="controllers.html">controllers</a> for libraries that benefit from or require being broken down into discrete classes.</p> - -<p>Drivers are found in the <dfn>system/libraries</dfn> folder, in their own folder which is identically named to the parent library class. Also inside that folder is a subfolder named <kbd>drivers</kbd>, which contains all of the possible child class files.</p> - -<p>To use a driver you will initialize it within a controller using the following initialization function:</p> - -<code>$this->load->driver('<var>class name</var>'); </code> - -<p>Where <var>class name</var> is the name of the driver class you want to invoke. For example, to load a driver named "Some Parent" you would do this:</p> - -<code>$this->load->driver('<var>some_parent</var>');</code> - -<p>Methods of that class can then be invoked with:</p> - -<code>$this->some_parent->some_method();</code> - -<p>The child classes, the drivers themselves, can then be called directly through the parent class, without initializing them:</p> - -<code>$this->some_parent->child_one->some_method();<br /> -$this->some_parent->child_two->another_method();</code> - -<h2>Creating Your Own Drivers</h2> - -<p>Please read the section of the user guide that discusses how to <a href="creating_drivers.html">create your own drivers</a>.</p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="creating_libraries.html">Creating Libraries</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="creating_drivers.html">Creating Drivers</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/environments.html b/user_guide/general/environments.html deleted file mode 100644 index 38ce862b4..000000000 --- a/user_guide/general/environments.html +++ /dev/null @@ -1,126 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Handling Multiple Environments : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Handling Multiple Environments -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Handling Multiple Environments</h1> - -<p> - Developers often desire different system behavior depending on whether - an application is running in a development or production - environment. For example, verbose error output is something that would - be useful while developing an application, but it may also pose a security issue when "live". -</p> - -<h2>The ENVIRONMENT Constant</h2> - -<p> - By default, CodeIgniter comes with the environment constant set to - '<kbd>development</kbd>'. At the top of index.php, you will see: -</p> - -<code> -define('<var>ENVIRONMENT</var>', '<var>development</var>'); -</code> - -<p> - In addition to affecting some basic framework behavior (see the next section), - you may use this constant in your own development to differentiate - between which environment you are running in. -</p> - -<h2>Effects On Default Framework Behavior</h2> - -<p> - There are some places in the CodeIgniter system where the <kbd>ENVIRONMENT</kbd> - constant is used. This section describes how default framework behavior is - affected. -</p> - -<h3>Error Reporting</h3> - -<p> - Setting the <kbd>ENVIRONMENT</kbd> constant to a value of '<kbd>development</kbd>' will - cause all PHP errors to be rendered to the browser when they occur. Conversely, - setting the constant to '<kbd>production</kbd>' will disable all error output. Disabling - error reporting in production is a <a href="security.html">good security practice</a>. -</p> - -<h3>Configuration Files</h3> - -<p> - Optionally, you can have CodeIgniter load environment-specific - configuration files. This may be useful for managing things like differing API keys - across multiple environments. This is described in more detail in the - environment section of the <a href="../libraries/config.html#environments">Config Class</a> documentation. -</p> - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="managing_apps.html">Managing Applications</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="alternative_php.html">Alternative PHP Syntax</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/errors.html b/user_guide/general/errors.html deleted file mode 100644 index 83725dcc5..000000000 --- a/user_guide/general/errors.html +++ /dev/null @@ -1,140 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Error Handling : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Error Handling -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Error Handling</h1> - -<p>CodeIgniter lets you build error reporting into your applications using the functions described below. -In addition, it has an error logging class that permits error and debugging messages to be saved as text files.</p> - -<p class="important"><strong>Note:</strong> By default, CodeIgniter displays all PHP errors. You might -wish to change this behavior once your development is complete. You'll find the <dfn>error_reporting()</dfn> -function located at the top of your main index.php file. Disabling error reporting will NOT prevent log files -from being written if there are errors.</p> - -<p>Unlike most systems in CodeIgniter, the error functions are simple procedural interfaces that are available -globally throughout the application. This approach permits error messages to get triggered without having to worry -about class/function scoping.</p> - -<p>The following functions let you generate errors:</p> - -<h2>show_error('<var>message</var>' [, int <var>$status_code</var>= 500 ] )</h2> -<p>This function will display the error message supplied to it using the following error template:</p> -<p><dfn>application/errors/</dfn><kbd>error_general.php</kbd></p> -<p>The optional parameter $status_code determines what HTTP status code should be sent with the error.</p> - -<h2>show_404('<var>page</var>' [, '<var>log_error</var>'])</h2> -<p>This function will display the 404 error message supplied to it using the following error template:</p> -<p><dfn>application/errors/</dfn><kbd>error_404.php</kbd></p> - -<p>The function expects the string passed to it to be the file path to the page that isn't found. -Note that CodeIgniter automatically shows 404 messages if controllers are not found.</p> - -<p>CodeIgniter automatically logs any show_404() calls. Setting the optional second parameter to FALSE will skip logging.</p> - - -<h2>log_message('<var>level</var>', '<samp>message</samp>')</h2> - -<p>This function lets you write messages to your log files. You must supply one of three "levels" -in the first parameter, indicating what type of message it is (debug, error, info), with the message -itself in the second parameter. Example:</p> - -<code> -if ($some_var == "")<br /> -{<br /> - log_message('error', 'Some variable did not contain a value.');<br /> -}<br /> -else<br /> -{<br /> - log_message('debug', 'Some variable was correctly set');<br /> -}<br /> -<br /> -log_message('info', 'The purpose of some variable is to provide some value.');<br /> -</code> - -<p>There are three message types:</p> - -<ol> -<li>Error Messages. These are actual errors, such as PHP errors or user errors.</li> -<li>Debug Messages. These are messages that assist in debugging. For example, if a class has been initialized, you could log this as debugging info.</li> -<li>Informational Messages. These are the lowest priority messages, simply giving information regarding some process. CodeIgniter doesn't natively generate any info messages but you may want to in your application.</li> -</ol> - - -<p class="important"><strong>Note:</strong> In order for the log file to actually be written, the - "logs" folder must be writable. In addition, you must set the "threshold" for logging in <dfn>application/config/config.php</dfn>. -You might, for example, only want error messages to be logged, and not the other two types. -If you set it to zero logging will be disabled.</p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="routing.html">URI Routing</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="caching.html">Page Caching</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/helpers.html b/user_guide/general/helpers.html deleted file mode 100644 index 3747eb7b9..000000000 --- a/user_guide/general/helpers.html +++ /dev/null @@ -1,185 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Helper Functions : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Helper Functions -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Helper Functions</h1> - -<p>Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular -category. There are <dfn>URL Helpers</dfn>, that assist in creating links, there are <dfn>Form Helpers</dfn> -that help you create form elements, <dfn>Text Helpers</dfn> perform various text formatting routines, -<dfn>Cookie Helpers</dfn> set and read cookies, <dfn>File Helpers</dfn> help you deal with files, etc. -</p> - -<p>Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. -Each helper function performs one specific task, with no dependence on other functions.</p> - -<p>CodeIgniter does not load Helper Files by default, so the first step in using -a Helper is to load it. Once loaded, it becomes globally available in your <a href="../general/controllers.html">controller</a> and <a href="../general/views.html">views</a>.</p> - -<p>Helpers are typically stored in your <dfn>system/helpers</dfn>, or <dfn>application/helpers </dfn>directory. CodeIgniter will look first in your <dfn>application/helpers</dfn> -directory. If the directory does not exist or the specified helper is not located there CI will instead look in your global -<dfn>system/helpers</dfn> folder.</p> - - -<h2>Loading a Helper</h2> - -<p>Loading a helper file is quite simple using the following function:</p> - -<code>$this->load->helper('<var>name</var>');</code> - -<p>Where <var>name</var> is the file name of the helper, without the .php file extension or the "helper" part.</p> - -<p>For example, to load the <dfn>URL Helper</dfn> file, which is named <var>url_helper.php</var>, you would do this:</p> - -<code>$this->load->helper('<var>url</var>');</code> - -<p>A helper can be loaded anywhere within your controller functions (or even within your View files, although that's not a good practice), -as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available -automatically in any function, or you can load a helper in a specific function that needs it.</p> - -<p class="important">Note: The Helper loading function above does not return a value, so don't try to assign it to a variable. Just use it as shown.</p> - - -<h2>Loading Multiple Helpers</h2> - -<p>If you need to load more than one helper you can specify them in an array, like this:</p> - -<code>$this->load->helper( <samp>array(</samp>'<var>helper1</var>', '<var>helper2</var>', '<var>helper3</var>'<samp>)</samp> );</code> - -<h2>Auto-loading Helpers</h2> - -<p>If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. -This is done by opening the <var>application/config/autoload.php</var> file and adding the helper to the autoload array.</p> - - -<h2>Using a Helper</h2> - -<p>Once you've loaded the Helper File containing the function you intend to use, you'll call it the way you would a standard PHP function.</p> - -<p>For example, to create a link using the <dfn>anchor()</dfn> function in one of your view files you would do this:</p> - -<code><?php echo anchor('blog/comments', 'Click Here');?></code> - -<p>Where "Click Here" is the name of the link, and "blog/comments" is the URI to the controller/function you wish to link to.</p> - -<h2>"Extending" Helpers</h2> - -<p>To "extend" Helpers, create a file in your <dfn>application/helpers/</dfn> folder with an identical name to the existing Helper, but prefixed with <kbd>MY_</kbd> (this item is configurable. See below.).</p> - -<p>If all you need to do is add some functionality to an existing helper - perhaps add a function or two, or change how a particular - helper function operates - then it's overkill to replace the entire helper with your version. In this case it's better to simply - "extend" the Helper. The term "extend" is used loosely since Helper functions are procedural and discrete and cannot be extended - in the traditional programmatic sense. Under the hood, this gives you the ability to add to the functions a Helper provides, - or to modify how the native Helper functions operate.</p> - -<p>For example, to extend the native <kbd>Array Helper</kbd> you'll create a file named <dfn>application/helpers/</dfn><kbd>MY_array_helper.php</kbd>, and add or override functions:</p> - -<code> -// any_in_array() is not in the Array Helper, so it defines a new function<br /> -function any_in_array($needle, $haystack)<br /> -{<br /> - $needle = (is_array($needle)) ? $needle : array($needle);<br /> - <br /> - foreach ($needle as $item)<br /> - {<br /> - if (in_array($item, $haystack))<br /> - {<br /> - return TRUE;<br /> - }<br /> - }<br /> - <br /> - return FALSE;<br /> -}<br /> -<br /> -// random_element() is included in Array Helper, so it overrides the native function<br /> -function random_element($array)<br /> -{<br /> - shuffle($array);<br /> - return array_pop($array);<br /> -}<br /> -</code> - -<h3>Setting Your Own Prefix</h3> - -<p>The filename prefix for "extending" Helpers is the same used to extend libraries and Core classes. To set your own prefix, open your <dfn>application/config/config.php</dfn> file and look for this item:</p> - -<code>$config['subclass_prefix'] = 'MY_';</code> - -<p>Please note that all native CodeIgniter libraries are prefixed with <kbd>CI_</kbd> so DO NOT use that as your prefix.</p> - - -<h2>Now What?</h2> - -<p>In the Table of Contents you'll find a list of all the available Helper Files. Browse each one to see what they do.</p> - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="models.html">Models</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="libraries.html">Using Libraries</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/hooks.html b/user_guide/general/hooks.html deleted file mode 100644 index c0d616c50..000000000 --- a/user_guide/general/hooks.html +++ /dev/null @@ -1,165 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Hooks : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Hooks - Extending the Framework Core -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Hooks - Extending the Framework Core</h1> - -<p>CodeIgniter's Hooks feature provides a means to tap into and modify the inner workings of the framework without hacking the core files. -When CodeIgniter runs it follows a specific execution process, diagramed in the <a href="../overview/appflow.html">Application Flow</a> page. -There may be instances, however, where you'd like to cause some action to take place at a particular stage in the execution process. -For example, you might want to run a script right before your controllers get loaded, or right after, or you might want to trigger one of -your own scripts in some other location. -</p> - -<h2>Enabling Hooks</h2> - -<p>The hooks feature can be globally enabled/disabled by setting the following item in the <kbd>application/config/config.php</kbd> file:</p> - -<code>$config['enable_hooks'] = TRUE;</code> - - -<h2>Defining a Hook</h2> - -<p>Hooks are defined in <dfn>application/config/hooks.php</dfn> file. Each hook is specified as an array with this prototype:</p> - -<code> -$hook['pre_controller'] = array(<br /> - 'class' => 'MyClass',<br /> - 'function' => 'Myfunction',<br /> - 'filename' => 'Myclass.php',<br /> - 'filepath' => 'hooks',<br /> - 'params' => array('beer', 'wine', 'snacks')<br /> - );</code> - -<p><strong>Notes:</strong><br />The array index correlates to the name of the particular hook point you want to -use. In the above example the hook point is <kbd>pre_controller</kbd>. A list of hook points is found below. -The following items should be defined in your associative hook array:</p> - -<ul> -<li><strong>class</strong> The name of the class you wish to invoke. If you prefer to use a procedural function instead of a class, leave this item blank.</li> -<li><strong>function</strong> The function name you wish to call.</li> -<li><strong>filename</strong> The file name containing your class/function.</li> -<li><strong>filepath</strong> The name of the directory containing your script. Note: Your script must be located in a directory INSIDE your <kbd>application</kbd> folder, so the file path is relative to that folder. For example, if your script is located in <dfn>application/hooks</dfn>, you will simply use <samp>hooks</samp> as your filepath. If your script is located in <dfn>application/hooks/utilities</dfn> you will use <samp>hooks/utilities</samp> as your filepath. No trailing slash.</li> -<li><strong>params</strong> Any parameters you wish to pass to your script. This item is optional.</li> -</ul> - - -<h2>Multiple Calls to the Same Hook</h2> - -<p>If want to use the same hook point with more then one script, simply make your array declaration multi-dimensional, like this:</p> - -<code> -$hook['pre_controller']<kbd>[]</kbd> = array(<br /> - 'class' => 'MyClass',<br /> - 'function' => 'Myfunction',<br /> - 'filename' => 'Myclass.php',<br /> - 'filepath' => 'hooks',<br /> - 'params' => array('beer', 'wine', 'snacks')<br /> - );<br /> -<br /> -$hook['pre_controller']<kbd>[]</kbd> = array(<br /> - 'class' => 'MyOtherClass',<br /> - 'function' => 'MyOtherfunction',<br /> - 'filename' => 'Myotherclass.php',<br /> - 'filepath' => 'hooks',<br /> - 'params' => array('red', 'yellow', 'blue')<br /> - );</code> - -<p>Notice the brackets after each array index:</p> - -<code>$hook['pre_controller']<kbd>[]</kbd></code> - -<p>This permits you to have the same hook point with multiple scripts. The order you define your array will be the execution order.</p> - - -<h2>Hook Points</h2> - -<p>The following is a list of available hook points.</p> - -<ul> - <li><strong>pre_system</strong><br /> - Called very early during system execution. Only the benchmark and hooks class have been loaded at this point. No routing or other processes have happened.</li> - <li><strong>pre_controller</strong><br /> - Called immediately prior to any of your controllers being called. All base classes, routing, and security checks have been done.</li> - <li><strong>post_controller_constructor</strong><br /> - Called immediately after your controller is instantiated, but prior to any method calls happening.</li> - <li><strong>post_controller</strong><br /> - Called immediately after your controller is fully executed.</li> - <li><strong>display_override</strong><br /> - Overrides the <dfn>_display()</dfn> function, used to send the finalized page to the web browser at the end of system execution. This permits you to - use your own display methodology. Note that you will need to reference the CI superobject with <dfn>$this->CI =& get_instance()</dfn> and then the finalized data will be available by calling <dfn>$this->CI->output->get_output()</dfn></li> - <li><strong>cache_override</strong><br /> - Enables you to call your own function instead of the <dfn>_display_cache()</dfn> function in the output class. This permits you to use your own cache display mechanism.</li> - <li><strong>post_system</strong><br /> - Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.</li> - </ul> -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="core_classes.html">Creating Core Classes</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="autoloader.html">Auto-loading Resources</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/libraries.html b/user_guide/general/libraries.html deleted file mode 100644 index 40533e124..000000000 --- a/user_guide/general/libraries.html +++ /dev/null @@ -1,98 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Using CodeIgniter Libraries : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Using CodeIgniter Libraries -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Using CodeIgniter Libraries</h1> - - -<p>All of the available libraries are located in your <dfn>system/libraries</dfn> folder. -In most cases, to use one of these classes involves initializing it within a <a href="controllers.html">controller</a> using the following initialization function:</p> - -<code>$this->load->library('<var>class name</var>'); </code> - -<p>Where <var>class name</var> is the name of the class you want to invoke. For example, to load the form validation class you would do this:</p> - -<code>$this->load->library('<var>form_validation</var>'); </code> - -<p>Once initialized you can use it as indicated in the user guide page corresponding to that class.</p> - -<p>Additionally, multiple libraries can be loaded at the same time by passing an array of libraries to the load function.</p> - -<code>$this->load->library(array('<var>email</var>', '<var>table</var>'));</code> - -<h2>Creating Your Own Libraries</h2> - -<p>Please read the section of the user guide that discusses how to <a href="creating_libraries.html">create your own libraries</a></p> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="helpers.html">Helpers</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="creating_libraries.html">Creating Libraries</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/managing_apps.html b/user_guide/general/managing_apps.html deleted file mode 100644 index e716d1072..000000000 --- a/user_guide/general/managing_apps.html +++ /dev/null @@ -1,133 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Managing your Applications : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Managing your Applications -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Managing your Applications</h1> - -<p>By default it is assumed that you only intend to use CodeIgniter to manage one application, which you will build in your -<dfn>application/</dfn> directory. It is possible, however, to have multiple sets of applications that share a single -CodeIgniter installation, or even to rename or relocate your <dfn>application</dfn> folder.</p> - -<h2>Renaming the Application Folder</h2> - -<p>If you would like to rename your <dfn>application</dfn> folder you may do so as long as you open your main <kbd>index.php</kbd> -file and set its name using the <samp>$application_folder</samp> variable:</p> - -<code>$application_folder = "application";</code> - -<h2>Relocating your Application Folder</h2> - -<p>It is possible to move your <dfn>application</dfn> folder to a different location on your server than your <kbd>system</kbd> folder. -To do so open your main <kbd>index.php</kbd> and set a <em>full server path</em> in the <samp>$application_folder</samp> variable.</p> - - -<code>$application_folder = "/Path/to/your/application";</code> - - -<h2>Running Multiple Applications with one CodeIgniter Installation</h2> - -<p>If you would like to share a common CodeIgniter installation to manage several different applications simply -put all of the directories located inside your <kbd>application</kbd> folder into their -own sub-folder.</p> - -<p>For example, let's say you want to create two applications, "foo" and "bar". You could structure your -application folders like this:</p> - -<code>applications/<var>foo</var>/<br /> -applications/<var>foo</var>/config/<br /> -applications/<var>foo</var>/controllers/<br /> -applications/<var>foo</var>/errors/<br /> -applications/<var>foo</var>/libraries/<br /> -applications/<var>foo</var>/models/<br /> -applications/<var>foo</var>/views/<br /> -applications/<samp>bar</samp>/<br /> -applications/<samp>bar</samp>/config/<br /> -applications/<samp>bar</samp>/controllers/<br /> -applications/<samp>bar</samp>/errors/<br /> -applications/<samp>bar</samp>/libraries/<br /> -applications/<samp>bar</samp>/models/<br /> -applications/<samp>bar</samp>/views/</code> - - -<p>To select a particular application for use requires that you open your main <kbd>index.php</kbd> file and set the <dfn>$application_folder</dfn> -variable. For example, to select the "foo" application for use you would do this:</p> - -<code>$application_folder = "applications/foo";</code> - -<p class="important"><strong>Note:</strong> Each of your applications will need its own <dfn>index.php</dfn> file which -calls the desired application. The index.php file can be named anything you want.</p> - - - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="profiling.html">Profiling Your Application</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="alternative_php.html">Alternative PHP Syntax</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/models.html b/user_guide/general/models.html deleted file mode 100644 index 1696f424a..000000000 --- a/user_guide/general/models.html +++ /dev/null @@ -1,251 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Models : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Models -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Models</h1> - -<p>Models are <strong>optionally</strong> available for those who want to use a more traditional MVC approach.</p> - - - -<ul> -<li><a href="#what">What is a Model?</a></li> -<li><a href="#anatomy">Anatomy of a Model</a></li> -<li><a href="#loading">Loading a Model</a></li> -<li><a href="#auto_load_model">Auto-Loading a Model</a> </li> -<li><a href="#conn">Connecting to your Database</a></li> -</ul> - - - -<h2><a name="what"></a>What is a Model?</h2> - -<p>Models are PHP classes that are designed to work with information in your database. For example, let's say -you use CodeIgniter to manage a blog. You might have a model class that contains functions to insert, update, and -retrieve your blog data. Here is an example of what such a model class might look like:</p> - -<code> -class Blogmodel extends CI_Model {<br /> -<br /> - var $title = '';<br /> - var $content = '';<br /> - var $date = '';<br /> -<br /> - function __construct()<br /> - {<br /> - // Call the Model constructor<br /> - parent::__construct();<br /> - }<br /> - <br /> - function get_last_ten_entries()<br /> - {<br /> - $query = $this->db->get('entries', 10);<br /> - return $query->result();<br /> - }<br /> -<br /> - function insert_entry()<br /> - {<br /> - $this->title = $_POST['title']; // please read the below note<br /> - $this->content = $_POST['content'];<br /> - $this->date = time();<br /> -<br /> - $this->db->insert('entries', $this);<br /> - }<br /> -<br /> - function update_entry()<br /> - {<br /> - $this->title = $_POST['title'];<br /> - $this->content = $_POST['content'];<br /> - $this->date = time();<br /> -<br /> - $this->db->update('entries', $this, array('id' => $_POST['id']));<br /> - }<br /> -<br /> -}</code> - -<p>Note: The functions in the above example use the <a href="../database/active_record.html">Active Record</a> database functions.</p> -<p class="important"><strong>Note:</strong> For the sake of simplicity in this example we're using $_POST directly. This is generally bad practice, and a more common approach would be to use the <a href="../libraries/input.html">Input Class</a> $this->input->post('title')</p> -<h2><a name="anatomy"></a>Anatomy of a Model</h2> - -<p>Model classes are stored in your <dfn>application/models/</dfn> folder. They can be nested within sub-folders if you -want this type of organization.</p> - -<p>The basic prototype for a model class is this:</p> - - -<code> -class <var>Model_name</var> extends CI_Model {<br /> -<br /> - function <var>__construct</var>()<br /> - {<br /> - parent::__construct();<br /> - }<br /> -}</code> - -<p>Where <var>Model_name</var> is the name of your class. Class names <strong>must</strong> have the first letter capitalized with the rest of the name lowercase. -Make sure your class extends the base Model class.</p> - -<p>The file name will be a lower case version of your class name. For example, if your class is this:</p> - -<code> -class <var>User_model</var> extends CI_Model {<br /> -<br /> - function <var>__construct</var>()<br /> - {<br /> - parent::__construct();<br /> - }<br /> -}</code> - -<p>Your file will be this:</p> - -<code>application/models/<var>user_model.php</var></code> - - - -<h2><a name="loading"></a>Loading a Model</h2> - -<p>Your models will typically be loaded and called from within your <a href="controllers.html">controller</a> functions. -To load a model you will use the following function:</p> - -<code>$this->load->model('<var>Model_name</var>');</code> - -<p>If your model is located in a sub-folder, include the relative path from your models folder. For example, if -you have a model located at <dfn>application/models/blog/queries.php</dfn> you'll load it using:</p> - -<code>$this->load->model('<var>blog/queries</var>');</code> - - -<p>Once loaded, you will access your model functions using an object with the same name as your class:</p> - -<code> -$this->load->model('<var>Model_name</var>');<br /> -<br /> -$this-><var>Model_name</var>->function(); -</code> - -<p>If you would like your model assigned to a different object name you can specify it via the second parameter of the loading -function:</p> - - -<code> -$this->load->model('<var>Model_name</var>', '<kbd>fubar</kbd>');<br /> -<br /> -$this-><kbd>fubar</kbd>->function(); -</code> - -<p>Here is an example of a controller, that loads a model, then serves a view:</p> - -<code> -class Blog_controller extends CI_Controller {<br /> -<br /> - function blog()<br /> - {<br /> - $this->load->model('Blog');<br /> -<br /> - $data['query'] = $this->Blog->get_last_ten_entries();<br /><br /> - $this->load->view('blog', $data);<br /> - }<br /> -}</code> - -<h2><a name="auto_load_model" id="auto_load_model"></a>Auto-loading Models</h2> -<p>If you find that you need a particular model globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the application/config/autoload.php file and adding the model to the autoload array.</p> - - -<h2><a name="conn"></a>Connecting to your Database</h2> - -<p>When a model is loaded it does <strong>NOT</strong> connect automatically to your database. The following options for connecting are available to you:</p> - -<ul> -<li>You can connect using the standard database methods <a href="../database/connecting.html">described here</a>, either from within your Controller class or your Model class.</li> -<li>You can tell the model loading function to auto-connect by passing <kbd>TRUE</kbd> (boolean) via the third parameter, -and connectivity settings, as defined in your database config file will be used: - - <code>$this->load->model('<var>Model_name</var>', '', <kbd>TRUE</kbd>);</code> - </li> - - -<li>You can manually pass database connectivity settings via the third parameter: - - - <code>$config['hostname'] = "localhost";<br /> - $config['username'] = "myusername";<br /> - $config['password'] = "mypassword";<br /> - $config['database'] = "mydatabase";<br /> - $config['dbdriver'] = "mysql";<br /> - $config['dbprefix'] = "";<br /> - $config['pconnect'] = FALSE;<br /> - $config['db_debug'] = TRUE;<br /> - <br /> - $this->load->model('<var>Model_name</var>', '', <kbd>$config</kbd>);</code></li> -</ul> - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="views.html">Views</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="helpers.html">Helpers</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/profiling.html b/user_guide/general/profiling.html deleted file mode 100644 index 9895b0284..000000000 --- a/user_guide/general/profiling.html +++ /dev/null @@ -1,181 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Profiling Your Application : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Profiling Your Application -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Profiling Your Application</h1> - -<p>The Profiler Class will display benchmark results, queries you have run, and $_POST data at the bottom of your pages. -This information can be useful during development in order to help with debugging and optimization.</p> - - -<h2>Initializing the Class</h2> - -<p class="important"><strong>Important:</strong> This class does <kbd>NOT</kbd> need to be initialized. It is loaded automatically by the -<a href="../libraries/output.html">Output Class</a> if profiling is enabled as shown below.</p> - -<h2>Enabling the Profiler</h2> - - <p>To enable the profiler place the following function anywhere within your <a href="controllers.html">Controller</a> functions:</p> - <code>$this->output->enable_profiler(TRUE);</code> - - <p>When enabled a report will be generated and inserted at the bottom of your pages.</p> - - <p>To disable the profiler you will use:</p> - <code>$this->output->enable_profiler(FALSE);</code> - - -<h2>Setting Benchmark Points</h2> - - <p>In order for the Profiler to compile and display your benchmark data you must name your mark points using specific syntax.</p> - - <p>Please read the information on setting Benchmark points in <a href="../libraries/benchmark.html">Benchmark Class</a> page.</p> - - -<h2>Enabling and Disabling Profiler Sections</h2> - - <p>Each section of Profiler data can be enabled or disabled by setting a corresponding config variable to <var>TRUE</var> or <var>FALSE</var>. This can be done one of two ways. First, you can set application wide defaults with the <dfn>application/config/profiler.php</dfn> config file.</p> - - <code>$config['config'] = FALSE;<br /> - $config['queries'] = FALSE;<br /></code> - - <p>In your controllers, you can override the defaults and config file values by calling the <kbd>set_profiler_sections()</kbd> method of the <a href="../libraries/output.html">Output class</a>:</p> - - <code>$sections = array(<br /> - 'config' => TRUE,<br /> - 'queries' => TRUE<br /> - );<br /> - <br /> - $this->output->set_profiler_sections($sections);</code> - - <p>Available sections and the array key used to access them are described in the table below.</p> - - <table cellpadding="0" cellspacing="1" border="0" style="width:100%" class="tableborder"> - <tr> - <th>Key</th> - <th>Description</th> - <th>Default</th> - </tr> - <tr> - <td class="td"><strong>benchmarks</strong></td> - <td class="td">Elapsed time of Benchmark points and total execution time</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>config</strong></td> - <td class="td">CodeIgniter Config variables</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>controller_info</strong></td> - <td class="td">The Controller class and method requested</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>get</strong></td> - <td class="td">Any GET data passed in the request</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>http_headers</strong></td> - <td class="td">The HTTP headers for the current request</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>memory_usage</strong></td> - <td class="td">Amount of memory consumed by the current request, in bytes</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>post</strong></td> - <td class="td">Any POST data passed in the request</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>queries</strong></td> - <td class="td">Listing of all database queries executed, including execution time</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>uri_string</strong></td> - <td class="td">The URI of the current request</td> - <td class="td">TRUE</td> - </tr> - <tr> - <td class="td"><strong>query_toggle_count</strong></td> - <td class="td">The number of queries after which the query block will default to hidden.</td> - <td class="td">25</td> - </tr> - </table> - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="caching.html">Caching</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="managing_apps.html">Managing Applications</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/quick_reference.html b/user_guide/general/quick_reference.html deleted file mode 100644 index 242e9afb8..000000000 --- a/user_guide/general/quick_reference.html +++ /dev/null @@ -1,77 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Quick Reference Chart : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Quick Reference Chart -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Quick Reference Chart</h1> - -<p>For a PDF version of this chart, <a href="http://codeigniter.com/download_files/ci_quick_ref.pdf">click here</a>.</p> - -<p><img src="../images/ci_quick_ref.png" width="763" height="994" border="0" /></p> - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/requirements.html b/user_guide/general/requirements.html deleted file mode 100644 index 405798f04..000000000 --- a/user_guide/general/requirements.html +++ /dev/null @@ -1,82 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Server Requirements : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Server Requirements -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Server Requirements</h1> - -<ul> - <li><a href="http://www.php.net/">PHP</a> version 5.1.6 or newer.</li> - <li>A Database is required for most web application programming. Current supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, SQLite, and ODBC.</li> -</ul> - - - -</div> -<!-- END CONTENT --> - - - -<div id="footer"> -<p> -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="../license.html">License Agreement</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/reserved_names.html b/user_guide/general/reserved_names.html deleted file mode 100644 index 91d93a03b..000000000 --- a/user_guide/general/reserved_names.html +++ /dev/null @@ -1,128 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Reserved Names : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Controllers -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Reserved Names</h1> - -<p>In order to help out, CodeIgniter uses a series of functions and names in its operation. Because of this, some names cannot be used by a developer. Following is a list of reserved names that cannot be used.</p> -<h3>Controller names</h3> -<p>Since your controller classes will extend the main application controller you -must be careful not to name your functions identically to the ones used by that class, otherwise your local functions -will override them. The following -is a list of reserved names. Do not name your controller any of these:</p> -<ul> - <li>Controller</li> - <li>CI_Base</li> - <li>_ci_initialize</li> - <li>Default</li> - <li>index</li> -</ul> -<h3>Functions</h3> -<ul> - <li>is_really_writable()</li> - <li>load_class()</li> - <li>get_config()</li> - <li>config_item()</li> - <li>show_error()</li> - <li>show_404()</li> - <li>log_message()</li> - <li>_exception_handler()</li> - <li>get_instance()</li> - </ul> -<h3>Variables</h3> -<ul> - <li>$config</li> - <li>$mimes</li> - <li>$lang</li> -</ul> -<h3>Constants</h3> -<ul> - <li>ENVIRONMENT</li> - <li>EXT</li> - <li>FCPATH</li> - <li>SELF</li> - <li>BASEPATH</li> - <li>APPPATH</li> - <li>CI_VERSION</li> - <li>FILE_READ_MODE</li> - <li>FILE_WRITE_MODE</li> - <li>DIR_READ_MODE</li> - <li>DIR_WRITE_MODE</li> - <li>FOPEN_READ</li> - <li>FOPEN_READ_WRITE</li> - <li>FOPEN_WRITE_CREATE_DESTRUCTIVE</li> - <li>FOPEN_READ_WRITE_CREATE_DESTRUCTIVE</li> - <li>FOPEN_WRITE_CREATE</li> - <li>FOPEN_READ_WRITE_CREATE</li> - <li>FOPEN_WRITE_CREATE_STRICT</li> - <li>FOPEN_READ_WRITE_CREATE_STRICT</li> -</ul> -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="controllers.html">Controllers</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="views.html">Views</a></p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/routing.html b/user_guide/general/routing.html deleted file mode 100644 index c6429628e..000000000 --- a/user_guide/general/routing.html +++ /dev/null @@ -1,171 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>URI Routing : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -URI Routing -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>URI Routing</h1> - -<p>Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method. -The segments in a URI normally follow this pattern:</p> - -<code>example.com/<dfn>class</dfn>/<samp>function</samp>/<var>id</var>/</code> - -<p>In some instances, however, you may want to remap this relationship so that a different class/function can be called -instead of the one corresponding to the URL.</p> - -<p>For example, lets say you want your URLs to have this prototype:</p> - -<p> -example.com/product/1/<br /> -example.com/product/2/<br /> -example.com/product/3/<br /> -example.com/product/4/ -</p> - -<p>Normally the second segment of the URL is reserved for the function name, but in the example above it instead has a product ID. -To overcome this, CodeIgniter allows you to remap the URI handler.</p> - - -<h2>Setting your own routing rules</h2> - -<p>Routing rules are defined in your <var>application/config/routes.php</var> file. In it you'll see an array called <dfn>$route</dfn> that -permits you to specify your own routing criteria. Routes can either be specified using <dfn>wildcards</dfn> or <dfn>Regular Expressions</dfn></p> - - -<h2>Wildcards</h2> - -<p>A typical wildcard route might look something like this:</p> - -<code>$route['product/:num'] = "catalog/product_lookup";</code> - -<p>In a route, the array key contains the URI to be matched, while the array value contains the destination it should be re-routed to. -In the above example, if the literal word "product" is found in the first segment of the URL, and a number is found in the second segment, -the "catalog" class and the "product_lookup" method are instead used.</p> - -<p>You can match literal values or you can use two wildcard types:</p> - -<p><strong>(:num)</strong> will match a segment containing only numbers.<br /> -<strong>(:any)</strong> will match a segment containing any character. -</p> - -<p class="important"><strong>Note:</strong> Routes will run in the order they are defined. -Higher routes will always take precedence over lower ones.</p> - -<h2>Examples</h2> - -<p>Here are a few routing examples:</p> - -<code>$route['journals'] = "blogs";</code> -<p>A URL containing the word "journals" in the first segment will be remapped to the "blogs" class.</p> - -<code>$route['blog/joe'] = "blogs/users/34";</code> -<p>A URL containing the segments blog/joe will be remapped to the "blogs" class and the "users" method. The ID will be set to "34".</p> - -<code>$route['product/(:any)'] = "catalog/product_lookup";</code> -<p>A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the "product_lookup" method.</p> - -<code>$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";</code> -<p>A URL with "product" as the first segment, and a number in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.</p> - -<p class="important"><strong>Important:</strong> Do not use leading/trailing slashes.</p> - -<h2>Regular Expressions</h2> - -<p>If you prefer you can use regular expressions to define your routing rules. Any valid regular expression is allowed, as are back-references.</p> - -<p class="important"><strong>Note:</strong> If you use back-references you must use the dollar syntax rather than the double backslash syntax.</p> - -<p>A typical RegEx route might look something like this:</p> - -<code>$route['products/([a-z]+)/(\d+)'] = "$1/id_$2";</code> - -<p>In the above example, a URI similar to <dfn>products/shirts/123</dfn> would instead call the <dfn>shirts</dfn> controller class and the <dfn>id_123</dfn> function.</p> - -<p>You can also mix and match wildcards with regular expressions.</p> - -<h2>Reserved Routes</h2> - -<p>There are two reserved routes:</p> - -<code>$route['default_controller'] = 'welcome';</code> - -<p>This route indicates which controller class should be loaded if the URI contains no data, which will be the case -when people load your root URL. In the above example, the "welcome" class would be loaded. You -are encouraged to always have a default route otherwise a 404 page will appear by default.</p> - -<code>$route['404_override'] = '';</code> - -<p>This route indicates which controller class should be loaded if the requested controller is not found. It will override the default 404 -error page. It won't affect to the <samp>show_404()</samp> function, which will continue loading the default <dfn>error_404.php</dfn> file at <var>application/errors/error_404.php</var>.</p> - -<p class="important"><strong>Important:</strong> The reserved routes must come before any wildcard or regular expression routes.</p> - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="common_functions.html">Common Functions</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="errors.html">Error Handling</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/security.html b/user_guide/general/security.html deleted file mode 100644 index 5685bfa89..000000000 --- a/user_guide/general/security.html +++ /dev/null @@ -1,164 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Security : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Security -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Security</h1> - -<p>This page describes some "best practices" regarding web security, and details -CodeIgniter's internal security features.</p> - - -<h2>URI Security</h2> - -<p>CodeIgniter is fairly restrictive regarding which characters it allows in your URI strings in order to help -minimize the possibility that malicious data can be passed to your application. URIs may only contain the following: -</p> - -<ul> -<li>Alpha-numeric text</li> -<li>Tilde: ~ </li> -<li>Period: .</li> -<li>Colon: :</li> -<li>Underscore: _</li> -<li>Dash: -</li> -</ul> - -<h2>Register_globals</h2> - -<p>During system initialization all global variables are unset, except those found in the $_GET, $_POST, and $_COOKIE arrays. The unsetting -routine is effectively the same as register_globals = off.</p> - -<a name="error_reporting"></a> -<h2>error_reporting</h2> - -<p> - In production environments, it is typically desirable to disable PHP's - error reporting by setting the internal error_reporting flag to a value of 0. This disables native PHP - errors from being rendered as output, which may potentially contain - sensitive information. -</p> - -<p> - Setting CodeIgniter's <kbd>ENVIRONMENT</kbd> constant in index.php to a - value of '<kbd>production</kbd>' will turn off these errors. In development - mode, it is recommended that a value of '<kbd>development</kbd>' is used. - More information about differentiating between environments can be found - on the <a href="environments.html">Handling Environments</a> page. -</p> - -<h2>magic_quotes_runtime</h2> - -<p>The magic_quotes_runtime directive is turned off during system initialization so that you don't have to remove slashes when -retrieving data from your database.</p> - -<h1>Best Practices</h1> - -<p>Before accepting any data into your application, whether it be POST data from a form submission, COOKIE data, URI data, -XML-RPC data, or even data from the SERVER array, you are encouraged to practice this three step approach:</p> - -<ol> -<li>Filter the data as if it were tainted.</li> -<li>Validate the data to ensure it conforms to the correct type, length, size, etc. (sometimes this step can replace step one)</li> -<li>Escape the data before submitting it into your database.</li> -</ol> - -<p>CodeIgniter provides the following functions to assist in this process:</p> - -<ul> - -<li><h2>XSS Filtering</h2> - -<p>CodeIgniter comes with a Cross Site Scripting filter. This filter looks for commonly -used techniques to embed malicious Javascript into your data, or other types of code that attempt to hijack cookies -or do other malicious things. The XSS Filter is described <a href="../libraries/security.html">here</a>. -</p> -</li> - -<li><h2>Validate the data</h2> - -<p>CodeIgniter has a <a href="../libraries/form_validation.html">Form Validation Class</a> that assists you in validating, filtering, and prepping -your data.</p> -</li> - -<li><h2>Escape all data before database insertion</h2> - -<p>Never insert information into your database without escaping it. Please see the section that discusses -<a href="../database/queries.html">queries</a> for more information.</p> - -</li> - -</ul> - - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="alternative_php.html">Alternative PHP</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="styleguide.html">PHP Style Guide</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/styleguide.html b/user_guide/general/styleguide.html deleted file mode 100644 index 25fab6547..000000000 --- a/user_guide/general/styleguide.html +++ /dev/null @@ -1,679 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Style Guide : CodeIgniter 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' /> - -<style type="text/css" media="screen"> - code { - white-space: pre; - } -</style> - -<script type="text/javascript" src="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Style Guide -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>General Style and Syntax</h1> - -<p>The following page describes the use of coding rules adhered to when developing CodeIgniter.</p> - - -<h2>Table of Contents</h2> -<ul class="minitoc"> - <li><a href="#file_format">File Format</a></li> - <li><a href="#php_closing_tag">PHP Closing Tag</a></li> - <li><a href="#class_and_method_naming">Class and Method Naming</a></li> - <li><a href="#variable_names">Variable Names</a></li> - <li><a href="#commenting">Commenting</a></li> - <li><a href="#constants">Constants</a></li> - <li><a href="#true_false_and_null">TRUE, FALSE, and NULL</a></li> - <li><a href="#logical_operators">Logical Operators</a></li> - <li><a href="#comparing_return_values_and_typecasting">Comparing Return Values and Typecasting</a></li> - <li><a href="#debugging_code">Debugging Code</a></li> - <li><a href="#whitespace_in_files">Whitespace in Files</a></li> - <li><a href="#compatibility">Compatibility</a></li> - <li><a href="#class_and_file_names_using_common_words">Class and File Names using Common Words</a></li> - <li><a href="#database_table_names">Database Table Names</a></li> - <li><a href="#one_file_per_class">One File per Class</a></li> - <li><a href="#whitespace">Whitespace</a></li> - <li><a href="#line_breaks">Line Breaks</a></li> - <li><a href="#code_indenting">Code Indenting</a></li> - <li><a href="#bracket_spacing">Bracket and Parenthetic Spacing</li> - <li><a href="#localized_text">Localized Text</a></li> - <li><a href="#private_methods_and_variables">Private Methods and Variables</a></li> - <li><a href="#php_errors">PHP Errors</a></li> - <li><a href="#short_open_tags">Short Open Tags</a></li> - <li><a href="#one_statement_per_line">One Statement Per Line</a></li> - <li><a href="#strings">Strings</a></li> - <li><a href="#sql_queries">SQL Queries</a></li> - <li><a href="#default_function_arguments">Default Function Arguments</a></li> -</ul> - -<li> - - <h2><a name="file_format"></a>File Format</h2> - <div class="guidelineDetails"> - <p>Files should be saved with Unicode (UTF-8) encoding. The <abbr title="Byte Order Mark">BOM</abbr> - should <em>not</em> be used. Unlike UTF-16 and UTF-32, there's no byte order to indicate in - a UTF-8 encoded file, and the <abbr title="Byte Order Mark">BOM</abbr> can have a negative side effect in PHP of sending output, - preventing the application from being able to set its own headers. Unix line endings should - be used (LF).</p> - - <p>Here is how to apply these settings in some of the more common text editors. Instructions for your - text editor may vary; check your text editor's documentation.</p> - - <h5>TextMate</h5> - - <ol> - <li>Open the Application Preferences</li> - <li>Click Advanced, and then the "Saving" tab</li> - <li>In "File Encoding", select "UTF-8 (recommended)"</li> - <li>In "Line Endings", select "LF (recommended)"</li> - <li><em>Optional:</em> Check "Use for existing files as well" if you wish to modify the line - endings of files you open to your new preference.</li> - </ol> - - <h5>BBEdit</h5> - - <ol> - <li>Open the Application Preferences</li> - <li>Select "Text Encodings" on the left.</li> - <li>In "Default text encoding for new documents", select "Unicode (UTF-8, no BOM)"</li> - <li><em>Optional:</em> In "If file's encoding can't be guessed, use", select - "Unicode (UTF-8, no BOM)"</li> - <li>Select "Text Files" on the left.</li> - <li>In "Default line breaks", select "Mac OS X and Unix (LF)"</li> - </ol> - </div> - - <h2><a name="php_closing_tag"></a>PHP Closing Tag</h2> - <div class="guidelineDetails"> - <p>The PHP closing tag on a PHP document <strong>?></strong> is optional to the PHP parser. However, if used, any whitespace following the closing tag, whether introduced - by the developer, user, or an FTP application, can cause unwanted output, PHP errors, or if the latter are suppressed, blank pages. For this reason, all PHP files should - <strong>OMIT</strong> the closing PHP tag, and instead use a comment block to mark the end of file and it's location relative to the application root. - This allows you to still identify a file as being complete and not truncated.</p> -<code><strong>INCORRECT</strong>: -<?php - -echo "Here's my code!"; - -?> - -<strong>CORRECT</strong>: -<?php - -echo "Here's my code!"; - -/* End of file myfile.php */ -/* Location: ./system/modules/mymodule/myfile.php */ -</code> - </div> - - - <h2><a name="class_and_method_naming"></a>Class and Method Naming</h2> - <div class="guidelineDetails"> - <p>Class names should always start with an uppercase letter. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.</p> - - <code><strong>INCORRECT</strong>: -class superclass -class SuperClass - -<strong>CORRECT</strong>: -class Super_class</code> - - - <code>class Super_class { - - function __construct() - { - - } -}</code> - - <p>Examples of improper and proper method naming:</p> - - <code><strong>INCORRECT</strong>: -function fileproperties() // not descriptive and needs underscore separator -function fileProperties() // not descriptive and uses CamelCase -function getfileproperties() // Better! But still missing underscore separator -function getFileProperties() // uses CamelCase -function get_the_file_properties_from_the_file() // wordy - -<strong>CORRECT</strong>: -function get_file_properties() // descriptive, underscore separator, and all lowercase letters</code> - - </div> - - - <h2><a name="variable_names"></a>Variable Names</h2> - <div class="guidelineDetails"> - <p>The guidelines for variable naming is very similar to that used for class methods. Namely, variables should contain only lowercase letters, use underscore separators, and be reasonably named to indicate their purpose and contents. Very short, non-word variables should only be used as iterators in for() loops.</p> -<code><strong>INCORRECT</strong>: -$j = 'foo'; // single letter variables should only be used in for() loops -$Str // contains uppercase letters -$bufferedText // uses CamelCasing, and could be shortened without losing semantic meaning -$groupid // multiple words, needs underscore separator -$name_of_last_city_used // too long - -<strong>CORRECT</strong>: -for ($j = 0; $j < 10; $j++) -$str -$buffer -$group_id -$last_city -</code> - </div> - - - <h2><a name="commenting"></a>Commenting</h2> - <div class="guidelineDetails"> - <p>In general, code should be commented prolifically. It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line. There is not a required format for comments, but the following are recommended.</p> - - <p><a href="http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.docblock">DocBlock</a> style comments preceding class and method declarations so they can be picked up by IDEs:</p> - -<code>/** - * Super Class - * - * @package Package Name - * @subpackage Subpackage - * @category Category - * @author Author Name - * @link http://example.com - */ -class Super_class {</code> - -<code>/** - * Encodes string for use in XML - * - * @access public - * @param string - * @return string - */ -function xml_encode($str)</code> - - <p>Use single line comments within code, leaving a blank line between large comment blocks and code.</p> - -<code>// break up the string by newlines -$parts = explode("\n", $str); - -// A longer comment that needs to give greater detail on what is -// occurring and why can use multiple single-line comments. Try to -// keep the width reasonable, around 70 characters is the easiest to -// read. Don't hesitate to link to permanent external resources -// that may provide greater detail: -// -// http://example.com/information_about_something/in_particular/ - -$parts = $this->foo($parts); -</code> - </div> - - - <h2><a name="constants"></a>Constants</h2> - <div class="guidelineDetails"> - <p>Constants follow the same guidelines as do variables, except constants should always be fully uppercase. <em>Always use CodeIgniter constants when appropriate, i.e. SLASH, LD, RD, PATH_CACHE, etc.</em></p> -<code><strong>INCORRECT</strong>: -myConstant // missing underscore separator and not fully uppercase -N // no single-letter constants -S_C_VER // not descriptive -$str = str_replace('{foo}', 'bar', $str); // should use LD and RD constants - -<strong>CORRECT</strong>: -MY_CONSTANT -NEWLINE -SUPER_CLASS_VERSION -$str = str_replace(LD.'foo'.RD, 'bar', $str); -</code> - </div> - - - <h2><a name="true_false_and_null"></a>TRUE, FALSE, and NULL</h2> - <div class="guidelineDetails"> - <p><strong>TRUE</strong>, <strong>FALSE</strong>, and <strong>NULL</strong> keywords should always be fully uppercase.</p> -<code><strong>INCORRECT</strong>: -if ($foo == true) -$bar = false; -function foo($bar = null) - -<strong>CORRECT</strong>: -if ($foo == TRUE) -$bar = FALSE; -function foo($bar = NULL)</code> - </div> - - - - <h2><a name="logical_operators"></a>Logical Operators</h2> - <div class="guidelineDetails"> - <p>Use of <strong>||</strong> is discouraged as its clarity on some output devices is low (looking like the number 11 for instance). - <strong>&&</strong> is preferred over <strong>AND</strong> but either are acceptable, and a space should always precede and follow <strong>!</strong>.</p> -<code><strong>INCORRECT</strong>: -if ($foo || $bar) -if ($foo AND $bar) // okay but not recommended for common syntax highlighting applications -if (!$foo) -if (! is_array($foo)) - -<strong>CORRECT</strong>: -if ($foo OR $bar) -if ($foo && $bar) // recommended -if ( ! $foo) -if ( ! is_array($foo)) -</code> - </div> - - - - <h2><a name="comparing_return_values_and_typecasting"></a>Comparing Return Values and Typecasting</h2> - <div class="guidelineDetails"> - <p>Some PHP functions return FALSE on failure, but may also have a valid return value of "" or 0, which would evaluate to FALSE in loose comparisons. Be explicit by comparing the variable type when using these return values in conditionals to ensure the return value is indeed what you expect, and not a value that has an equivalent loose-type evaluation.</p> - <p>Use the same stringency in returning and checking your own variables. Use <strong>===</strong> and <strong>!==</strong> as necessary. - -<code><strong>INCORRECT</strong>: -// If 'foo' is at the beginning of the string, strpos will return a 0, -// resulting in this conditional evaluating as TRUE -if (strpos($str, 'foo') == FALSE) - -<strong>CORRECT</strong>: -if (strpos($str, 'foo') === FALSE) -</code> - -<code><strong>INCORRECT</strong>: -function build_string($str = "") -{ - if ($str == "") // uh-oh! What if FALSE or the integer 0 is passed as an argument? - { - - } -} - -<strong>CORRECT</strong>: -function build_string($str = "") -{ - if ($str === "") - { - - } -}</code> - - <p>See also information regarding <a href="http://us3.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting">typecasting</a>, which can be quite useful. Typecasting has a slightly different effect which may be desirable. When casting a variable as a string, for instance, NULL and boolean FALSE variables become empty strings, 0 (and other numbers) become strings of digits, and boolean TRUE becomes "1":</p> - -<code>$str = (string) $str; // cast $str as a string</code> - - </div> - - - <h2><a name="debugging_code"></a>Debugging Code</h2> - <div class="guidelineDetails"> - <p>No debugging code can be left in place for submitted add-ons unless it is commented out, i.e. no var_dump(), print_r(), die(), and exit() calls that were used while creating the add-on, unless they are commented out.</p> - -<code>// print_r($foo);</code> - </div> - - - - <h2><a name="whitespace_in_files"></a>Whitespace in Files</h2> - <div class="guidelineDetails"> - <p>No whitespace can precede the opening PHP tag or follow the closing PHP tag. Output is buffered, so whitespace in your files can cause output to begin before CodeIgniter outputs its content, leading to errors and an inability for CodeIgniter to send proper headers. In the examples below, select the text with your mouse to reveal the incorrect whitespace.</p> - - <p><strong>INCORRECT</strong>:</p> -<code> -<?php - // ...there is whitespace and a linebreak above the opening PHP tag - // as well as whitespace after the closing PHP tag -?> -</code> - <p><strong>CORRECT</strong>:</p> -<code><?php - // this sample has no whitespace before or after the opening and closing PHP tags -?></code> - - </div> - - - <h2><a name="compatibility"></a>Compatibility</h2> - <div class="guidelineDetails"> - <p>Unless specifically mentioned in your add-on's documentation, all code must be compatible with PHP version 5.1+. Additionally, do not use PHP functions that require non-default libraries to be installed unless your code contains an alternative method when the function is not available, or you implicitly document that your add-on requires said PHP libraries.</p> - </div> - - - - <h2><a name="class_and_file_names_using_common_words"></a>Class and File Names using Common Words</h2> - <div class="guidelineDetails"> - <p>When your class or filename is a common word, or might quite likely be identically named in another PHP script, provide a unique prefix to help prevent collision. Always realize that your end users may be running other add-ons or third party PHP scripts. Choose a prefix that is unique to your identity as a developer or company.</p> - -<code><strong>INCORRECT</strong>: -class Email pi.email.php -class Xml ext.xml.php -class Import mod.import.php - -<strong>CORRECT</strong>: -class Pre_email pi.pre_email.php -class Pre_xml ext.pre_xml.php -class Pre_import mod.pre_import.php -</code> - </div> - - - <h2><a name="database_table_names"></a>Database Table Names</h2> - <div class="guidelineDetails"> - <p>Any tables that your add-on might use must use the 'exp_' prefix, followed by a prefix uniquely identifying you as the developer or company, and then a short descriptive table name. You do not need to be concerned about the database prefix being used on the user's installation, as CodeIgniter's database class will automatically convert 'exp_' to what is actually being used.</p> - -<code><strong>INCORRECT</strong>: -email_addresses // missing both prefixes -pre_email_addresses // missing exp_ prefix -exp_email_addresses // missing unique prefix - -<strong>CORRECT</strong>: -exp_pre_email_addresses -</code> - - <p class="important"><strong>NOTE:</strong> Be mindful that MySQL has a limit of 64 characters for table names. This should not be an issue as table names that would exceed this would likely have unreasonable names. For instance, the following table name exceeds this limitation by one character. Silly, no? <strong>exp_pre_email_addresses_of_registered_users_in_seattle_washington</strong> - </div> - - - - <h2><a name="one_file_per_class"></a>One File per Class</h2> - <div class="guidelineDetails"> - <p>Use separate files for each class your add-on uses, unless the classes are <em>closely related</em>. An example of CodeIgniter files that contains multiple classes is the Database class file, which contains both the DB class and the DB_Cache class, and the Magpie plugin, which contains both the Magpie and Snoopy classes.</p> - </div> - - - - <h2><a name="whitespace"></a>Whitespace</h2> - <div class="guidelineDetails"> - <p>Use tabs for whitespace in your code, not spaces. This may seem like a small thing, but using tabs instead of whitespace allows the developer looking at your code to have indentation at levels that they prefer and customize in whatever application they use. And as a side benefit, it results in (slightly) more compact files, storing one tab character versus, say, four space characters.</p> - </div> - - - - <h2><a name="line_breaks"></a>Line Breaks</h2> - <div class="guidelineDetails"> - <p>Files must be saved with Unix line breaks. This is more of an issue for developers who work in Windows, but in any case ensure that your text editor is setup to save files with Unix line breaks.</p> - </div> - - - - <h2><a name="code_indenting"></a>Code Indenting</h2> - <div class="guidelineDetails"> - <p>Use Allman style indenting. With the exception of Class declarations, braces are always placed on a line by themselves, and indented at the same level as the control statement that "owns" them.</p> - -<code><strong>INCORRECT</strong>: -function foo($bar) { - // ... -} - -foreach ($arr as $key => $val) { - // ... -} - -if ($foo == $bar) { - // ... -} else { - // ... -} - -for ($i = 0; $i < 10; $i++) - { - for ($j = 0; $j < 10; $j++) - { - // ... - } - } - -<strong>CORRECT</strong>: -function foo($bar) -{ - // ... -} - -foreach ($arr as $key => $val) -{ - // ... -} - -if ($foo == $bar) -{ - // ... -} -else -{ - // ... -} - -for ($i = 0; $i < 10; $i++) -{ - for ($j = 0; $j < 10; $j++) - { - // ... - } -}</code> - </div> - - - <h2><a name="bracket_spacing"></a>Bracket and Parenthetic Spacing</h2> - <div class="guidelineDetails"> - <p>In general, parenthesis and brackets should not use any additional spaces. The exception is that a space should always follow PHP control structures that accept arguments with parenthesis (declare, do-while, elseif, for, foreach, if, switch, while), to help distinguish them from functions and increase readability.</p> - -<code>INCORRECT: -$arr[ $foo ] = 'foo'; - -CORRECT: -$arr[$foo] = 'foo'; // no spaces around array keys - - -INCORRECT: -function foo ( $bar ) -{ - -} - -CORRECT: -function foo($bar) // no spaces around parenthesis in function declarations -{ - -} - - -INCORRECT: -foreach( $query->result() as $row ) - -CORRECT: -foreach ($query->result() as $row) // single space following PHP control structures, but not in interior parenthesis -</code> - </div> - - - - <h2><a name="localized_text"></a>Localized Text</h2> - <div class="guidelineDetails"> - <p>Any text that is output in the control panel should use language variables in your lang file to allow localization.</p> - -<code>INCORRECT: -return "Invalid Selection"; - -CORRECT: -return $this->lang->line('invalid_selection');</code> - </div> - - - - <h2><a name="private_methods_and_variables"></a>Private Methods and Variables</h2> - <div class="guidelineDetails"> - <p>Methods and variables that are only accessed internally by your class, such as utility and helper functions that your public methods use for code abstraction, should be prefixed with an underscore.</p> - -<code>convert_text() // public method -_convert_text() // private method</code> - </div> - - - - <h2><a name="php_errors"></a>PHP Errors</h2> - <div class="guidelineDetails"> - <p>Code must run error free and not rely on warnings and notices to be hidden to meet this requirement. For instance, never access a variable that you did not set yourself (such as $_POST array keys) without first checking to see that it isset().</p> - - <p>Make sure that while developing your add-on, error reporting is enabled for ALL users, and that display_errors is enabled in the PHP environment. You can check this setting with:</p> - -<code>if (ini_get('display_errors') == 1) -{ - exit "Enabled"; -}</code> - - <p>On some servers where display_errors is disabled, and you do not have the ability to change this in the php.ini, you can often enable it with:</p> - -<code>ini_set('display_errors', 1);</code> - - <p class="important"><strong>NOTE:</strong> Setting the <a href="http://us.php.net/manual/en/ref.errorfunc.php#ini.display-errors">display_errors</a> setting with ini_set() at runtime is not identical to having it enabled in the PHP environment. Namely, it will not have any effect if the script has fatal errors</p> - </div> - - - - <h2><a name="short_open_tags"></a>Short Open Tags</h2> - <div class="guidelineDetails"> - <p>Always use full PHP opening tags, in case a server does not have short_open_tag enabled.</p> - -<code><strong>INCORRECT</strong>: -<? echo $foo; ?> - -<?=$foo?> - -<strong>CORRECT</strong>: -<?php echo $foo; ?></code> - </div> - - - - <h2><a name="one_statement_per_line"></a>One Statement Per Line</h2> - <div class="guidelineDetails"> - <p>Never combine statements on one line.</p> - -<code><strong>INCORRECT</strong>: -$foo = 'this'; $bar = 'that'; $bat = str_replace($foo, $bar, $bag); - -<strong>CORRECT</strong>: -$foo = 'this'; -$bar = 'that'; -$bat = str_replace($foo, $bar, $bag); -</code> - </div> - - - - <h2><a name="strings"></a>Strings</h2> - <div class="guidelineDetails"> - <p>Always use single quoted strings unless you need variables parsed, and in cases where you do need variables parsed, use braces to prevent greedy token parsing. You may also use double-quoted strings if the string contains single quotes, so you do not have to use escape characters.</p> - -<code><strong>INCORRECT</strong>: -"My String" // no variable parsing, so no use for double quotes -"My string $foo" // needs braces -'SELECT foo FROM bar WHERE baz = \'bag\'' // ugly - -<strong>CORRECT</strong>: -'My String' -"My string {$foo}" -"SELECT foo FROM bar WHERE baz = 'bag'"</code> - </div> - - - - <h2><a name="sql_queries"></a>SQL Queries</h2> - <div class="guidelineDetails"> - <p>MySQL keywords are always capitalized: SELECT, INSERT, UPDATE, WHERE, AS, JOIN, ON, IN, etc.</p> - - <p>Break up long queries into multiple lines for legibility, preferably breaking for each clause.</p> - -<code><strong>INCORRECT</strong>: -// keywords are lowercase and query is too long for -// a single line (... indicates continuation of line) -$query = $this->db->query("select foo, bar, baz, foofoo, foobar as raboof, foobaz from exp_pre_email_addresses -...where foo != 'oof' and baz != 'zab' order by foobaz limit 5, 100"); - -<strong>CORRECT</strong>: -$query = $this->db->query("SELECT foo, bar, baz, foofoo, foobar AS raboof, foobaz - FROM exp_pre_email_addresses - WHERE foo != 'oof' - AND baz != 'zab' - ORDER BY foobaz - LIMIT 5, 100");</code> - </div> - - - - <h2><a name="default_function_arguments"></a>Default Function Arguments</h2> - <div class="guidelineDetails"> - <p>Whenever appropriate, provide function argument defaults, which helps prevent PHP errors with mistaken calls and provides common fallback values which can save a few lines of code. Example:</p> - -<code>function foo($bar = '', $baz = FALSE)</code> - </div> - - - -</div> - - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="security.html">Security</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="../doc_style/index.html">Writing Documentation</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/urls.html b/user_guide/general/urls.html deleted file mode 100644 index 580b5fc54..000000000 --- a/user_guide/general/urls.html +++ /dev/null @@ -1,151 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>CodeIgniter URLs : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -URLS -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>CodeIgniter URLs</h1> - -<p>By default, URLs in CodeIgniter are designed to be search-engine and human friendly. Rather than using the standard "query string" -approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a <strong>segment-based</strong> approach:</p> - -<code>example.com/<var>news</var>/<dfn>article</dfn>/<samp>my_article</samp></code> - -<p class="important"><strong>Note:</strong> Query string URLs can be optionally enabled, as described below.</p> - -<h2>URI Segments</h2> - -<p>The segments in the URL, in following with the Model-View-Controller approach, usually represent:</p> - -<code>example.com/<var>class</var>/<dfn>function</dfn>/<samp>ID</samp></code> - -<ol> -<li>The first segment represents the controller <strong>class</strong> that should be invoked.</li> -<li>The second segment represents the class <strong>function</strong>, or method, that should be called.</li> -<li>The third, and any additional segments, represent the ID and any variables that will be passed to the controller.</li> -</ol> - -<p>The <a href="../libraries/uri.html">URI Class</a> and the <a href="../helpers/url_helper.html">URL Helper</a> -contain functions that make it easy to work with your URI data. In addition, your URLs can be remapped using the -<a href="routing.html">URI Routing</a> feature for more flexibility.</p> - - - -<h2>Removing the index.php file</h2> - -<p>By default, the <strong>index.php</strong> file will be included in your URLs:</p> - -<code>example.com/<var>index.php</var>/news/article/my_article</code> - -<p>You can easily remove this file by using a .htaccess file with some simple rules. Here is an example - of such a file, using the "negative" method in which everything is redirected except the specified items:</p> - -<code>RewriteEngine on<br /> -RewriteCond $1 !^(index\.php|images|robots\.txt)<br /> -RewriteRule ^(.*)$ /index.php/$1 [L]</code> - -<p>In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as -a request for your index.php file.</p> - - -<h2>Adding a URL Suffix</h2> - -<p>In your <dfn>config/config.php</dfn> file you can specify a suffix that will be added to all URLs generated -by CodeIgniter. For example, if a URL is this:</p> - -<code>example.com/index.php/products/view/shoes</code> - -<p>You can optionally add a suffix, like <kbd>.html</kbd>, making the page appear to be of a certain type:</p> - -<code>example.com/index.php/products/view/shoes.html</code> - - -<h2>Enabling Query Strings</h2> - -<p>In some cases you might prefer to use query strings URLs:</p> - -<code>index.php?c=products&m=view&id=345</code> - -<p>CodeIgniter optionally supports this capability, which can be enabled in your <dfn>application/config.php</dfn> file. If you -open your config file you'll see these items:</p> - -<code>$config['enable_query_strings'] = FALSE;<br /> -$config['controller_trigger'] = 'c';<br /> -$config['function_trigger'] = 'm';</code> - -<p>If you change "enable_query_strings" to TRUE this feature will become active. Your controllers and functions will then -be accessible using the "trigger" words you've set to invoke your controllers and methods:</p> - -<code>index.php?c=controller&m=method</code> - -<p class="important"><strong>Please note:</strong> If you are using query strings you will have to build your own URLs, rather than utilizing -the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with -segment based URLs.</p> - - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="controllers.html">Controllers</a></p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file diff --git a/user_guide/general/views.html b/user_guide/general/views.html deleted file mode 100644 index a2273f862..000000000 --- a/user_guide/general/views.html +++ /dev/null @@ -1,274 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -<title>Views : CodeIgniter 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="../nav/nav.js"></script> -<script type="text/javascript" src="../nav/prototype.lite.js"></script> -<script type="text/javascript" src="../nav/moo.fx.js"></script> -<script type="text/javascript" src="../nav/user_guide_menu.js"></script> - -<meta http-equiv='expires' content='-1' /> -<meta http-equiv= 'pragma' content='no-cache' /> -<meta name='robots' content='all' /> -<meta name='author' content='ExpressionEngine Dev Team' /> -<meta name='description' content='CodeIgniter 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_darker.jpg" width="154" height="43" 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>CodeIgniter User Guide Version 2.0.3</h1></td> -<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</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://codeigniter.com/">CodeIgniter Home</a> › -<a href="../index.html">User Guide Home</a> › -Views -</td> -<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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>Views</h1> - -<p>A <dfn>view</dfn> is simply a web page, or a page fragment, like a header, footer, sidebar, etc. -In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type -of hierarchy.</p> - -<p>Views are never called directly, they must be loaded by a <a href="controllers.html">controller</a>. Remember that in an MVC framework, the Controller acts as the -traffic cop, so it is responsible for fetching a particular view. If you have not read the <a href="controllers.html">Controllers</a> page -you should do so before continuing.</p> - -<p>Using the example controller you created in the <a href="controllers.html">controller</a> page, let's add a view to it.</p> - -<h2>Creating a View</h2> - -<p>Using your text editor, create a file called <dfn>blogview.php</dfn>, and put this in it:</p> - -<textarea class="textarea" style="width:100%" cols="50" rows="10"> -<html> -<head> -<title>My Blog</title> -</head> -<body> - <h1>Welcome to my Blog!</h1> -</body> -</html> -</textarea> - -<p>Then save the file in your <dfn>application/views/</dfn> folder.</p> - -<h2>Loading a View</h2> - -<p>To load a particular view file you will use the following function:</p> - -<code>$this->load->view('<var>name</var>');</code> - -<p>Where <var>name</var> is the name of your view file. Note: The .php file extension does not need to be specified unless you use something other than <kbd>.php</kbd>.</p> - - -<p>Now, open the controller file you made earlier called <dfn>blog.php</dfn>, and replace the echo statement with the view loading function:</p> - - -<textarea class="textarea" style="width:100%" cols="50" rows="10"> -<?php -class Blog extends CI_Controller { - - function index() - { - $this->load->view('blogview'); - } -} -?> -</textarea> - - -<p>If you visit your site using the URL you did earlier you should see your new view. The URL was similar to this:</p> - -<code>example.com/index.php/<var>blog</var>/</code> - -<h2>Loading multiple views</h2> -<p>CodeIgniter will intelligently handle multiple calls to $this->load->view from within a controller. If more than one call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view. That might look something like this:</p> -<p><code><?php<br /> -<br /> -class Page extends CI_Controller {<br /><br /> - - function index()<br /> - {<br /> - $data['page_title'] = 'Your title';<br /> - $this->load->view('header');<br /> - $this->load->view('menu');<br /> - $this->load->view('content', $data);<br /> - $this->load->view('footer');<br /> - }<br /> -<br /> -}<br /> - ?></code></p> -<p>In the example above, we are using "dynamically added data", which you will see below.</p> -<h2>Storing Views within Sub-folders</h2> -<p>Your view files can also be stored within sub-folders if you prefer that type of organization. When doing so you will need -to include the folder name loading the view. Example:</p> - -<code>$this->load->view('<kbd>folder_name</kbd>/<var>file_name</var>');</code> - - -<h2>Adding Dynamic Data to the View</h2> - -<p>Data is passed from the controller to the view by way of an <strong>array</strong> or an <strong>object</strong> in the second -parameter of the view loading function. Here is an example using an array:</p> - -<code>$data = array(<br /> - 'title' => 'My Title',<br /> - 'heading' => 'My Heading',<br /> - 'message' => 'My Message'<br /> - );<br /> -<br /> -$this->load->view('blogview', <var>$data</var>);</code> - -<p>And here's an example using an object:</p> - -<code>$data = new Someclass();<br /> -$this->load->view('blogview', <var>$data</var>);</code> - -<p>Note: If you use an object, the class variables will be turned into array elements.</p> - - -<p>Let's try it with your controller file. Open it add this code:</p> - -<textarea class="textarea" style="width:100%" cols="50" rows="14"> -<?php -class Blog extends CI_Controller { - - function index() - { - $data['title'] = "My Real Title"; - $data['heading'] = "My Real Heading"; - - $this->load->view('blogview', $data); - } -} -?> -</textarea> - - -<p>Now open your view file and change the text to variables that correspond to the array keys in your data:</p> - - -<textarea class="textarea" style="width:100%" cols="50" rows="10"> -<html> -<head> -<title><?php echo $title;?></title> -</head> -<body> - <h1><?php echo $heading;?></h1> -</body> -</html> -</textarea> - -<p>Then load the page at the URL you've been using and you should see the variables replaced.</p> - -<h2>Creating Loops</h2> - -<p>The data array you pass to your view files is not limited to simple variables. You can -pass multi dimensional arrays, which can be looped to generate multiple rows. For example, if you -pull data from your database it will typically be in the form of a multi-dimensional array.</p> - -<p>Here's a simple example. Add this to your controller:</p> - -<textarea class="textarea" style="width:100%" cols="50" rows="17"> -<?php -class Blog extends CI_Controller { - - function index() - { - $data['todo_list'] = array('Clean House', 'Call Mom', 'Run Errands'); - - $data['title'] = "My Real Title"; - $data['heading'] = "My Real Heading"; - - $this->load->view('blogview', $data); - } -} -?> -</textarea> - - -<p>Now open your view file and create a loop:</p> - - -<textarea class="textarea" style="width:100%" cols="50" rows="24"> -<html> -<head> -<title><?php echo $title;?></title> -</head> -<body> -<h1><?php echo $heading;?></h1> - -<h3>My Todo List</h3> - -<ul> -<?php foreach ($todo_list as $item):?> - -<li><?php echo $item;?></li> - -<?php endforeach;?> -</ul> - -</body> -</html> -</textarea> -<p><strong>Note:</strong> You'll notice that in the example above we are using PHP's alternative syntax. If you -are not familiar with it you can read about it <a href="alternative_php.html">here</a>.</p> - -<h2>Returning views as data</h2> - -<p>There is a third <strong>optional</strong> parameter lets you change the behavior of the function so that it returns data as a string -rather than sending it to your browser. This can be useful if you want to process the data in some way. If you -set the parameter to <kbd>true</kbd> (boolean) it will return data. The default behavior is <kbd>false</kbd>, which sends it -to your browser. Remember to assign it to a variable if you want the data returned:</p> - -<code>$string = $this->load->view('<var>myfile</var>', '', <kbd>true</kbd>);</code> - -</div> -<!-- END CONTENT --> - - -<div id="footer"> -<p> -Previous Topic: <a href="reserved_names.html">Reserved Names</a> - · -<a href="#top">Top of Page</a> · -<a href="../index.html">User Guide Home</a> · -Next Topic: <a href="models.html">Models</a> -</p> -<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2011 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> -</div> - -</body> -</html>
\ No newline at end of file |