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') 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