CodeIgniter Forums
View loading failure - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: View loading failure (/showthread.php?tid=2871)



View loading failure - El Forum - 08-29-2007

[eluser]ralf57[/eluser]
I've just found a strange behaviour trying to load a view while adding dynamic data to it.
It's a peculiar case and i need it to be confirmed before i submit it to the Bug Tracker.
My controller:
Code:
class MyController extends Controller
    {
    
        function MyController()
        {
            parent::Controller();
        }
    
        function index()
        {
            $data = array(
                'title' => 'My Title',
                'path' => 'My Title',
                'heading' => 'My Heading',
                'message' => 'My Message'
            );
            
            $this->load->view('myview', $data);
        }
    
    }

If in the passed array there is a key named "path" the view is not loaded at all
throwing this warning:

Code:
A PHP Error was encountered

Severity: Warning

Message: CI_Loader::include(My Title) [function.CI-Loader-include]: failed to open stream: No such file or directory

Filename: libraries/Loader.php

Line Number: 652

a quick check reveals that $data['path'] is used in libraries/Loader.php line 652 instead of the correct path.
Removing the $data['path'] key will fix the problem.

Is this a bug? Can you reproduce it?

------------------

Environement:
PHP Version 5.2.1
Apache 2.2.3


View loading failure - El Forum - 08-29-2007

[eluser]jedre[/eluser]
Hi, maybe it's small offtopic,
but if you use PHP v. 5.2.1 why u write constructor in PHP4 style?


View loading failure - El Forum - 08-29-2007

[eluser]deviant[/eluser]
To make it compatible with PHP4?


View loading failure - El Forum - 08-29-2007

[eluser]ralf57[/eluser]
Instead of going off-topic, did you try and reproduce
the behaviour/bug?


View loading failure - El Forum - 08-29-2007

[eluser]xwero[/eluser]
do you have a myview.php file?

ok that was not the question, you can skip my question.

I tried to reproduce it and i got an error in the Loader class on line 639, a variable $path is used there.


View loading failure - El Forum - 08-29-2007

[eluser]ralf57[/eluser]
[quote author="xwero" date="1188408739"]
I tried to reproduce it and i got an error in the Loader class on line 639, a variable $path is used there.[/quote]

if you do a "var_dump($path)" you get "My Title" instead of the path/to/the/myview, don't you?


View loading failure - El Forum - 08-29-2007

[eluser]xwero[/eluser]
Yes the $path value in the loader class was the value from the array. I used different values but with the same path key as you.


View loading failure - El Forum - 08-29-2007

[eluser]ralf57[/eluser]
It looks like a bug.
I will post it to the bugtracker.


View loading failure - El Forum - 08-29-2007

[eluser]coolfactor[/eluser]
I've notified the person in charge of maintaining CI.


View loading failure - El Forum - 09-03-2007

[eluser]barbazul[/eluser]
As I mentioned in this topic there are some reserved words in views.

Check the loader class and you'll notice that there are some assignments to the $data array.

The following are reserved variable names:
view
vars
path
return

and they should be documented