diff options
Diffstat (limited to 'user_guide/general/helpers.html')
-rw-r--r-- | user_guide/general/helpers.html | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/user_guide/general/helpers.html b/user_guide/general/helpers.html index 99f47178e..3747eb7b9 100644 --- a/user_guide/general/helpers.html +++ b/user_guide/general/helpers.html @@ -28,7 +28,7 @@ <div id="masthead"> <table cellpadding="0" cellspacing="0" border="0" style="width:100%"> <tr> -<td><h1>CodeIgniter User Guide Version 2.0.2</h1></td> +<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> @@ -57,20 +57,20 @@ Helper Functions <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> +<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. +<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> +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 +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> @@ -87,10 +87,10 @@ directory. If the directory does not exist or the specified helper is not locate <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 +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> +<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> @@ -117,12 +117,12 @@ This is done by opening the <var>application/config/autoload.php</var> file and <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>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, + 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> @@ -154,7 +154,7 @@ function random_element($array)<br /> <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> +<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> @@ -163,7 +163,7 @@ function random_element($array)<br /> <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> +<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> |