Welcome Guest, Not a member yet? Register   Sign In
Really Simple Question, Regarding load->view

If I'm using the following code, to load a view:

<?= $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?

Bradford Knowlton

[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 Smile .

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.
<? $this->load->view('news_view'); ?>

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

[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.

Create some hmvc partial with wiredesigz things on the forum, check on ignited code.

see ya around.

Theme © iAndrew 2016 - Forum software by © MyBB