From 1f622294b92c095fd91e8ca44912d405c1605ded Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Thu, 7 Apr 2011 12:06:51 -0400 Subject: Wow, I screwed that up, Reactor is going to 2.0.2 not 2.0.1 --- user_guide/libraries/loader.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide/libraries/loader.html') diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 62a250482..42f8cf94f 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.0.1

CodeIgniter User Guide Version 2.0.2

-- cgit v1.2.3-24-g4f1b From e08c527aa0a8a05836b05763d859eb3d2970f62f Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Wed, 20 Apr 2011 09:54:47 -0500 Subject: Updating Documentation on package view loading --- user_guide/libraries/loader.html | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'user_guide/libraries/loader.html') diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index 42f8cf94f..1d93af5ed 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -231,17 +231,22 @@ $this->load->library('foo_bar');

Package view files

-

@todo - package view file interface is not complete. It can be experimentally used by first saving the Loader's original view path, setting the view path to the package's view path, and when finished, setting back to the original view path.

- -// ... save the original view path, and set to our Foo Bar package view folder
-$orig_view_path = $this->load->_ci_view_path;
-$this->load->_ci_view_path = APPPATH.'third_party/foo_bar/views/';
-
-// ... code using the package's view files
-
-// ... then return the view path to the application's original view path
-$this->load->_ci_view_path = $orig_view_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);
+$this->load->view('my_app_index'); // Loads
+$this->load->view('welcome_message'); // Will not load the default welcome_message b/c the second param to add_package_path is TRUE
+
+// Reset things
+$this->load->remove_package_path(APPPATH.'my_app');
+
+// Again without the second parameter:
+$this->load->add_package_path(APPPATH.'my_app', TRUE);
+$this->load->view('my_app_index'); // Loads
+$this->load->view('welcome_message'); // Loads
+
-- cgit v1.2.3-24-g4f1b From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001 From: Razican Date: Mon, 25 Apr 2011 17:26:45 +0200 Subject: Fixed double-space typo. --- 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 1d93af5ed..50ec60c1f 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 retur
$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