Welcome Guest, Not a member yet? Register   Sign In
[SOLVE]how pass data to subviews
#1

[eluser]li9ht[/eluser]
mycontroller.php
Code:
$data = array("content" => "blabla bla");
$this->load->view("template.php",$data);

template.php
Code:
<?php
$this->load->view('header.php');
?>
<div id="content">
&lt;?=$content;?&gt;
</div>

header.php
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;&lt;?php=$title;?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;



question.. how do i load data into $title?
any other simpler way or am i doing it wrongly..?
#2

[eluser]CroNiX[/eluser]
in your controller:
Code:
$data['title'] = 'this is the title';
$data['content'] = 'here is some content';
$this->load->view('header', $data);
$this->load->view('template', $data);

Id remove loading the header from within the content template.
#3

[eluser]Thorpe Obazee[/eluser]
Code:
$data['title'] = 'this is the title';
$data['content'] = 'here is some content';
$this->load->vars($data);
$this->load->view('header');
$this->load->view('template');
#4

[eluser]puzzlebox[/eluser]
or this:

$data= array('title'=>'this is the title',
'content'=>'here is some content');
...
..
.
#5

[eluser]li9ht[/eluser]
Quote:Id remove loading the header from within the content template.
any specific reason why..?


solve it by declaring the global var using
Code:
$this->load->vars()
and still using the same master template




Theme © iAndrew 2016 - Forum software by © MyBB