CodeIgniter Forums

Full Version: views and controllers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
I have several controllers that load the same views (besides specific views for each controller).
Is there a way to do it only once ?

El Forum

[eluser]InsiteFX[/eluser]
Create a template_view, something like this add more if you need them.
Code:
<?php $this->load->view(header_view);?>

<?php $this->load->view(body_view);?>

<?php $this->load->view(footer_view);?>

Controller:
Code:
$this->load->vars($data);
$this->load->view('template_view');

InsiteFX

El Forum

[eluser]Unknown[/eluser]
thanks but what I meant was regarding the $data...

El Forum

[eluser]dUspan[/eluser]
you mean this?

<?php
$data['body']="view body content";
$this->load->view('body_view',$data);
?>

El Forum

[eluser]InsiteFX[/eluser]
You mentioned nothing about data all about views!
Then look into creating a MY_Controller in the CodeIgniter User Guide

This can be used any place in your code and makes the data avaiable to all your views!
Code:
$this->load->vars($data);

InsiteFX