summaryrefslogtreecommitdiffstats
path: root/user_guide_src
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-01-28 20:46:08 +0100
committerAndrey Andreev <narf@bofh.bg>2013-01-28 20:46:08 +0100
commitc26d34ff12458760eb843454d3224e1dad1fb2e0 (patch)
treeaa13a094e46385f54ae865df3bb283df77bd70f1 /user_guide_src
parent662e34291a2d5d8997ea9835701fb9a8a7ec244c (diff)
Fix issue #2202 and alter Loader Class docs
Diffstat (limited to 'user_guide_src')
-rw-r--r--user_guide_src/source/libraries/loader.rst146
1 files changed, 72 insertions, 74 deletions
diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst
index 615aba1c2..b048f4881 100644
--- a/user_guide_src/source/libraries/loader.rst
+++ b/user_guide_src/source/libraries/loader.rst
@@ -11,14 +11,15 @@ can be libraries (classes) :doc:`View files <../general/views>`,
.. note:: This class is initialized automatically by the system so there
is no need to do it manually.
-The following functions are available in this class:
+The following methods are available in this class:
$this->load->library('class_name', $config, 'object name')
-===========================================================
+==========================================================
-This function is used to load core classes. Where class_name is the
-name of the class you want to load. Note: We use the terms "class" and
-"library" interchangeably.
+This method is used to load core classes. Where class_name is the
+name of the class you want to load.
+
+.. note:: We use the terms "class" and "library" interchangeably.
For example, if you would like to send email with CodeIgniter, the first
step is to load the email class within your controller::
@@ -26,15 +27,15 @@ step is to load the email class within your controller::
$this->load->library('email');
Once loaded, the library will be ready for use, using
-$this->email->*some_function*().
+$this->email->*some_method*().
Library files can be stored in subdirectories within the main
-"libraries" folder, or within your personal application/libraries
-folder. To load a file located in a subdirectory, simply include the
-path, relative to the "libraries" folder. For example, if you have file
-located at::
+"libraries" directory, or within your personal application/libraries
+directory. To load a file located in a subdirectory, simply include the
+path, relative to the "libraries" directory. For example, if you have
+file located at::
- libraries/flavors/chocolate.php
+ libraries/flavors/Chocolate.php
You will load it using::
@@ -43,7 +44,7 @@ You will load it using::
You may nest the file in as many subdirectories as you want.
Additionally, multiple libraries can be loaded at the same time by
-passing an array of libraries to the load function.
+passing an array of libraries to the load method.
::
@@ -56,10 +57,10 @@ The second (optional) parameter allows you to optionally pass
configuration setting. You will typically pass these as an array::
$config = array (
- 'mailtype' => 'html',
- 'charset' => 'utf-8,
- 'priority' => '1'
- );
+ 'mailtype' => 'html',
+ 'charset' => 'utf-8,
+ 'priority' => '1'
+ );
$this->load->library('email', $config);
@@ -84,16 +85,15 @@ third parameter::
$this->load->library('calendar', '', 'my_calendar');
// Calendar class is now accessed using:
-
$this->my_calendar
Please take note, when multiple libraries are supplied in an array for
the first parameter, this parameter is discarded.
$this->load->driver('parent_name', $config, 'object name')
-===========================================================
+==========================================================
-This function is used to load driver libraries. Where parent_name is the
+This method is used to load driver libraries. Where parent_name is the
name of the parent class you want to load.
As an example, if you would like to use sessions with CodeIgniter, the first
@@ -102,15 +102,15 @@ step is to load the session driver within your controller::
$this->load->driver('session');
Once loaded, the library will be ready for use, using
-$this->session->*some_function*().
+$this->session->*some_method*().
Driver files must be stored in a subdirectory within the main
-"libraries" folder, or within your personal application/libraries
-folder. The subdirectory must match the parent class name. Read the
+"libraries" directory, or within your personal application/libraries
+directory. The subdirectory must match the parent class name. Read the
:doc:`Drivers <../general/drivers>` description for details.
Additionally, multiple driver libraries can be loaded at the same time by
-passing an array of drivers to the load function.
+passing an array of drivers to the load method.
::
@@ -122,11 +122,11 @@ Setting options
The second (optional) parameter allows you to optionally pass
configuration settings. You will typically pass these as an array::
- $config = array (
- 'sess_driver' => 'cookie',
- 'sess_encrypt_cookie' => true,
- 'encryption_key' => 'mysecretkey'
- );
+ $config = array(
+ 'sess_driver' => 'cookie',
+ 'sess_encrypt_cookie' => true,
+ 'encryption_key' => 'mysecretkey'
+ );
$this->load->driver('session', $config);
@@ -135,12 +135,12 @@ is explained in detail in its own page, so please read the information
regarding each one you would like to use.
Assigning a Driver to a different object name
-----------------------------------------------
+---------------------------------------------
If the third (optional) parameter is blank, the library will be assigned
to an object with the same name as the parent class. For example, if
the library is named Session, it will be assigned to a variable named
-$this->session.
+``$this->session``.
If you prefer to set your own class names you can pass its value to the
third parameter::
@@ -148,32 +148,33 @@ third parameter::
$this->load->library('session', '', 'my_session');
// Session class is now accessed using:
-
$this->my_session
-.. note:: Driver libraries may also be loaded with the library() method,
- but it is faster to use driver()
+.. note:: Driver libraries may also be loaded with the ``library()`` method,
+ but it is faster to use ``driver()``.
-$this->load->view('file_name', $data, true/false)
-==================================================
+$this->load->view('file_name', $data, TRUE/FALSE)
+=================================================
-This function is used to load your View files. If you haven't read the
+This method is used to load your View files. If you haven't read the
:doc:`Views <../general/views>` section of the user guide it is
-recommended that you do since it shows you how this function is
+recommended that you do since it shows you how this method is
typically used.
The first parameter is required. It is the name of the view file you
-would like to load. Note: The .php file extension does not need to be
-specified unless you use something other than .php.
+would like to load.
+
+.. note:: The .php file extension does not need to be specified unless
+ you use something other than .php.
The second **optional** parameter can take an associative array or an
object as input, which it runs through the PHP
-`extract <http://www.php.net/extract>`_ function to convert to variables
+`extract() <http://www.php.net/extract>`_ function to convert to variables
that can be used in your view files. Again, read the
:doc:`Views <../general/views>` page to learn how this might be useful.
The third **optional** parameter lets you change the behavior of the
-function so that it returns data as a string rather than sending it to
+method 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 true (boolean) it will return data. The
default behavior is false, which sends it to your browser. Remember to
@@ -189,79 +190,76 @@ $this->load->model('model_name');
$this->load->model('model_name');
-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
+If your model is located in a subdirectory, include the relative path
+from your models directory. For example, if you have a model located at
application/models/blog/queries.php you'll load it using::
$this->load->model('blog/queries');
-
If you would like your model assigned to a different object name you can
-specify it via the second parameter of the loading function::
+specify it via the second parameter of the loading method::
$this->load->model('model_name', 'fubar');
+ $this->fubar->method();
- $this->fubar->function();
-
-$this->load->database('options', true/false)
+$this->load->database('options', TRUE/FALSE)
============================================
-This function lets you load the database class. The two parameters are
+This method lets you load the database class. The two parameters are
**optional**. Please see the :doc:`database <../database/index>`
section for more info.
$this->load->vars($array)
=========================
-This function takes an associative array as input and generates
+This method takes an associative array as input and generates
variables using the PHP `extract <http://www.php.net/extract>`_
-function. This function produces the same result as using the second
-parameter of the $this->load->view() function above. The reason you
-might want to use this function independently is if you would like to
+method. This method produces the same result as using the second
+parameter of the ``$this->load->view()`` method above. The reason you
+might want to use this method independently is if you would like to
set some global variables in the constructor of your controller and have
-them become available in any view file loaded from any function. You can
-have multiple calls to this function. The data get cached and merged
+them become available in any view file loaded from any method. You can
+have multiple calls to this method. The data get cached and merged
into one array for conversion to variables.
$this->load->get_var($key)
-===========================
+==========================
-This function checks the associative array of variables available to
+This method checks the associative array of variables available to
your views. This is useful if for any reason a var is set in a library
-or another controller method using $this->load->vars().
+or another controller method using ``$this->load->vars()``.
$this->load->get_vars()
-===========================
+=======================
-This function retrieves all variables available to
-your views.
+This method retrieves all variables available to your views.
$this->load->helper('file_name')
-=================================
+================================
-This function loads helper files, where file_name is the name of the
+This method loads helper files, where file_name is the name of the
file, without the _helper.php extension.
-$this->load->file('filepath/filename', true/false)
+$this->load->file('filepath/filename', TRUE/FALSE)
==================================================
-This is a generic file loading function. Supply the filepath and name in
+This is a generic file loading method. Supply the filepath and name in
the first parameter and it will open and read the file. By default the
data is sent to your browser, just like a View file, but if you set the
second parameter to true (boolean) it will instead return the data as a
string.
$this->load->language('file_name')
-===================================
+==================================
-This function is an alias of the :doc:`language loading
-function <language>`: $this->lang->load()
+This method is an alias of the :doc:`language loading
+method <language>`: ``$this->lang->load()``
$this->load->config('file_name')
-=================================
+================================
-This function is an alias of the :doc:`config file loading
-function <config>`: $this->config->load()
+This method is an alias of the :doc:`config file loading
+method <config>`: ``$this->config->load()``
Application "Packages"
======================
@@ -269,7 +267,7 @@ Application "Packages"
An application package allows for the easy distribution of complete sets
of resources in a single directory, complete with its own libraries,
models, helpers, config, and language files. It is recommended that
-these packages be placed in the application/third_party folder. Below
+these packages be placed in the application/third_party directory. Below
is a sample map of an package directory
Sample Package "Foo Bar" Directory Map
@@ -311,7 +309,7 @@ $this->load->remove_package_path()
When your controller is finished using resources from an application
package, and particularly if you have other application packages you
want to work with, you may wish to remove the package path so the Loader
-no longer looks in that folder for resources. To remove the last path
+no longer looks in that directory for resources. To remove the last path
added, simply call the method with no parameters.
$this->load->remove_package_path()
@@ -346,4 +344,4 @@ calling add_package_path().
// Again without the second parameter:
$this->load->add_package_path(APPPATH.'my_app');
$this->load->view('my_app_index'); // Loads
- $this->load->view('welcome_message'); // Loads
+ $this->load->view('welcome_message'); // Loads \ No newline at end of file