From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001
From: Razican Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular
-category. There are URL Helpers, that assist in creating links, there are Form Helpers
+ Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular
+category. There are URL Helpers, that assist in creating links, there are Form Helpers
that help you create form elements, Text Helpers perform various text formatting routines,
Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.
Unlike most other systems in CodeIgniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions.
+ 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. 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 controller and views.Helper Functions
-
Helpers are typically stored in your system/helpers, or application/helpers directory. CodeIgniter will look first in your application/helpers -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 system/helpers folder.
@@ -87,10 +87,10 @@ directory. If the directory does not exist or the specified helper is not locat$this->load->helper('url');
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.
-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.
+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.
To "extend" Helpers, create a file in your application/helpers/ folder with an identical name to the existing Helper, but prefixed with MY_ (this item is configurable. See below.).
+To "extend" Helpers, create a file in your application/helpers/ folder with an identical name to the existing Helper, but prefixed with MY_ (this item is configurable. See below.).
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.
For example, to extend the native Array Helper you'll create a file named application/helpers/MY_array_helper.php, and add or override functions:
@@ -154,7 +154,7 @@ function random_element($array)The filename prefix for "extending" Helpers is the same used to extend libraries and Core classes. To set your own prefix, open your application/config/config.php file and look for this item:
+The filename prefix for "extending" Helpers is the same used to extend libraries and Core classes. To set your own prefix, open your application/config/config.php file and look for this item:
$config['subclass_prefix'] = 'MY_';
@@ -163,7 +163,7 @@ function random_element($array)In the Table of Contents you'll find a list of all the available Helper Files. Browse each one to see what they do.
+In the Table of Contents you'll find a list of all the available Helper Files. Browse each one to see what they do.
-- cgit v1.2.3-24-g4f1b