Welcome Guest, Not a member yet? Register   Sign In
$this->load->view unexpected behavior.

I did a little test to check my theory.

What i did:
1. Created a view in subfolder: view/subfolder/test_view.php
2. Created another view in sub/subfolder: view/subfolder/_subfolder/inc_view.php
3. Created controller to call test_view.php view
4. Edited Loader library to echo view $path

test_view.php code:


echo __FILE__;



I get:

As you can see, im right now at "subfolder/test_view.php" and im trying to load view from "_subfolder/", but it searches for a view in a root directory. Shouldn't it be searching at "subfolder" directory as I'm already there?

[eluser]Matthew Pennell[/eluser]
No - the Loader class for views just looks in the /views directory, it won't take into account where in the file structure you happen to be when you call it.

[eluser]Michael Wales[/eluser]
Nope - all views are stored in the /views folder. The MVC framework (seperation of data, layout, and logic) produces this (and it's awesome).

With CI - always work off of the root. Images, Javascript, etc - reference it all from root - it will make your life much easier.

Theme © iAndrew 2016 - Forum software by © MyBB