Welcome Guest, Not a member yet? Register   Sign In
nested views
#1

[eluser]Siyavash[/eluser]
Hi

I have started using CI for about 3 weeks and now I have faced a problem . The exact problem is as follows :

I need to load a view file that could be able to load another view file itself. to be more accurate , suppose you have a header, a content and a footer and you want to load a view file in content and the loaded view file contains a link that when clicked updates a part of content (suppose content div is consist of 2 divs)
how can I do that ?

sending a $this->load->view() as a parameter is not the answer I know, but what is the solution ?
#2

[eluser]bubbafoley[/eluser]
you can load views from other views but I would do something like this

controller
Code:
$data['header'] = $this->load->view('header', '', TRUE);
$data['footer'] = $this->load->view('footer', '', TRUE);
$this->load->view('content', $data);

content view
Code:
<?php echo $header ?>
<div>CONTENT GOES HERE</div>
&lt;?php echo $footer ?&gt;
#3

[eluser]Siyavash[/eluser]
thanks for your quick reply. But I knew that i could use that method.
let me clarify my question. suppose you have loaded the header and now (after loading the whole parts) you want to load another view in a div tag inside the header.
I thought maybe i should use AJAX or something like that. CI itself doesn't support such thing. Am I right ?
#4

[eluser]bubbafoley[/eluser]
yes you need to use javascript to change the content after the page is loaded.
#5

[eluser]Siyavash[/eluser]
Thanks then!




Theme © iAndrew 2016 - Forum software by © MyBB