@@ -3,10 +3,10 @@ Helper Functions
3
3
################
4
4
5
5
Helpers, as the name suggests, help you with tasks. Each helper file is
6
- simply a collection of functions in a particular category. There are URL
7
- Helpers, that assist in creating links, there are Form Helpers that help
8
- you create form elements, Text Helpers perform various text formatting
9
- routines, Cookie Helpers set and read cookies, File Helpers help you
6
+ simply a collection of functions in a particular category. There are ** URL
7
+ Helpers ** , that assist in creating links, there are Form Helpers that help
8
+ you create form elements, ** Text Helpers ** perform various text formatting
9
+ routines, ** Cookie Helpers ** set and read cookies, File Helpers help you
10
10
deal with files, etc.
11
11
12
12
Unlike most other systems in CodeIgniter, Helpers are not written in an
@@ -19,9 +19,9 @@ using a Helper is to load it. Once loaded, it becomes globally available
19
19
in your :doc: `controller <../general/controllers >` and
20
20
:doc: `views <../general/views >`.
21
21
22
- Helpers are typically stored in your system/helpers, or
23
- application/helpers directory. CodeIgniter will look first in your
24
- application/helpers directory. If the directory does not exist or the
22
+ Helpers are typically stored in your ** system/helpers ** , or
23
+ ** application/helpers directory ** . CodeIgniter will look first in your
24
+ ** application/helpers directory ** . If the directory does not exist or the
25
25
specified helper is not located there CI will instead look in your
26
26
global system/helpers folder.
27
27
@@ -32,11 +32,11 @@ Loading a helper file is quite simple using the following function::
32
32
33
33
$this->load->helper('name');
34
34
35
- Where name is the file name of the helper, without the .php file
35
+ Where ** name ** is the file name of the helper, without the .php file
36
36
extension or the "helper" part.
37
37
38
- For example, to load the URL Helper file, which is named
39
- url_helper.php, you would do this::
38
+ For example, to load the ** URL Helper ** file, which is named
39
+ ** url_helper.php ** , you would do this::
40
40
41
41
$this->load->helper('url');
42
42
@@ -63,9 +63,8 @@ Auto-loading Helpers
63
63
64
64
If you find that you need a particular helper globally throughout your
65
65
application, you can tell CodeIgniter to auto-load it during system
66
- initialization. This is done by opening the
67
- application/config/autoload.php file and adding the helper to the
68
- autoload array.
66
+ initialization. This is done by opening the **application/config/autoload.php **
67
+ file and adding the helper to the autoload array.
69
68
70
69
Using a Helper
71
70
==============
@@ -84,8 +83,8 @@ URI to the controller/function you wish to link to.
84
83
"Extending" Helpers
85
84
===================
86
85
87
- To "extend" Helpers, create a file in your application/helpers/ folder
88
- with an identical name to the existing Helper, but prefixed with MY\_
86
+ To "extend" Helpers, create a file in your ** application/helpers/ ** folder
87
+ with an identical name to the existing Helper, but prefixed with ** MY\_ **
89
88
(this item is configurable. See below.).
90
89
91
90
If all you need to do is add some functionality to an existing helper -
@@ -98,8 +97,8 @@ sense. Under the hood, this gives you the ability to add to the
98
97
functions a Helper provides, or to modify how the native Helper
99
98
functions operate.
100
99
101
- For example, to extend the native Array Helper you'll create a file
102
- named application/helpers/MY_array_helper.php, and add or override
100
+ For example, to extend the native ** Array Helper ** you'll create a file
101
+ named ** application/helpers/MY_array_helper.php ** , and add or override
103
102
functions::
104
103
105
104
// any_in_array() is not in the Array Helper, so it defines a new function
@@ -130,11 +129,11 @@ Setting Your Own Prefix
130
129
131
130
The filename prefix for "extending" Helpers is the same used to extend
132
131
libraries and Core classes. To set your own prefix, open your
133
- application/config/config.php file and look for this item::
132
+ ** application/config/config.php ** file and look for this item::
134
133
135
134
$config['subclass_prefix'] = 'MY_';
136
135
137
- Please note that all native CodeIgniter libraries are prefixed with CI\_
136
+ Please note that all native CodeIgniter libraries are prefixed with ** CI\_ **
138
137
so DO NOT use that as your prefix.
139
138
140
139
Now What?
0 commit comments