CodeIgniter Forums
explaining: $this->load->view(); - 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: explaining: $this->load->view(); (/showthread.php?tid=29448)



explaining: $this->load->view(); - El Forum - 04-09-2010

[eluser]ajsie[/eluser]
in a controller you can use this method to load a view.

but i want to know behind the scenes here.

im new to php and frameworks, but i've learned the basics of OOP.

when $this->view() is made then the method in the current class or the parent class is used.

but what does this mean: $this->load->view(). what is the intermediate load? is it a function or is it a property?

where is it located? how could it contain view()?

grateful for explanation.


explaining: $this->load->view(); - El Forum - 04-09-2010

[eluser]gvillavizar[/eluser]
What you are looking for is exactly on system\libraries\Loader.php between lines 288 and 308.


explaining: $this->load->view(); - El Forum - 04-09-2010

[eluser]ajsie[/eluser]
thanks. so that function would explain the view(). but where can i find the load property?

cause i want to understand the chain between $this->load->view().

this is the downfall of not having a full api reference available. its difficult to check what extends what, and what classes are instantiated in which properties so one can get the whole picture quicker.

yii and java have good api reference that im used to to get the full picture.

http://www.yiiframework.com/doc/api/

http://java.sun.com/j2se/1.4.2/docs/api/


explaining: $this->load->view(); - El Forum - 04-10-2010

[eluser]adamp1[/eluser]
Thats a bit more difficult to explain. As you know there is a CI_Loader class in CodeIgniter. Well CodeIgniter loads this for you and saves the instance into the load property of the 'Core Object'.

When you create a controller you always extend Controller and call the parent constructor. By doing this it means this 'Core Object' is available to you in your class by using $this. So in you controller you can now do calls to $this->load. As since we have the CI_Loader class in the load property we can call it as well. $this->load->view();


explaining: $this->load->view(); - El Forum - 04-10-2010

[eluser]ajsie[/eluser]
Ok i get it. I wonder which class this Core Object is instantiated from and WHERE this instantiation occur. And also WHERE CodeIgniter saves the instance of CI_Loader to the load property.

I just want to know where these 2 events occur. But the latter one is most relevant.

this is the downfall of not having a api reference available for getting the big picture of which class are extending whom and what classes are instantiated to what properties.

yii and java have excellent api reference documentation:

http://www.yiiframework.com/doc/api/

http://java.sun.com/j2se/1.4.2/docs/api/