From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- user_guide/libraries/loader.html | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'user_guide/libraries/loader.html') diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 50ec60c1f..1d93af5ed 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -58,7 +58,7 @@ Loader Class

Loader Class

-

Loader, as the name suggests, is used to load elements. These elements can be libraries (classes) View files, +

Loader, as the name suggests, is used to load elements. These elements can be libraries (classes) View files, Helpers, Models, or your own files.

Note: This class is initialized automatically by the system so there is no need to do it manually.

@@ -69,7 +69,7 @@ Loader 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. +

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.

For example, if you would like to send email with CodeIgniter, the first step is to load the email class within your controller:

@@ -96,7 +96,7 @@ For example, if you have file located at:

Setting options

-

The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:

+

The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:

$config = array (
@@ -113,7 +113,7 @@ $this->load->library('email', $config);

Assigning a Library to a different object name

-

If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it +

If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.

If you prefer to set your own class names you can pass its value to the third parameter:

@@ -131,20 +131,20 @@ $this->my_session

$this->load->view('file_name', $data, true/false)

-

This function is used to load your View files. If you haven't read the Views section of the +

This function is used to load your View files. If you haven't read the Views section of the user guide it is recommended that you do since it shows you how this function 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.

+

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.

The second optional parameter can take an associative array or an object as input, which it runs through the PHP extract function to -convert to variables that can be used in your view files. Again, read the Views page to learn +convert to variables that can be used in your view files. Again, read the 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 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 assign it to a variable if you want the data returned:

+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 assign it to a variable if you want the data returned:

$string = $this->load->view('myfile', '', true); @@ -159,7 +159,7 @@ to your browser. Remember to assign it to a variable if you want the data return
$this->fubar->function();

$this->load->database('options', true/false)

-

This function lets you load the database class. The two parameters are optional. Please see the +

This function lets you load the database class. The two parameters are optional. Please see the database section for more info.

@@ -168,9 +168,9 @@ $this->fubar->function();

$this->load->vars($array)

This function takes an associative array as input and generates variables using the PHP extract function. -This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might +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 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 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 into one array for conversion to variables.

@@ -180,7 +180,7 @@ and merged into one array for conversion to variables.

$this->load->file('filepath/filename', true/false)

-

This is a generic file loading function. Supply the filepath and name in the first parameter and it will open and read the file. +

This is a generic file loading function. 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.

@@ -194,7 +194,7 @@ it will instead return the data as a string.

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 is a sample map of an package directory

+

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 is a sample map of an package directory

Sample Package "Foo Bar" Directory Map

@@ -210,18 +210,18 @@ libraries/
models/
-

Whatever the purpose of the "Foo Bar" application package, it has its own config files, helpers, language files, libraries, and models. To use these resources in your controllers, you first need to tell the Loader that you are going to be loading resources from a package, by adding the package path.

+

Whatever the purpose of the "Foo Bar" application package, it has its own config files, helpers, language files, libraries, and models. To use these resources in your controllers, you first need to tell the Loader that you are going to be loading resources from a package, by adding the package path.

$this->load->add_package_path()

-

Adding a package path instructs the Loader class to prepend a given path for subsequent requests for resources. As an example, the "Foo Bar" application package above has a library named Foo_bar.php. In our controller, we'd do the following:

+

Adding a package path instructs the Loader class to prepend a given path for subsequent requests for resources. As an example, the "Foo Bar" application package above has a library named Foo_bar.php. In our controller, we'd do the following:

$this->load->add_package_path(APPPATH.'third_party/foo_bar/');
$this->load->library('foo_bar');

$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 added, simply call the method with no parameters.

+

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 added, simply call the method with no parameters.

$this->load->remove_package_path()

@@ -231,8 +231,8 @@ $this->load->library('foo_bar');

Package view files

-

By Default, package view files paths are set when add_package_path() is called. View paths are looped through, and once a match is encountered that view is loaded.

-

In this instance, it is possible for view naming collisions within packages to occur, and possibly the incorrect package being loaded. To ensure against this, set an optional second parameter of FALSE when calling add_package_path().

+

By Default, package view files paths are set when add_package_path() is called. View paths are looped through, and once a match is encountered that view is loaded.

+

In this instance, it is possible for view naming collisions within packages to occur, and possibly the incorrect package being loaded. To ensure against this, set an optional second parameter of FALSE when calling add_package_path().

$this->load->add_package_path(APPPATH.'my_app', TRUE);
-- cgit v1.2.3-24-g4f1b