![]() |
Really Simple Question, Regarding load->view - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Really Simple Question, Regarding load->view (/showthread.php?tid=8431) |
Really Simple Question, Regarding load->view - El Forum - 05-17-2008 [eluser]bradmkjr[/eluser] If I'm using the following code, to load a view: home_view.php: Code: <?= $this->load->view('news_view', $data, true) ?> I'm I correct in assuming that the news controller is never loaded, since the news_view is loaded directly by the home_view? What is the correct way to load a controller from within a view? or is that not the correct way to do it? thanks, Bradford Knowlton http://x86Virtualization.com/ Really Simple Question, Regarding load->view - El Forum - 05-17-2008 [eluser]Pascal Kriete[/eluser] It's not a correct way to do it. Libraries and helpers are made specifically for shared components. You still have that good ol' include() mindset ![]() Also, you can nest views normally, there is no need to get the text and echo it. The views are flattened first as well, so there is no need to pass data in again. Code: <? $this->load->view('news_view'); ?> Really Simple Question, Regarding load->view - El Forum - 05-17-2008 [eluser]bradmkjr[/eluser] Thank you for the quick reply. I'm walking into CI as a newbie on a rather large project, so I have been learning by looking at everyones code before me. What I'm currently working on is a Social Networking library to display the users data (# of friends, new messages etc) on different views. I'm a little puzzled right now as where to put the class initialization calls, would it be acceptable to put them in a facebook view? Thanks again for the quick reply, Bradford Knowlton http://x86Virtualization.com Really Simple Question, Regarding load->view - El Forum - 05-17-2008 [eluser]Pascal Kriete[/eluser] You load any classes you need in your controller and then pass the data/object-references you need to your view in the $data array. Really Simple Question, Regarding load->view - El Forum - 05-17-2008 [eluser]sikkle[/eluser] Create some hmvc partial with wiredesigz things on the forum, check on ignited code. see ya around. |