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

[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 ?
#2

[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
#3

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

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

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

[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




Theme © iAndrew 2016 - Forum software by © MyBB