Welcome Guest, Not a member yet? Register   Sign In
Easy Views Question
#1

[eluser]ssharp[/eluser]
I'm new to CodeIgnitor and have a quick question on views.

I have a website that is going to be made up of a lot of dynamic components. The actual page content themselves will have dynamic content and the general site template will also have some dynamic content.

Is it proper to have Views reference other Views or must all views be called from the controller?
#2

[eluser]gtech[/eluser]
I load views within views and it does me no harm (In my opinion it does not break MVC as you are only loading more display data).

Be aware that a view loaded within a view will automatically have the same variables available as the 'parent' view, without having to pass data through the second parameter when using $this->load->view. (the same applies when you load a second view within the controller in the same page request)
#3

[eluser]ssharp[/eluser]
Thanks.

What is the proper way to load them from a view? I'm not sure exactly how CI parses these, so can I still use $this->load->view("") inside of the view or is there another "proper" way to do it. I could just throw in a <?php include_once(""); ?> in the view but would rather do it the "CI way".
#4

[eluser]gtech[/eluser]
Code:
<?php
$this->load->view('viewname');
?>
works for me. you still have access to $this-> in the views.

*you cannot call controller functions through $this-> once in a view though.




Theme © iAndrew 2016 - Forum software by © MyBB