Welcome Guest, Not a member yet? Register   Sign In
how to do subtemplates (master-template and content-template)
#1

[eluser]stoefln[/eluser]
i would like to nest one view into another, i mean something like this:
Code:
$data = array(
      'content' => $this->load->view('content_view',$cdata),
);

$this->load->view('masterlayout_view',$data);

anyone has an idea if this is possible with CI?

BR Stef
#2

[eluser]Sarre[/eluser]
I use a "master" template in which I load a view
Code:
<?php $this->load->view($page);?>
And in my controller I just assign that $page with the name of the content view I need...

Pretty basic, but it works perfect...
#3

[eluser]stoefln[/eluser]
[quote author="Sarre" date="1212531582"]I use a "master" template in which I load a view
Code:
<?php $this->load->view($page);?>
And in my controller I just assign that $page with the name of the content view I need...

Pretty basic, but it works perfect...[/quote]

hmm, and how do you assign data to your content view?
#4

[eluser]Sarre[/eluser]
By passing the data in your controller into your master template...
That data will automatically be passed to your content view as well, so you don't need to pass an extra $data array into that view-loader.

Just try it out, it works for me and it's really easy
#5

[eluser]stoefln[/eluser]
[quote author="Sarre" date="1212539346"]By passing the data in your controller into your master template...
That data will automatically be passed to your content view as well, so you don't need to pass an extra $data array into that view-loader.

Just try it out, it works for me and it's really easy[/quote]
yeah, thats great! thanks mate Smile




Theme © iAndrew 2016 - Forum software by © MyBB