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

[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/
#2

[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.
Code:
<? $this->load->view('news_view'); ?>
#3

[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
#4

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

[eluser]sikkle[/eluser]
Create some hmvc partial with wiredesigz things on the forum, check on ignited code.

see ya around.




Theme © iAndrew 2016 - Forum software by © MyBB