CodeIgniter Forums
Templatefile - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Templatefile (/showthread.php?tid=34709)



Templatefile - El Forum - 10-07-2010

[eluser]Fireclave[/eluser]
Hi, i am using a Templatefile:

Controller
Code:
function index()
   $data['site_load']  = 'adressbook/detail';
   $this->load->view('template', [b]$data[/b]);
}

Temlatefile

Code:
$this->load->view('includes/header');

if(isset($site_load))
    $this->load->view($site_load);
else  
    $this->load->view('user_panel/control');

$this->load->view('includes/footer');

But my Problem is, that the $data in my Controller will lost, because i send it to the template and not to the content page...

Do you have any idea ?

Possible is this in the Controller:

$d[$data];
$this->load->view('template', $data);

but i don't like this way.


Templatefile - El Forum - 10-07-2010

[eluser]InsiteFX[/eluser]
Give this a try:

Code:
function index() {
   $data['site_load']  = 'adressbook/detail';
   $this->load_vars($data);
   $this->load->view('template');
}

InsiteFX


Templatefile - El Forum - 10-07-2010

[eluser]Fireclave[/eluser]
$this->load_vars($data);

This is new ;-)
Thank you


Templatefile - El Forum - 10-07-2010

[eluser]InsiteFX[/eluser]
Your very welcome, take a look at the loader library!

InsiteFX